- Home /
How do I make a Countdown Timer in Minutes and Seconds only
I have most of the code for the countdown timer . It's still not working . The timer counts down one number and it stops. I am also trying to display the timer on the screen. Here is some of my code :
using UnityEngine; using System.Collections;
public class clock : MonoBehaviour { public string Minutes; public string Seconds; public float Clock; void Start () { string Minutes = Mathf.Floor(Clock / 60).ToString("00"); string Seconds = Mathf.Floor(Clock % 60).ToString("00");
 }
 
 void Update () 
 { 
``Clock += Time.deltaTime;
 }
}
Answer by rober-psious · Apr 27, 2016 at 04:33 PM
You can try with this:
 public class Clock : MonoBehaviour
 {
     public float CurrentTime;
     public float Minutes { get { return Mathf.Floor(CurrentTime / 60f); } }
     public float Seconds { get { return Mathf.Floor(CurrentTime % 60f); } }
 
     private void Start()
     {
         CurrentTime = 0f;
     }
 
     private void Update()
     {
         CurrentTime += Time.deltaTime;
     }
 }
The $$anonymous$$inutes and Seconds is not showing up in the inspector.
Your answer
 
 
             Follow this Question
Related Questions
timer not ticking down 2 Answers
How to make reverse countdown timer in unity? 1 Answer
How to create an accurate timer in Unity? 1 Answer
Timer Pause and Reset Issue 2 Answers
How accurate is Stopwatch.ElapsedTicks? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                