- Home /
Timer to measure game length
How do you create a timer that measures how long you are alive for? I need this for my survival game as the time is measured on the highscores page
Answer by syclamoth · Oct 30, 2011 at 11:53 PM
float time = 0;
void Update()
{
time += Time.deltaTime;
}
Or, alternatively (a method I personally don't like because it can't easily be paused, amongst other things)
float startTime;
void StartRunning()
{
startTime = Time.time;
}
float GetTime()
{
return Time.time - startTime;
}
Would i put this on to a GUI Texture or an empty GameObject attatched to the player
Put it wherever you need it- there's no limitation there!
Answer by stopsecret · Oct 31, 2011 at 12:05 AM
If you simply need the time since your level started you can call : Time.timeSinceLevelLoad
Your answer
Follow this Question
Related Questions
Time does not start counting down when need to 1 Answer
Stop and Resume Timer 0 Answers
Unity3D Timer. 1 Answer
did not QUIT when the Time is over ...? 1 Answer
Start timer with trigger 1 Answer