- Level Design 101
- Getting around Our Scene
- Manipulating Objects in Unity
- Our First Level
- Continuing On
- Summary
- Exercises
Getting around Our Scene
Up to this point we haven’t used the Scene View much for our Project. We did a lot of the legwork: bringing in our assets, building our sprite sheets, and creating our GameObjects. But now we really need to get in and get dirty (so to speak). We should first get comfortable with moving around in the environment. Although we are not dealing much with the concept of 3D depth, we should know how to view our GameObjects and Scene in both 2D and 3D space. Let’s get familiar with Scene navigation and object manipulation by creating a test Scene where we can move around:
- Start by creating a new Scene.
- In the Scene View control bar, toggle the workspace from 2D to 3D.
- Create a Cube GameObject by going to the GameObject menu > Create Other and selecting Cube.
- Reset the Cube’s Transform values all to 0. With the Cube selected, in the Inspector, right-click the gear icon to the right of the Transform Component and select Reset.
Scene Gizmo
To begin, it helps to know how 3D space works. Take a look at the little colored Gizmo in the top right corner of the Scene View. This is the Scene Gizmo (Figure 4.2).
Figure 4.2 The Scene Gizmo
In 3D space, there are three different axes that determine the direction you are facing or the direction in which an object is moving. The red (X-axis), green (Y-axis), and blue (Z-axis) axes on the Scene Gizmo help clarify this. An easier way to understand this concept is that the X-axis runs left to right, the Y-axis runs up and down, and the Z-axis moves front (near) to back (far). We will get a better understanding of this in just a bit when we move our cube around in 3D space.
Perspective versus Isometric
Our Main Camera works in perspective view. This means that we can see our cube object in our Scene with multiple converging angles (perspective viewpoints). Most likely if you haven’t moved your view around, you will see two sides of the cube running off into a two-point perspective view.
Isometric view refers to the camera having equal projection of all three axes. This makes your Scene appear as though it has very little depth. We will see more of this isometric relation when we start laying down our objects using a 2D orthographic mode for the camera. Figure 4.3 shows an example of perspective and isometric cameras. Notice how the objects on the left appear to have depth and foreshortening, while the objects on the right appear flat and almost as though they exist on the same plane.
Figure 4.3 A perspective camera (left) and an isometric camera (right)
Camera Controls
There are a few different methods for getting around in 3D space inside Unity. If you come from any type of 3D background or have played a third-person-style game, you will easily grasp this concept.
Arrow Keys
One method of moving around in the Scene View is using the arrow keys on your keyboard. If you are at all familiar with moving around in a third-person game, the arrow keys work the same way: up and down to move you forward and back, and left or right to pan the camera sideways.
WASD Movement
This is the movement that exactly replicates most PC-style games. While the arrow keys method is very similar, this one uses the W, A, S, and D keys for movement while using the mouse to direct the camera for that movement. To enable the WASD keys, you must first hold down the right mouse button.
Mouse Shortcut
The mouse movement is the most efficient method as you can still easily move about in the Scene but also keep the Transform tools for manipulating the GameObjects. While this method is most effective with a three-button mouse, you can use a two-button (no scroll wheel) or even a one-button mouse (most common for Macs or trackpad users). Table 4.1 gives shortcuts to help clarify this.
Table 4.1 Mouse Movement for One, Two, or Three Button Mouse
Action |
One Button |
Two Button |
Three Button |
Move |
Alt1Ctrl(Cmd) and click-drag |
Alt1Ctrl(Cmd) and click-drag |
Alt and middle click-drag |
Orbit |
Alt and click-drag |
Alt and click-drag |
Alt and click-drag |
Zoom |
Alt and right click-drag |
Alt and right click-drag or use the Scroll wheel |
Hand Tool
Another method is to use the Hand tool (Figure 4.4). You can access it by tapping the Q key on the keyboard. In this mode, you are able to control the camera movements simply by using the mouse.
Figure 4.4 Transform tools with the Hand tool selected
By holding down the Alt or Ctrl keys, you can orbit or zoom the camera respectively. Also, holding down Shift while using these will increase how fast the camera orbits and zooms.