← all demos · chapter 06

Screen shake — the kind version

The good recipe: keep a trauma value 0–1 that decays every frame; camera offset = smooth noise × trauma². Noise (not random jumps) keeps it smooth; the square makes small hits whisper and big hits roar; decay ends it quickly. Press Run, then click the canvas to add impacts.

Click once: a polite nudge. Click four times fast: a real quake — because trauma adds up and the square amplifies the top end. The bar shows calm returning.

Try tweaking: remove the square (const shake = trauma;) — feel how small hits get too loud · MAX_OFFSET 14 → 40 (then please come back down) · DECAY 1.4 → 0.3 for a long aftershock. Accessibility stance: keep amplitude modest, keep frequency low, and ship a "reduce shake" toggle — calm defaults cost nothing.

In Godot: apply dx/dy to Camera2D.offset, driving noise from FastNoiseLite — download shake.gd, trauma² and all. In Unity: same recipe on the camera transform in LateUpdate() (or Cinemachine's impulse system, which implements exactly this). In Unreal: a CameraShakeBase class — its oscillation fields are these numbers with different names. Chapter 06.