Game Development Reference
In-Depth Information
if (Physics.Raycast (transform.position, transform
.forward, hit, 100)){
Debug.DrawLine (transform.position, hit
.point, Color.yellow);
if (hit.collider.gameObject.tag == “Player”){
seenSomething=true;
PulseLight();
CountDown();
}
}
}
function PulseLight(){
audio.enabled = true;
while (seenSomething){
var textureColor : Color;
textureColor.r = Mathf.Sin (Time.time *
10.0);
renderer.material.color = textureColor;
yield;
}
}
function CountDown(){
yield WaitForSeconds (10);
Application.LoadLevel(“Scene-ClosingFail”);
}
Why?
Remember that this script is attached to the camera itself, and when
the camera is shot it's destroyed and the broken version is instantiated
in its place. Because the camera itself gets destroyed, the scripts
attached to it destroy as well. So, if the player does indeed find the
alerting camera and shoots it, this function (CountDown) never gets to
its 10 seconds and therefore never launches Scene-ClosingFail.
Step 38: Save and return to Unity. Fix syntax problems.
Scene-ClosingFail
Step 39: Duplicate Scene-Closing (select it in the Project panel and
choose Edit>Duplicate). Rename the duplicate Scene-ClosingFail .
Open this new Scene-ClosingFail.
Step 40: Rename the Congratulations GUITexture to Fail and replace its
texture with the DataPanel-Failed texture from the Project panel's 2D Assets.
Step 41: Adjust lighting or other visual elements to give this version a
darker feeling of failure. The image shown in Figure 17.12 simply turns the
color balance of all the lights toward red.
Step 42: Save Scene-ClosingFail.
Step 43: Add Scene-ClosingFail to the Build Settings' (File>Build Settings)
 
Search WWH ::




Custom Search