Creating the zombie prefab

We can now begin the process of incorporating the Zombies into our scene. The Zombie asset created by Pxltiger comes with the models, materials, textures, and animated prefabs. This saves us hours of work constructing the elements, but we still need to prepare the assets for our scene and create a means of controlling the various states needed to have the creature interact with our player:

  1. Create the Zombie prefab by dragging the Zombie/Model/z@walk asset from the Project window to the Hierarchy window. When the item appears in the Hierarchy panel, the text will be blue.

We are utilizing the walk animation since our biters will always be moving. For future projects, you might want to use an idle or default animation as the project requires.

  1. Rename the z@walk item to ZombiePrefab in the Inspector panel.
  2. Add a Capsule Collider component to the prefab item with the following settings:
    • Center=0,0.85,0.3
    • Radius=0.17
    • Height=1.7
  1. Add a Rigidbody component.

Adding the Rigidbody component to an object will subject the object to Unity's physics engine. With this component, vector forces and gravity can be used to simulate behaviors. The Rigidbody component will let objects fall, roll, and bounce in a manner that we would expect in the real world.

  1. Change Collision Detection to Continous Dynamic.
  2. Set constraints Freeze Position Y = On.
  3. Set constraints Rotation X = On and Z = On.
  4. Drag the ZombiePrefab from the Hierarchy panel to the Prefabs folder. This will create a new prefab.
  5. With the new prefab created, delete the ZombiePrefab item from the Hierarchy panel.

Before the zombies can be spawned, we need to create a state machine to control their animations (walking, attacking, and dying). This state machine is created with the Animator tool. If you have not used the Animator, Unity has provided a short video introduction to the tool: https://unity3d.com/learn/tutorials/topics/animation/animator-controller. The following steps illustrate how to create a state machine for our asset.

..................Content has been hidden....................

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