I am having issues with my clock script: The problem is:
When the seconds get 60, the scripts goes crazy!
using UnityEngine; using System.Collections;
public class Clock : MonoBehaviour {
public float seconds = 0;
public int minutes = 1;
public int hours = 22;
public int day = 0;
public float month;
public float year;
public bool isBusy = false;
public dfLabel textd;
public float aseconds = 0;
// Update is called once per frame
void Update () {
if (!isBusy){
isBusy = true;
seconds = (int) Time.time;
if (seconds <=9 minutes <=9 hours <=9)
{
textd.Text = “0” + hours + “:0” + minutes + “:0” + seconds;
}
else if (hours <=9 minutes <=9)
{
textd.Text = “0” + hours + “:0” + minutes + “:” + seconds;
}
else if (minutes <=9)
{
textd.Text = hours + “:0” + minutes + “:” + seconds;
}
else if (hours <=9)
{
textd.Text = “0” + hours + “:” + minutes + “:” + seconds;
}
else
{
textd.Text = hours + “:” + minutes + “:” + seconds;
}
isBusy = false;
}
}
}
From Docs: Time.time returns the time in seconds since the start of the game. So it can return… 54855!, and your code has no lines to convert seconds to minutes. Or hours… Or anything else.