Cinemachine: How to create Camera Shake on Unity Cameras
Ever wonder how to have a camera shake effect? It’s very simple!
Let’s set up a new virtual camera in our scene.
I want to add a handheld effect to the shot above.
Cinemachine Virtual Camera Component
When creating a new virtual camera, we want to access the Cinemachine Virtual Camera component in the inspector tab. At the very bottom of the component, there is a dropdown menu for the “Noise” property.
Click on the dropdown and add “Basic Multi-Channel Perlin.” Cinemachine will add Perlin Noise to the movement of the camera.
We’ll have access to a set of new properties to play with.
The noise properties will help simulate camera shake! Let's take a brief look at each property.
The noise profiles are assets that can be used for specific camera shakes.
The Gain to apply to the amplitudes defined in the noise profile. A larger value will shake the camera more rapidly. A value of 0 mutes the noise.
The Factor to apply to the frequencies defined in the noise profile. A larger value will intensify the speed of the camera shake.
When rotating the camera, the Pivot Offset will offset the camera’s pivot by the values of x, y, and z distance. This generates variation in the positioning to the rotation noise.
Cinemachine provides a simple way to add a camera shake for our needs! Now that we have an understanding of them, let's keep practicing by messing with other profiles and their properties and applying them to our games! The best way to trigger them would be to have trigger boxes on areas that would call the camera shake through code.