Game Development Reference
In-Depth Information
Note
Cameras are created by selecting
GameObject
➤
Create Other
➤
Camera
from the
application menu.
After adding a second camera, change its
Projection Type
from
Perspective
to
Orthographic
.
Perspective cameras are useful for rendering 3D geometry in which objects are seen in perspective;
distant objects appear smaller and objects further to the camera edges are distorted from
foreshortening. Orthographic cameras, in contrast, are useful for rendering 2D graphics drawn
directly in screen space, such as 2D weapon sprites. After changing the camera projection, translate
the camera (along with its children) outside the main scene area—at a distance where it doesn't
collide with or intersect scene geometry. It doesn't ultimately matter where it's moved; this step is
mainly for
our
benefit, to avoid confusion with other game objects and to facilitate easier selection
from the viewport (see Figure
6-7
). Notice that I've adjusted the punch sprites to be in view of the
camera, as shown in the camera preview window.
Figure 6-7.
Configuring a 2D camera for rendering weapon sprites
The camera is now almost configured for rendering the weapon punch sprites. But, if you play
the game right now, you'll still see only the First Person Controller camera being rendered, and
not the newly created weapon camera. From appearances, the user would never know a second
camera existed, and the weapon sprites are not even layered on top of the initial rendering as we
want them to be. To fix this, change the WeaponCamera
Depth
property to
1
, and the
Clear Flags