Game Development Reference
In-Depth Information
Note
More information on the Unity Legacy Animation Editor can be found at
https://docs.unity3d.
Remember, the animation and completed project for this chapter are included in the chapter companion files
at
Chapter05/Completed
.
The animation asset itself just defines a generic animation sequence in terms of key frames and
transformations; these could apply to any GameObject. For the death sequence, I'll first create
empty objects (named
AnimatedCamera
), added to the First Person Controller, as parents of the
Camera
objects. Make sure their transformations are set to 0 for all positions and rotations (see
Figure
5-16
). Then add
Animator
components to the objects, which will handle the animation
functionality through the Mecanim system. Animator components can be added from the main menu
by choosing
Component
➤
Miscellaneous
➤
Animator
.
Figure 5-16.
Adding animations to camera parent objects. Doing this may break connections with existing Prefabs—but that's
fine in this case
The added Animator component begins empty, without any associations to animation. We'll fix
that now. Specifically, we'll create an
AnimationController
asset that will drive the camera death
animation when health reaches less than 0. To do this, create a new AnimationController asset,
right-clicking in the Project panel and choosing
Create
➤
Animation Controller
from the context
menu. View the Animation Controller (see Figure
5-17
) using the
Animator
window (
not
the
Animation
window).