Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Guys I've got some code here for camera shake can any programmer make it a coppercube action for me please |
||||
|
// Set the duration of the shake effect (in milliseconds) var shakeDuration = 1000; // Set the intensity of the shake effect (in pixels) var shakeIntensity = 10; // Get a reference to the camera object var camera = CopperCube.getScene().getActiveCamera(); // Get the camera's initial position var startX = camera.getPositionX(); var startY = camera.getPositionY(); var startZ = camera.getPositionZ(); // Define the easing function to use for the shake effect var easingFunction = CopperCube.Easing.ElasticOut; // Start the shake effect CopperCube.getScene().startAction(function (elapsedTime) { // Calculate the current shake intensity var shakeX = (Math.random() * shakeIntensity * 2 - shakeIntensity) * easingFunction(elapsedTime / shakeDuration); var shakeY = (Math.random() * shakeIntensity * 2 - shakeIntensity) * easingFunction(elapsedTime / shakeDuration); var shakeZ = (Math.random() * shakeIntensity * 2 - shakeIntensity) * easingFunction(elapsedTime / shakeDuration); // Set the camera's position to the new, shaken position camera.setPosition(startX + shakeX, startY + shakeY, startZ + shakeZ); // End the shake effect after the specified duration has elapsed if (elapsedTime >= shakeDuration) { return false; } return true; }); |
||||
|
Hi! Did anyone ever get back to you on this and make it into an Action? That would be great. Sorry, not really great at the coding thing, but would this work in an Execute Java Script Action? Thank you, Moris |
||||
|
@morbott, there is already a camera shake extension available. The post you commented on didn't get any responses likely because the code shared by @OP seems to be AI-generated and doesn't actually use the CopperCube API. I'm not sure of the exact links to a camera shake extension, but either @SamMhmdy or @SamGrady created one. You can also experiment with the "up Vector" of the camera to create your own shake effect. |
||||
|
both @SamMhmdy @SamGrady AND @Hadooken made extensions that were messing with upvector, you can find them by searching on forum "upvector", the most suitable for this extension mission is one that @Hadooken wrote (nerd emoji) |
||||
|
Des wrote: // Set the duration of the shake effect (in milliseconds) var shakeDuration = 1000; // Set the intensity of the shake effect (in pixels) var shakeIntensity = 10; // Get a reference to the camera object var camera = CopperCube.getScene().getActiveCamera(); // Get the camera's initial position var startX = camera.getPositionX(); var startY = camera.getPositionY(); var startZ = camera.getPositionZ(); // Define the easing function to use for the shake effect var easingFunction = CopperCube.Easing.ElasticOut; // Start the shake effect CopperCube.getScene().startAction(function (elapsedTime) { // Calculate the current shake intensity var shakeX = (Math.random() * shakeIntensity * 2 - shakeIntensity) * easingFunction(elapsedTime / shakeDuration); var shakeY = (Math.random() * shakeIntensity * 2 - shakeIntensity) * easingFunction(elapsedTime / shakeDuration); var shakeZ = (Math.random() * shakeIntensity * 2 - shakeIntensity) * easingFunction(elapsedTime / shakeDuration); // Set the camera's position to the new, shaken position camera.setPosition(startX + shakeX, startY + shakeY, startZ + shakeZ); // End the shake effect after the specified duration has elapsed if (elapsedTime >= shakeDuration) { return false; } return true; }); Please don't waste people's time with this AI crap. It can be useful for some stuff (particularly if you make an extension or code and want to know if it can be optimized beyond what you can do), but this? No... As others have stated, nothing there is usable. I understand you wanted to help, but please research how things work in this engine before just asking ChatGPT to make you something which is of no use, and pass it off as a solution, confusing others. |
|