Skip to content

Camera Shake

Amethyst-szs edited this page Dec 6, 2023 · 8 revisions

Introduction

This plugin includes an extra type of camera behavior separate from camera actions, the CameraShake node. It can be freely configured in the inspector or code, and then played in your application or game.

One important note about camera shake. This node is heavily integrated into the rest of CameraAction. You cannot use camera shake if there is no CameraAction active at that time, attempting to do so will have no effect and push a warning in your debugger.

Methods

Interacting with camera shakes through your code only requires a couple methods:

start(): Begins your camera shake and will play using whatever parameters are currently set.

end(): Ends your camera shake instantly with no easing applied. Useful to stop infinite duration shakes.

end_ease(): Will play the ease out section of your shake and then stop itself. Works even with infinite duration.

Properties

Lifetime

The lifetime of a camera shake node determines how long the shake is going to play. You can also enable infinite duration to make the camera shake forever until manually stopped.

Animation

The animation settings control how fast the shake moves the camera, as well as how the shake should be eased into and out of.

Speed: The speed of camera's movement is calculated as sin(time_in_seconds * speed). The higher the speed value, the faster the camera shake around.

Easing: Sets if the camera eases into the shake, out of the shake, both, or neither.

Ease In Length: The amount of time in seconds that the camera will spend easing into the shake

Ease Out Length: Time in seconds the camera will ease out of the shake

Randomness

The randomness settings control the pseudo-random shaking that the camera will perform.

Complexity: A number ranging from 1-5 (Default 2) that controls how complex the shaking pattern is. This number is applied as the amount of sine waves of random length to average together. This means a complexity of 1 will follow a perfectly smooth random motion, and a complexity of 5 will be frantic and unpredictable.

Seed: The seed is fed into the random number generator to determine its output. If you don't like the pattern your shake is following, try out a couple different seeds.

Variations: This determines if the seed should be automatically randomly re-rolled every time it plays. This gives you less manual control over your shake, but prevents the same camera shake node from getting repetitive when played multiple times.

Size

Control how far the camera is able to move, rotate, and zoom during the shake. If you want to enable rotation and zoom shaking, you'll need to enable them in the components section.

Horizontal Size and Vertical Size: These control how far the camera will shake on the x axis and y axis. Note that these are a radius, so a value of 10px will have a diameter of 20px.

Rotation Size: How far can the camera rotate during a shake? This value is stored in degrees.

Zoom Size: Control the camera's zooming in and out during a camera shake. Note that this is not in pixels, but instead a direct offset to the zoom value on the Camera2D.

Components

Toggle what parts of the camera are animated by the shake. You can enable and disable position shaking, rotation shaking, and zoom shaking.

Clone this wiki locally