show times at the end of the game

Hello everyone!... Im working on this race game, What im having trouble with is basically showing the time on the top of the screen, and then when the game finnishes(when player gets to the goal) display a sign saying your time is:__(and show how long it took t to complete it)... Any ideas?? Thanks a lot!

Hey Colombian,

you have to add a new Cube and disable the mesh renderer. Then place it on your Finish line. Now make a new tag like "FinishLine".

Now you do this with a script on youre car:

var time : float;
var finished : boolean = false;

function Update{
  //Add the time every Frame if race isnt finished
  if(finished == false){
    time += Time.deltaTime;

function OnTriggerEnter(hit : Collider){
  //if hit Collider is the Finish Cube
  if(hit.tag == "FinishLine"){
    //Race is finished
    finished = true;

function OnGUI(){
    //if Race finished
    GUI.Label(Rect(Screen.width / 2 - 100, 20, 200, 25), "Your Time: " + time);
    //if race isnt finished (only draw time)
    GUI.Label(Rect(Screen.width / 2 - 100, 20, 200, 25), "" + time);

Store the time at the beginning of the race, then in your update function print out the current time minus the start time to display how long they've been racing on the top of the screen. When they reach the goal, save the current time minus the start time, and that's the time the race took.

Although there may be more suitable solutions (depending on the circumstances), Unity's built-in GUI system is probably a good place to start. Using the GUI system, you can easily display text and graphics onscreen, which is what it sounds like you need here.

Displaying the total time at the end of the race is more of a program logic problem, and there are many ways it can be done (a simple state machine, loading a completely separate scene, etc.).

Those are fairly general answers, but the question itself is fairly broad. If you need further help with this, I'd recommend posting some more specific questions and specifying in more detail what exactly it is that you need help with.