On previewing the game thus far, the spaceship probably looks too large. We can fix this easily by changing the scale of the
Player object. I've used a value of
0.5 for the X, Y, and Z axes. See Figure 3.24. However, even with a more sensible scale, a problem remains. Specifically, it's possible to move the player outside the boundaries of the screen without limit. This means that the player can fly off into the distance, out of view, and never be seen again. Instead, the camera should remain still and the player movement should be limited to the camera view or bounds so that it never exits the view.
There are different ways to achieve bounds locking, most of which involve scripting. One way is to simply clamp the positional values of the
Player object between a specified range, a minimum and maximum. Consider Code Sample 3.2 for a new C# class called
BoundsLock. This script file should be attached to the player.