- Home /
Display Time At Game Over Scene
I have this time 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;
}
Stars all falling and the player's job is to destroy the stars by touching them and they cannot let one pass or they will lose the game. The score system is basically the time; how long they last. But, I'm having trouble with creating a game Over trigger and displaying the player's highest time in the Game Over scene. How do I do it?
this is the best reference I have at the moment.
Austin was talking in earlier videos about making this score system based off time but he changed it in the end to make it based off points. but he does show how to open a window and add fields to it for score. so it may help you with the basics of creating the window and feeding information to it. just change his score to your time.
good luck. I hope someone can help you with more information.
Answer by DecipherOne · Jun 07, 2014 at 03:53 AM
Count the seconds, then convert them into your other values, the game over trigger would be a boolean triggered when your game over condition was met and then load a different state somehow.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150953im_/https://answers.unity.com/themes/thub/images/avi.jpg)