I have this script which is what i use as my timer to countdown the seconds, the timer stops at 0 but i don’t know how to make the game restart when it reaches zero.
Here’s the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MyTimer : MonoBehaviour
{
public float MyCoolTimer = 60;
public Text timerText;
// Use this for initialization
void Start()
{
timerText = GetComponent<Text>();
}
// Update is called once per frame
void Update()
{
MyCoolTimer -= Time.deltaTime;
timerText.text = MyCoolTimer.ToString("f1");
print(MyCoolTimer);
if (MyCoolTimer == 0)
{
MyCoolTimer = 0;
}
}
}