this script is confusing me i asked my teacher and he told me to “put the timer -=Timer.deltaTime; inside if (timer >0) statement and inside if timer < 0f set text.text to “0”,so it displays zero if timer is less than 0” anyone has an idea what that means?
using UnityEngine; using UnityEngine.UI; using System.Collections;
public class Timer : MonoBehaviour{
float timer = 30.0f;
public Text text;
public GameObject GameOverText;
public bool enable;
void Update()
{
timer -= Time.deltaTime;
text.text = "" + Mathf.Round(timer);
if (timer < 0f )
{
GameOverText.gameObject.SetActive(true);
}
}
}