Camera Shake

Kinga Osińska
May 11, 2021


Today, we will learn how to make a camera shake when our player takes damage.

There are several ways to do it. I will show you how to do it using animation.

Go to Main Camera in the Hierarchy and click on Window -> Animation ->Animation. Create a new animation called “camera_shake_anim”. Animate the camera.

Go to Window -> Animation -> Animator. Create an empty state and set it as a default state. Add a Trigger called “Shake”. Create a transition between your default state and the animation of your camera and set the condition of the transition to the trigger.

Create a second transition, so that we automatically go back to the default state.

Open the Player script. Add new variable of type Animator called “_CameraAnim”.

In the Damage() method set the Trigger to “Shake”: