Game Development Reference
In-Depth Information
that it contains a Sparks particle system, and some curious scripts that are
attached to Hallway_CCTV_Base….Detonator Scripts.
Step 11: Declare a variable to hold the broken version of the camera.
Add the following declaration to the beginning of the AC_
ToolFunctionalityScript script:
var brokenCamera : GameObject;
Step 12: Create the instantiation mechanism to pull off the ol' camera
switcheroo. This needs to happen only if the raycasting mechanism hits
something, and if pistolActive is true, and if the player presses the mouse
button when this is happening, and if the object the ray hits is indeed
a camera. Since some of the lines are getting long and for clarity's sake,
the entire function Update is shown in Figure 15.20 with the new script
highlighted.
Figure 15.20 Added mechanism that checks to see if the object is tagged “Camera,” and if it is, replace it with the broken version of the camera.
Why?
Notice that this if statement is within several if statements and only fires if
the mouse button is pressed while the pistolActive Boolean is true. Then,
the instantiate statement is saying, “instantiate brokenCamera at the
position of the camera that was hit, and make sure it's rotated at the same
angle as the camera that was hit.” Finally, the Destroy command destroys
the object that was hit (the old camera).
Search WWH ::




Custom Search