Camera Shake 2D
Tunes the shake of its virtual camera. Shake grows with trauma and fades over time.
component camera.CameraShake2D
On this page
Usage
Needs Virtual Camera 2D on the same node.
Try it
Rotate the shaken view
A single full hit is held with zero Decay. The landmarks stay still; the camera's zero Max Angle initially prevents rotation.
Change Max Angle from 0 to 0.5 radians to see the view shake. Reset restores the still view. Reduced-motion settings can suppress shake.
Starts the scene; open the example parameters to experiment.
Scene6 nodes
View
Transform
position[0, 0]rotation0scale[1, 1]
Scriptmain.aes
package demo
import "aego/camera"
// Hold one full hit so the editable Max Angle can be compared at any time.
// Zero Decay in the scene keeps the hit; the camera service supplies the motion.
script ShakeOnce {
func Ready() {
camera.Shake(1)
}
}
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Decay | float | 1.5 | Trauma lost per second. ≥ 0 |
| Max Offset | Vec2 | (0.5, 0.5) | Largest offset in world units at full trauma. |
| Max Angle | float | 0.05 | Largest rotation in radians at full trauma. ≥ 0 |
| Frequency | float | 25 | How fast the shake changes, in noise steps per second. ≥ 0 |
| Exponent | float | 2 | Shake is trauma to this power: 2 keeps small hits subtle. ≥ 1 |
Methods
Add method
func (CameraShake2D) Add(trauma float)
Adds trauma to the output of this camera; trauma is capped at 1.
Related guides
- Shake In Try it, the crate drops every two seconds and its script calls
camera.Shake(0.9)when it lands. - Cameras 2D A Camera 2D draws the view; virtual cameras decide where it looks.