Game Development Reference
In-Depth Information
Figure 5-6. Importing the desktop and mobile First Person Controllers into the active scene
Note Remember to delete any other cameras in the scene, if there are any. We won't need them since our
game is exclusively first-person.
Obviously, we're going to write some C# script to switch between these two controllers at level-
start, on a per-platform basis—the desktop controller used for desktop games, and the mobile
controller for mobile games. But first, let's apply some GameObject organization to the scene, as
opposed to simply leaving the two newly added controllers as separate objects. I want to organize
both controllers under a single GameObject umbrella that eventually, when taken as a whole, will
become a Player prefab—an object we'll reuse as often as we need for other scenes and levels. The
First Person Controller prefabs we've created will only form a part of that Player object—because the
Player can do more than just move around the scene. To get started, I'll create two new and empty
GameObjects: Player and Controls . These are created using the menu item GameObject Create
Empty . The Player GameObject represents the root object for the Player prefab. Beneath this (as a
child game object) will be the Controls object. Then I'll add both First Person Controller objects as
children of the Controls object. The hierarchy looks like Figure 5-7 .
 
Search WWH ::




Custom Search