Shake
Overview
The Shake extension, like you probably have guessed, allows you create all kind of different camera shake effects. You can create shake effects that are applied once or multiple times, like explosions and gun fire. Or you can create constant shake effects that are enabled during a certain period of time, like a handheld camera effect or a long earthquake. The shake editor simply lists all the available presets on the current scene. To create new ones press the "Create ShakePreset" or "Create ConstantShakePreset". They'll be automatically added to the list. You can then select each preset individually and tweak the values. All presets live on their own files and all changes are saved even at runtime. This way you can test your shakes during runtime and adjust until you find the perfect values.
Shake once example (explosion)
Constant shake example (handheld)
Editor
Parameters:
Shake Presets
: A list of all the loaded shake presets on this sceneConstant Shake Presets
: A list of all the loaded constant shake presets on this scene
Shake Preset Editor
Parameters:
Strength
: The shake strength on each axisDuration (>0)
: The duration of the shakeVibrato
: Indicates how much will the shake vibrateSmoothness
: The smoothness of the shake. Lower numbers provide more aggressive shakesRandomness
: Indicates how random the shake will beUse Random Initial Angle
: If enabled, the initial shaking angle will be randomRotation
: The maximum rotation the camera will reachIgnore TimeScale
: Uses an unscaled delta time
Constant Shake Preset Editor
Parameters:
Intensity
: How fast the camera will move between the different amplitudes. Lower values produce smoother resultsLayers
: The number of accumalated movements the camera does. Usually one is enough. 3 is recommended for handheld simulation.Frequency
: How fast the camera moves towards the amplitudeAmplitude Horizontal
: The range of horizontal movementAmplitude Vertical
: The range of vertical movementAmplitude Depth
: The range of depth movement
Methods
For runtime implementation of a shake on your game you can use the methods:
Shake(float duration, Vector2 strength, int vibrato, float randomness, float initialAngle, Vector3 rotation, float smoothness)
Or, if you simply want to use one of your presets:
Shake(string presetName)
Shake(int presetIndex)
And if you want to stop all current shakes:
StopShaking()
This extension provides a static instance so it’s easier to call its methods. As an example:
ProCamera2DShake.Instance.Shake();