Game Development Reference
In-Depth Information
Step 13: Turn off the baked version of Hallway, and activate the unlit
version. In the scene file that was imported (if you're using that one),
there will actually be two versions of the hallway. One is within the group
Hallway_BakedGroup and the second is called Hallway_Unbaked. Select the
Hallway_BakedGroup and in the Inspector, turn the group off (click off the
check mark up by the object's name). Click the Deactivate Children button
in the resulting Deactivating Game Object dialog box ( Figure 14.9 ). Activate
the Hallway_Unbaked version (it should show up completely black).
Figure 14.9 Deactivating an entire
hierarchy.
Why?
Our method of turning the lights on and off here is going to be a
little clumsy, but it is very easy to see how things are happening in
the script. The way we are going to manage this light switching is by
deactivating and reactivating big collections of stuff. Specifically in
this scene there is an unbaked version of the scene that will show up
completely dark (except for a flashlight we'll create in a minute). There
is also the baked version of the scene that we have now deactivated.
When the switch is thrown, we'll reactivate the baked version and
deactivate the blacked-out version. It's a bit like weeding the garden
with a backhoe, but it'll do the trick.
Tips and Tricks
If you built your own version of this hallway, by this point, hopefully it
has been lit and baked. To replicate the preceding situation, simply bring
up another instance of the Hallway from the project into the Hierarchy
(this will be unbaked). Relabel it as Hallway_Unbaked, and relabel the
baked version as Hallway_BakedGroup. My version of the file Hallway_
BakedGroup also includes the lights, cameras, and keybox. These will just
be hidden when working through the base with the flashlight to keep the
player on task.
Step 14: Create a flashlight for the First Person Controller's camera. In
the Hierarchy, select First Person Controller. In the Inspector make sure
its Rotation XYZ values are all set to 0. Back in Hierarchy, select the Main
Camera object that is a child of the First Person Controller. Move the
mouse into the scene view and press F to focus on the camera. Choose
GameObject>Create Other>Spotlight. Make the Spotlight a child of Main
Camera and rename it Flashlight . Finally, make the Flashlight a child of
Main Camera.
Search WWH ::




Custom Search