I am currently using Time.time to make a countdown timer (if you don’t beat the game in x amount of time, you lose) but the issue is that when using the timer code, you cant reset Time.time without hard reloading the game,
using UnityEngine;
using System.Collections;
public class Timer : MonoBehaviour {
public bool timesUp = false;
void OnGUI () {
GUI.Box (new Rect(0, 0, Screen.width/2, 20), Time.time + "/ 75");
}
// Update is called once per frame
void Update () {
if(Time.time >= 75)
{
timesUp = true;
}
if(timesUp == true)
{
Application.LoadLevel (7);
}
}
}
Why don’t you use deltatime instead? This way, you will have full control about how much time have elapsed since you set. After that, you can reset it by just setting it back to zero.