Hello, I have a little problem with my countdown script.
My game has a countdown that if it reach 0, this will freeze the game and you have to Press R to reload the scene, it works but after it reload the scene, the scene is still frozen, Can anyone help me please?
I know that Time.timeScale = 0; is causing the problem, It may be a little thing but Im noob scripting. Help me please.
var timer: float = 300; // set duration time in seconds in the Inspector
var isFinishedLevel : boolean = false; // while this is false, timer counts down
function Update()
{
if (!isFinishedLevel) // has the level been completed
{
timer -= Time.deltaTime; // I need timer which from a particular time goes to zero
}
if (timer > 0)
{
guiText.text = timer.ToString("F0");
}
else
{
guiText.text = "Press R to restart"; // when it goes to the end-0,game ends (shows text: time over...)
Time.timeScale = 0;
if (Input.GetKeyDown("x")) // And then i can restart game: pressing restart.
{
Application.LoadLevel ("as"); // reload the same level
}
}
}