hey guys,
i have got this script here, and what it does is: when i apply it to the player, and then drag a game object into the “objective” variable, it is meant to display the GUI Label for 5 seconds on the screen.
It all works fine if i don’t use the whole “timing” method, but just make it display for ever.
But as soon as i add the parts to make it so that it will only display for 5 seconds it won’t show up on screen.
private var ShowLabel : boolean = true;
var objective : Transform;
var style : GUIStyle;
function Start()
{
yield WaitForSeconds(5);
ShowLabel = false;
}
function OnGUI()
{
if (Vector3.Distance(transform.position, objective.position) < 3000){
if(ShowLabel)
{
GUI.Label(Rect(650, 650, 300, 50), "MY GUI TEXT", style);
}
}
}
There are no errors in the console, and as i said, it will work fine with the vector3.distance funtion with a normal GUI.Label, but with the timing it doesn’t appear.
can someone please tell me what i have done wrong…
any answers are greatly appreciated…
thanks
-Grady