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
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;
}
If you simply need the time since your level started you can call : Time.timeSinceLevelLoad