How do I stop a timer when it hits 0?
I have a game that needs to end after a timer counts down from 60. The below script that I am using counts down from 60 and displays "You win" once the timer goes below 0. I am trying to find a way to display "You win" when the timer hits 0 instead of below 0. Also I can not figure out how to stop the timer from going into negative numbers after 0. How would I do this?
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 public class counting : MonoBehaviour
 {
     float timeLeft = 60.0f;
     public Text winText;
 
     void Start()
     {
         winText.text = "";
     }
     void Update()
     {
         timeLeft -= Time.deltaTime;
         text.text = "Timer:" + Mathf.Round(timeLeft);
             if(timeLeft < 0)
             {
                 winText.text = "You Win";
             }
     }    
 }
 
              
               Comment
              
 
               
              Your answer