Making Camera Shake using Impulse Listener Extensions

Tyler Smallwood
3 min readNov 29, 2022

--

Objective: Shake the Camera using Impulse Listener.

Impluse Listener is another extension like the story board that we covered yesterday. We will follow the same procress just instead of storyboard we will select CinemachineImpulseListener.

Now we have the component. There is a message saying that the Listener will respond to signals broadcast by any CinemachineImpulseSource.

We will create an empty game object and add a CinemachineImpulseSource component to it.

Now that we have a object with the source, we will need create a signal. To do this, in your project window, right click → Create → Cinemachine →NoiseSettings.

Drag the new NoiseSettings into the Source Raw Signal section.

With the noise selected, in the project window, we can play with some settings. Position Noise will move the camera between the X, Y, and Z axis while the Rotation Noise will rotate the camera.

Expand the Position X, Y, and Z. Then select the plus to add the Components.

I set the X Frequency to 1, Y to 10, and Z to 1 while all have amplitude set to 1.

Next thing to set up will be the source information. On the ImpulseSource object, we will set amplitude Gain to .5 and keep frequency gain to 1. Attack and decay will be set to .1. Sustain Time will be .2. This will shake the camera as needed as if we shot a gun.

Now to call the impulse. We will create a C# script, I named mine Camera Shake. I attached it to the ImpulseSource.

We will need to use Cinemachine libaray, so use a using statement. Next create a variable of type CinemachineImpulseSource.

In start grab a reference by using GetComponent.

We will create a method called Shake. In there we will call the _source.GenerateImpulse().

Now in update we will check for input to call the Shake method.

Now when we play our camera shakes. If you play with the settings you will notice a difference in the shakes. Playing with the settings will help you get a better look for the type of shake you need.

Thank you for reading and have a wonderful day!

--

--

Tyler Smallwood
Tyler Smallwood

Written by Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

No responses yet