Game Development Reference
In-Depth Information
Figure 6-5. Weapons should appear at a consistent size and at the bottom-middle of the screen
No matter where the First Person Controller moves or looks in the scene during gameplay,
the gun sprite should always follow, being aligned to the bottom-middle of the screen, exactly
where we'd expect to find the Player's hand holding a weapon. There are many ways to achieve
this functionality: you could, for example, use GameObject parenting to create transformation
dependencies. But in this chapter, we'll use a layered camera technique, effectively rendering
all scene geometry from the default first-person camera, and the weapon from a second and
orthographic camera layered on top of the original rendering. To get started, I'll adjust the scene
hierarchy somewhat for clearer organization.
Specifically, I'll create a new GameObject (called Weapons ), adding this as a child of the Player
object, and then add a new Camera object ( WeaponCamera ) as a child of the Weapons object, and
finally, I'll add the Weapon_Punch object as a child of WeaponCamera . In addition, I'll also remove
all components from the Camera object (including the AudioListener), leaving only the Camera
component (see Figure 6-6 for clarification on this process).
Figure 6-6. Housekeeping game objects and creating a second camera
 
Search WWH ::




Custom Search