using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Timer : MonoBehaviour {
public float displayTime = 3;
public Text timeText;
// Use this for initialization
void Start () {
timeText=GetComponent<Text>();
}
// Update is called once per frame
void Update () {
if(displayTime<=0)
{
displayTime = 3;
}
displayTime -= Time.deltaTime;
timeText.text = displayTime.ToString("f0");
}
}
I’ve typed this code. I feel it is because of the encountered “if” block. But i want to revert the timer back to 3 once it reaches 0. How do i do that without the loss in countdown accuracy?