Okay, this is the only thing that is hindering the completion of my game. I have a timer script:
#pragma strict
private var startTime : float;
var textTime : String;
//First define two variables. One private and one public variable. Set the first variable to be a float.
//Use for textTime a string.
function Start() {
startTime = Time.time;
}
function OnGUI () {
var guiTime = Time.time - startTime;
//The gui-Time is the difference between the actual time and the start time.
var minutes : int = guiTime / 60; //Divide the guiTime by sixty to get the minutes.
var seconds : int = guiTime % 60;//Use the euclidean division for the seconds.
var fraction : int = (guiTime * 100) % 100;
textTime = String.Format ("{0:00}:{1:00}:{2:00}", minutes, seconds, fraction);
//text.Time is the time that will be displayed.
GetComponent(GUIText).text = textTime;
}
var bestScore = 0;
var playerTime = 0;
//When the race is completed;
bestScore = playerTime;
//Reset playerTime to zero
//Display the best score(Score to beat)
//If the next drivers playerTime is higher than the previous bestScore
if(playerTime > bestScore){
//Display the new best score.
//Reset playerTime to zero
}
The player’s job in my game is to tap each of the spawning stars to destroy them, and if they let one pass a certain point they lose the game. The Timer is there to basically see how long each player can last.
I’ve tried, but I cannot seem to save the timer score and display on the GameOver Scene. How do I go about this? Could you please explain in a step by step way.