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; }); |
|