Cinemachine: Creating a Camera Shake Using Impulse Listener

Ryan McCoach
3 min readAug 19, 2022

--

Intro

In this article, we are going to cover how to create your own camera shake using Cinemachine’s Impulse Listener extension.

Impulse Noise Source

The first thing we will do is create a impulse noise for the camera to listen for and based on the noise will determine how the camera will shake.

We create an empty game object and add a Cinemachine Impulse Source component. It needs a signal to produce, so…

We create a noise signal by creating a New > Cinemachine > Noise Settings.

This will create a new Noise Setting in the project files and we assign it to the Raw Signal on the Impulse Source script.

Clicking on the new Noise Setting profile, we can create a signal by adjusting the frequency and amplitude on the positions and rotations on the X, Y & Z axis

These different waves will be combined into the main signal and will determine how the camera will move.

You can adjust the intensity of the amplitude and frequency using the impulse source, so you don’t have to have the levels too high in the noise settings.

The Time Envelope will determine the beginning (attack), middle (sustain time), and end (decay) of the noise. These stages duration can be set and…

can have different easing curves applied to them.

Generating Impulse Using Script

We are going to trigger this impulse through script. I am will be attach this camera shake script onto the Impulse object, but it can be assigned to any script and all you will have to do is get the script component.

In the script, we need to use the Cinemachine library and declare a Cinemachine Impulse Source class variable, which is the script class of our noise signal. In Start, we store the component in the variable.

We can now use the Generate Impulse method to trigger the noise of the camera.

Impulse Listener

The last thing to do is add an Impulse Listener to the virtual camera(s) we want to impulse noise to effect. This can only “hear” or be effected by the noise. It does not create the noise, which is what was done in the previous steps.

This can listener can be added in the Extension section of the virtual camera. Experiment with the different settings to customize your camera shake!

--

--

No responses yet