Animating the zombie assets

Take the following steps to animate the zombie assets:

  1. Choose Asset | Create | Animator Controller from the main menu.
  2. Rename the new asset ZombieAnimator and place it in the Project/Zombie folder.
  1. Double-click the ZombieAnimator to load the state engine into the Animator window for editing:
Figure 5.8: Based on the size of your display, you may have to pan around (MMB+drag) the window to locate the three states

Within the window we will define three parameters, five states, and seven transitions, which will be used to control the behaviors and actions of our zombie horde. The state machine is useful because it creates a smooth seamless transition between the asset's animations.

  1. With the Animator window open, select the Parameter tab and create the following items by choosing Bool or Int from the + menu:
    1. Death (Boolean): used to determine if the Zombie can move or attack
    2. Attack (Boolean): used to determine if the Zombie is attacking
    3. DeathAnimationIndex (Integer): used to determine which death animation will be played. 
  2. Create five new states by right-clicking on an empty spot in the grey grid area and choosing Create State | Empty. Rename the items Walk, Attack, FallLeft, FallRight, and FallBack in the Inspector panel.

FallLeft, FallRight, and FallBack are the zombie's three death animations. They indicate the direction of the death, such as fall straight back, fall back to the left and fall back to the right.

  1. Confirm that the Walk state is the default by right-clicking on Walk and choosing Set as Layer Default State.
  2. Right-click the Walk state and select Make Transition. Then click on Attack to anchor the transition. When called from a script, this transition will create a smooth blending between the walk cycle and the attack animations. If you make a mistake, select the state in the Animator window and the Transition in the Inspector panel. Then, hit the - button in the lower corner to remove the transition.
  3. Continue by adding transitions, as indicated in the following image. When completed, Walk will be the starting point for four transitions, Attack will start three, and the remaining items (FallLeft, FallRight, and FallBack) start zero transitions. Figure 5.9 illustrates the Animator layout when you've completed this step:
Figure 5.9: Layout of states for the ZombieAnimator
  1. Select the Walk item and review the Inspector window. Note that the Motion field has a value of None (Motion). Change this by clicking the small target selector circle and choosing walk from the Select Motion dialog. The items listed here were created by the zombie asset creator and will save us the time of animating them ourselves. Complete this step by selecting each of the other states and setting their motion to the appropriate animation.
  2. Save the ShootingRange scene.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.203.43