Creating the Player GameObject

The player is made up of a single GameObject. This object will contain the first-person camera, a collider, and a light source. Our GameObject will not need a light source until we address the environment in the Setting the mood section, but we can create the other components by following the steps listed here:

  1. Create an empty GameObject in the Hierarchy panel, rename it Player, and move it to 0,1,0.5 using the Inspector. This object will house the VR camera and scripts needed for player control.
  2. Change the Player tag from Untagged to Player using the Inspector panel.
  3. With the object still selected, add a Capsule Collider by clicking the Add Component button in the Inspector window. Enter capsule in the search field or select Physics from the list of categories. Next, select Capsule Collider from the list to assign it to the Player GameObject.

Unity Colliders are invisible objects used to facilitate physical collisions between GameObjects. They can be exact shapes or rough approximations of the object's mesh renderer and can be primitive or complex in definition. In normal operations, we use an object's collider to determine if two objects have touched and then act upon those results programmatically. In this project, the player's collider will collide with the ground so that we don't pass through the floor. It will also be used to trigger the zombie's attack animation after the two (player and zombie) collide.

  1. Set the Capsule Collider's center z-value to -0.25 and increase the Height from 1 to 2.
..................Content has been hidden....................

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