Configuring the game camera

The preceding code allows you to control the Player object, but there are some problems. One of them is that the player doesn't seem to face the position of the mouse cursor, even though our code is designed to achieve this behavior. The reason is that the camera, by default, is not configured as it needs to be for a top-down 2D game. We'll fix this in this section. To get started, the scene camera should have a top-down view of the scene.

To achieve this, switch the Scene viewport to a top-down 2D view by clicking on the ViewCube, the up arrow in the top right corner of the Scene viewport. This switches your viewport to a top view. See Figure 3.17:

Figure 3.17: The viewcube can change the viewport perspective

You can ...

Get Unity 2018 By Example - Second Edition 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.