Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Camera shake action for explosions

Des
Guest
Quote
2023-03-24 04:08:45

Guys I've got some code here for camera shake can any programmer make it a coppercube action for me please


Des
Guest
Quote
2023-03-24 04:09:36

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


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact