Game Development Reference
In-Depth Information
Figure 5-8. Renaming the First Person Controllers
In Listing 4-11 in the previous chapter, we examined collision detection with Cash Power-Ups. In
that sample, the OnTriggerEnter event was used to detect the intersection of a rigid body with
the power-up. While coding that event, we were aware that, in the future, there would be several
rigid bodies moving around the level during gameplay, namely the Player and Enemies. Since we
wanted to avoid enemies collecting power-ups, we coded OnTriggerEnter to verify the colliding
objects' tag, ensuring it was marked as player . To ensure our player object, and its First Person
Controllers, work in conjunction with that functionality, we'll need to tag the relevant objects as
player . Since the desktop and mobile First Person Controllers are implemented slightly differently,
we'll need to tag different GameObjects in each one. For the desktop First Person Controller, the
root object DesktopController should be marked as player (since it features the physics-based
CharacterController component). For the MobileController , it should be the object named player ,
which is a child object embedded deep within the Mobile prefab—again, this object features the
CharacterController component (see Figure 5-9 ).
Figure 5-9. Tagging objects in First Person Controllers to work with power-up collision
 
Search WWH ::




Custom Search