Game Development Reference
In-Depth Information
Step 13: Delete the default information contained in that script and enter
the following:
function FindDoorHint (){
guiText.enabled = true;
guiText.text = “Find the secure entrance to the
base.”;
yield WaitForSeconds (3);
guiText.enabled = false;
}
Why?
This function is a bit different than those we've written in the past. While
most of the functions we've built included a call to action (OnMouseDown,
OnMouseEnter, etc.), this one simply provides a name, FindDoorHint—we
are creating a custom function that we're are deciding to name FindDoorHint.
In this case, our function is a block of instructions waiting to be told to
jump into action, but presently there is no such instruction; we'll build that
into the other script.
The first line of this block just turns on the GUIText component (remember
we turned it off earlier?). Then it defines what the text should actually say
(it's defining the text part of the GUIText component). The third line says,
“after you've shown the text, wait for 3 seconds,” and then the fourth line
turns the GUIText component off so the onscreen text will disappear.
Step 14: In the same script, create two more similar functions with a water
warning and a hint to use the EMP. Here's what the whole thing should
look like up to this point:
function FindDoorHint (){
guiText.enabled = true;
guiText.text = “Find the secure entrance to the
base.”;
yield WaitForSeconds (3);
guiText.enabled = false;
}
function StayOutOfWaterHint (){
guiText.enabled = true;
guiText.text = “Stay out of the water! At this
temperature, it's lethal.”;
yield WaitForSeconds (5);
guiText.enabled = false;
}
function TryEMPHint (){
guiText.enabled = true;
guiText.text = “Try using EMP to disable exterior
security system.”;
 
Search WWH ::




Custom Search