Game Development Reference
In-Depth Information
property to
Depth Only
, as shown in Figure
6-8
. The
MainCamera
on the First Person Controller
has a default Depth property of 0. Cameras with higher depth values are layered
on top
of lower-
order ones. The Clear Flags property defines how the camera background should be rendered:
Depth Only renders the background as transparent and allows the First Person Controller camera
to appear beneath the WeaponCamera (see Figure
6-8
).
Figure 6-8.
Layering the weapon camera onto of the scene camera using the Depth and Clear Flag properties
Configuring the camera this way is not all we
should
do, however. Although the layered weapon camera
now renders weapon sprites
on top
of the first-person camera, as we intended, it will still render any
scene geometry and other objects,
if they ever come into its view
. This could produce confusing results
leading to scene geometry being rendered twice or strange overlapping scenarios, depending entirely
on what enters the camera view. To
restrict
the WeaponCamera to render
only
weapon sprites, and
nothing else, we can use
layers
. Taking this extra precaution is highly recommended. Start by creating
a new layer (
weapon_layer
), and assigning all weapon sprites to it from the Object Inspector. Layers
are created from the
Tags and Layers
menu, accessed by selecting
Add New Layer
from the
Layer
drop-down menu at the top-right corner of the Object Inspector (see Figure
6-9
).