Hi there i´m new to unity. i have built a labyrinth with timer. how can i set the timer backwards from 15sec. counting down and stop the game at 0?
Timer:
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class Timer : MonoBehaviour {
 public Text counterText;
 public float seconds, minutes;
 // Use this for initialization
 void Start () {
     counterText = GetComponent <Text> () as Text;
 }
 // Update is called once per frame
 void Update () {
     minutes = (int)(Time.time / 60f);
     seconds = (int)(Time.time % 60f);
     counterText.text = minutes.ToString ("00") + ":" + seconds.ToString ("0000");
         }
         }
 
               PlayerController:
using UnityEngine; using UnityEngine.UI; using System.Collections;
public class PlayerController : MonoBehaviour {
 public float g=9.8f;
 public Text countText;
 public Text winText;
 private Rigidbody rb;
 private int count;
 void Start ()
 {
     rb = GetComponent<Rigidbody>();
     count = 0;
     SetCountText ();
     winText.text = "";
 }
 void FixedUpdate() {
     // normalize axis
     var gravity = new Vector3 (
         Input.acceleration.x,
         Input.acceleration.z,
         Input.acceleration.y
     ) * g;
     GetComponent<Rigidbody>().AddForce (gravity, ForceMode.Acceleration);
 }
 void OnTriggerEnter(Collider other) 
 {
     if (other.gameObject.CompareTag ( "Pick Up"))
     {
         other.gameObject.SetActive (false);
         count = count + 1;
         SetCountText ();
     }
 }
 void SetCountText ()
 {
     countText.text = "Count: " + count.ToString ();
     if (count >= 12)
     {
         winText.text = "Spitze!";
     }
 }
 
               }
               Comment
              
 
               
              Your answer