Creating camera shakes with the Animation View and the Animator Controller
In this recipe, we will use a simple, but very effective method for creating camera shakes. Those effects are often used to emphasize impacts or explosions in our games.
Getting ready
You don't need anything special for this recipe. We will create everything from scratch in Unity. You can also download the provided example Unity project and go to the Chapter 07 Special effects\Recipe 02 Creating camera shakes with the animation window and the animator controller directory. When you open the Example.unity scene and play the game, you can press the space bar to see a simple camera shake effect.
How to do it...
To create a camera shake effect, follow these steps:
- Create an empty game object in the
Scene Viewand name itCameraRig. - Parent the
Main Camerato theCameraRig. - Select the
Main Cameraand add anAnimatorcomponent to it. - Open the
Animation View. - Create a new
Animation Clipand call itCamNormal. The camera should have...