So I have the problem that I never reach the else statement in update. And also i want the clock to stop at 0.0. The startTime is in seconds. If you make it 90.0f you will have 1.30minute. The problem is i need to stop this clock when reaches the 0:0.0. Thank you in advance
public class TImer : MonoBehaviour
{
public Text TimerText;
private float startTime = 3.0f;
private bool start = false;
private float _time;
private float _minutes, _seconds;
// Use this for initialization
void Start ()
{
start = false;
startTime = 3.0f;
}
// Update is called once per frame
void Update ()
{
// if (start)
// return;
if (startTime > 0.0f)
{
_time = startTime - Time.time; // ammount of time since the time has started
_minutes = (int)_time / 60;
_seconds = _time % 60;
TimerText.text = _minutes + ":" + _seconds.ToString("f1");
}
else
Debug.Log("we are here");
}
private void CheckGameOver()
{
Debug.Log("gameover");
}
public void StartTime()
{
TimerText.color = Color.black;
start = true;
}