Game Development Reference
In-Depth Information
Life and Death: Getting Started
Historically and philosophically, there's much of interest to be said about the way video games
implement life and death. Here, CMOD uses the “traditional” approach where Player life or health
is expressed quantitatively as an integer between 0-100; 0 is death and 100 is full health. Similarly,
in keeping with retro side-scrollers where you can attack a phone booth and get a health-restoring
turkey out of it, CMOD allows you to pick up floating, restorative hamburger power-ups to restore
health. These tasty burgers have the power-up to heal bullet wounds and punch attacks. Death,
however, comes upon the Player when health reaches 0 or below; and this typically happens
because of enemy attacks. Here again, CMOD takes the traditional approach to death: when
death arrives, the scene is restarted and the Player respawns back to the level origin, allowing
a resurrection ad infinitum . So let's start implementing these concepts now, starting with a
consideration of death.
When the Player dies, I'd like to play a small death-sequence before restarting the level in the form
of a camera animation. Specifically, the camera should roll over and fall to the ground. This simple
transformation-style animation can be recorded using the Unity Animation Editor, through
Window Animation . This editor works through key framing (see Figure 5-15 ). There I've defined
two key frames for rotation and position, defining the motion for the camera as it falls to the ground.
I'm going to apply the animation to a newly created empty game object, AnimatedCamera , which has
been parented to the First Person Controller camera (as we'll see shortly), to keep the translation and
rotation separate from the camera transformations themselves. When the animation is saved from
the editor, it's added automatically as an animation clip asset in the Project panel. I've named the
asset CameraDeath .
Figure 5-15. Creating a basic camera fall animation using the Legacy Animation Editor
 
Search WWH ::




Custom Search