Game Development Reference
In-Depth Information
Step 13: Save and return to Unity. Fix any syntax problems.
Step 14: Populate the brokenCamera variable. Select the Main Camera, and
look to the AC_Tool Functionality Script (Script) component. Drag Hallway_
CCTV_Broken from the Project panel's Scenography Assets folder to the
input field for Broken Camera. Be sure to press the Prefab Apply button.
Step 15: Play and test. Since the pistol is always visible, you should be able
to start shooting cameras. They'll explode as the broken version pops into
existence ( Figure 15.21 ).
Figure 15.21 The shooting camera
mechanism working.
Warnings and Pitfalls
When the technical editor
was going through the
chapters, he found and
pointed out some of the
trickier aspects of what
happens sometimes in
Unity's scripts. Be very
careful of capitalization
issues. His note read
like this: “Dang, it's not
working. And I'm not
getting any errors, so
some of the conditions
must not be being met . . . .
Conclusion
We still haven't built in the mechanism for the cameras to end the game.
However, using raycasting, prefabs, and instantiation, we have created
a working pistol. Let's look at how to continue to use raycasting and
instantiation to place other items, like the EMP Mine.
“Going back and looking
at the Script, it seemed
to me that 'Camera' is
wrong. It should read
Hallway_CCTV_Prefab,
but then I realized the
script is already doing
that through .tag text.
Tutorial 15.4: Sound Revisited
The first-person controller is coming together nicely, and is becoming the
central depository for many of the functionality scripts. However, the version
of the first-person controller that we've been constructing in the Hallway
scene is different than the one out in the EntryWay. Of particular worry is the
fact that the controller outside has our footstep script and sound and the
controller out there is lacking all the raycasting capability created here.
“Come to find out I
didn't capitalize the O in
gameObject. Tricky stuff.”
Unity needs to see things
just the right way for
things to go right. Pay
special attention to things
like capitalization to make
sure stuff like that doesn't
sneak past you.
Eventually, since we've created a prefab of the controller in here, we will be
using this version out in the EntryWay. So we'll quickly rebuild the footstep
functionality of the EntryWay controller and add a bit more functionality,
including gunshot sounds to round him out.
Step 1: Select FPC_AegisChung in the Hierarchy. Press F to focus on the
object.
Search WWH ::




Custom Search