Bounds locking

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.

Bounds locking

Figure 3.24: Rescaling the player ...

Get Unity 5.x By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.