hi im using this script to serve as a timer and a game over script but when the timer hits zero, it still displays counting like 00: -1 00: -2 and so forth.
i have no idea how to hide the timer when it hits zero, any ideas? im a total newbie so please explain it a bit more thanks!
private var startTime;
private var restSeconds : int;
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
var text : String;
//gui
var mySkin2 : GUISkin;
var gameover: Texture2D;
var permago: Texture2D;
var countDownSeconds : int;
function Awake() {
startTime = Time.time;
guiTexture.enabled=false;
}
function OnGUI () {
GUI.skin = mySkin2;
//make sure that your time is based on when this script was first called
//instead of when your game started
var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
//display messages or whatever here -->do stuff based on your timer
if (restSeconds == 60) {
print ("One Minute Left");
}
if (restSeconds == 0) {
print (stagegameover.gochecker);
gochecker = true;
stagegameover.gostate = true;
if(stagegameover.gochecker>2){
guiTexture.texture=permago;
guiTexture.enabled=true;
}
else{
guiTexture.texture=gameover;
guiTexture.enabled=true;
}
//stagegameover.tryagain=false;
//do stuff here
}
//display the timer
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
GUI.Label (Rect (400, 25, 300, 400), text);
}