When the game scene opens, I would like it to be automatically paused and to start displaying a 3 second timer (3 2 1). Once the timer is less than 0, I would like the game to be unpaused so the user can start playing.
This is my code so far :). At the moment, it starts off paused but the timer doesn’t count down. Any ideas as to what I can do?
public class StartGame : MonoBehaviour {
public Text countdownText;
public float timer = 3.0f;
// Use this for initialization
void Start () {
Time.timeScale = 0;
}
// Update is called once per frame
void Update () {
timer -= Time.deltaTime;
countdownText.text = (timer).ToString("0");
if (timer < 0)
{
Time.timeScale = 1;
}
}}