I’m making a simple FPS for an assignment I have a start screen, instructions, my level and a game over screen, the problem is that when I start my game on the start up screen the timer has already begun on my main level. also if I start from my level and skip the start screen it carries on after it has reached zero, ive made it take me to the game over screen when the timer reaches less than zero but this does not stop the timer from continuing to count down. Please help
Here is my script so far
#pragma strict
var startTime:float;
var timeRemaining:float;
function Start () {
startTime = 5.0;
}
function Update () {
Countdown();
}
function Countdown(){
timeRemaining = startTime - Time.time;
ShowTime();
if(timeRemaining < 0)
{
timeRemaining = 0;
TimeIsUp();
Debug.Log("Time remaining = "+ timeRemaining);
}
}
function ShowTime(){
var minutes: int;
var seconds: int;
var timeString : String;
minutes = timeRemaining/60;
seconds = timeRemaining%60;
timeString = minutes.ToString() + ":" + seconds.ToString("D2");
guiText.text = timeString;
}
function TimeIsUp(){
Application.LoadLevel(3);
Debug.Log ("Time is up");
}