Time Counter

i have a simple time counter that count just the seconds

var Counter : int = 0;

function Update () {

Counter++;

guiText.text = "Time: "+Counter;

}

but i want a time that count the seconds and minutes im not couding if you helpwith the script will be helpful

@thepra13 This code should work fine.

private float timeRemaining; 
 void Start()
 {
     timeRemaining = 61;
 }
 void Update()
 {
     timeRemaining -= Time.deltaTime;
     if (timeRemaining > 0)
     {
         float minutes = Mathf.Floor(timeRemaining / 60);
         float seconds = Mathf.Floor(timeRemaining % 60);
         timerText.text = " " + minutes.ToString("00") + ":" + seconds.ToString("00");
     }
 }

var Counter = 0.000;

function Update () {

Counter += 1 * Time.deltaTime;

var Counter2 : int;

Counter2 = Counter;

guiText.text = "Time: " + Counter2;

}

alright so here is a script I wrote to fix this issue

var min : int;
var sec : int;
var fraction : int;
var timecount : float;
var starttime : float;
var timeCounter : GUIText;

function Start ()
{
starttime = Time.time;
}

function Update () {
timecount = Time.time - starttime;
min = (timecount/60f);
sec = (timecount % 60f);
fraction = ((timecount * 10) %10);
timeCounter.text = String.Format("{00:00}:{1:00}:{2:00}",min,sec,fraction);
}

var counter : int;
var texta : GUIText;
function Update () {
counter1();
}
function counter1 () {
texta.text = "Time: " + counter;
yield WaitForSeconds(1);
counter++;
}

That answer is on here a lot of times. Just type “timer” in the search. What you are doing in that script is adding 1 on every frame not on every second. so if your computer is computing your script at 60 frames per second, you would have a count of 60 by the time you reach 1 second.

What you are looking for is Time.time, that counts seconds but it is a float not an int, if you search “Timer” here, you will also find how you can display that timer as an int.