UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Ui Module / Camera Shake System Completed

Ui Module — UGTK

Camera Shake

Summary

The Camera Shake module applies Perlin-noise position and rotation shake to a target Transform. It supports layered simultaneous shakes, reusable ShakeProfiles, envelopes, and per-shake handles for stopping and completion callbacks.


Content


Modules Dependencies

This module has no hard UGTK dependencies.


Setup

Drop the CameraShake prefab into the scene (or add Mn_CameraShake straight onto your camera):


How To Use

  1. Add Mn_CameraShake to your camera (or any object). If target is left empty it auto-assigns Camera.main.transform on Start.
  2. Trigger a shake:
  3. From an Inspector/UnityEvent with no arguments: TriggerDefaultShake().
  4. Quick one-shot from code: PlaySimpleShake(duration, intensity, frequency, ...).
  5. From a predefined profile: PlayShake(profile, strengthMultiplier, durationOverride, tag, onComplete).
  6. Reference the returned ShakeHandle to StopShake(handle) / StopShakeById(id), or call StopAllShakes().
  7. Access it anywhere via the static Mn_CameraShake.Instance, and hook OnAnyShakeCompleted to react when any shake ends.

Each ShakeProfile exposes duration, intensity, per-axis position/rotation amplitude and masks, frequency, an envelope curve, unscaled-time option, local/world space, and extra blend-in/out.

Good to know:


Testing Scene

Open Debug/CameraShakeScene.unity. It holds a CameraShake object wired to the Main Camera, an orange landmark and a floor, so a shake is something you can actually see. Select CameraShake and use the Editor Test Tools block; the controls need Play mode, and outside it they say so.

What to do, in order:

  1. Press Trigger Default Shake() and watch the landmark move against the frame.
  2. Raise Intensity and press Play Simple Shake(): the same shake, harder.
  3. Turn Affect Rotation off and repeat. A shake that only translates reads as a bump; one that rotates reads as an impact.
  4. Start a second shake while the first is running. They add up rather than replacing each other, which is what makes a burst of small hits feel different from one big one.
  5. Press StopAllShakes() while several are running: the camera returns to its base transform, not to wherever the last frame left it.

The scene shipped with nothing but a camera and a light: the component that gives the module its name was in a prefab that no scene used, so there was nothing to shake and nothing to look at.


Technical Info


© 2026 Marcello De Bonis. All rights reserved