i have two pieces of script ones the timer, the other is the GUI once it gets to 0 i want ti disply game over for the time being. Im new to unity any suggestions as to what this error is all about that would be great and how i can fix would be even better.
Below is the timer code
// the textfield to update the time to
private var textfield:GUIText;
// time variables
public var allowedTime:int = 5;
private var currentTime = allowedTime;
function Awake()
{
// retrieve the GUIText Component and set the text
textfield = GetComponent(GUIText);
UpdateTimerText();
// start the timer ticking
TimerTick();
}
function UpdateTimerText()
{
// update the textfield
textfield.text = currentTime.ToString();
}
function TimerTick()
{
// while there are seconds left
while(currentTime > 0)
{
// wait for 1 second
yield WaitForSeconds(1);
// reduce the time
currentTime--;
UpdateTimerText();
}
//gameover
}
This snippet is the GUI
gameOver : boolean = false;
function Update()
{
if (CurrentTime = 0)
gameOver = true;
}
function OnGUI()
{
if (gameOver)
GUI.Label(Rect(0,0, 100, 20), “Game Over”);
}
Help would be very much appreciated.
Thanks