I want my timer to activate after my countdown script has hit 1. Right now the timer activates at the same time as my 3 2 1 go script since they are two seperate Java Scripts, how do I combine them so that it goes 3 2 1 and then the timer kicks in?
FYI this is a racing game.
My CountDown script to start game 3 2 1 go!
var guiCountDown : GUIText;
var countMax : int;
private var countDown : int;
function Start () {
guiCountDown.enabled=true;
GameStart();
}
function Update () {
}
function GameStart() {
var car = gameObject.Find(“F1Car”);
var drivingScript = car.GetComponent(“CarControlScript”);
drivingScript.enabled=false;
for (countDown = countMax; countDown>0;countDown--){
guiCountDown.text = countDown.ToString();
yield WaitForSeconds(1);
}
guiCountDown.enabled=false;
drivingScript.enabled=true;
}
My Timer script
var timer : float = 60;
function Update ()
{
timer -= Time.deltaTime;
if(timer ← 0)
{
timer = 0;
Application.LoadLevel(“TooSlowScene”);
//Does something after reaching 0
}
}
function OnGUI()
{
GUI.Box(new Rect(50, 50, 50, 20),“” + timer.ToString(“0”));
}