I'm planning on making my own timing system with seconds, minutes, hours.....etc (in java language), but I'm trying to make the "Seconds" count to 60 then start back at 1 and then if seconds =60 then minute=+1 But when I type in this Seconds = Seconds + 1; It counts...but in tens . Code : var Seconds = 0; private var SecondCalculator = 0; function Start () { } function Update () { Seconds = Seconds + 1; } Can someone help me with this please (Checked the "Newbie guide to Unity Javascript (long)" and read the whole thing twice)
Update() gets called every frame, not every second, so if you're getting 40 FPS, then it will count up by 40 every second. Instead you should use Time.deltaTime, which is the time in seconds since the last frame. Like this: function Update() { Seconds = Seconds + Time.deltaTime }
That's because it's an integer. Code (csharp): var seconds : float = 0; function Update() { seconds += Time.deltaTime; }
Thanks a lot, at first it didn't work so I made a new java file and it worked! I then copied everything over to the old one but still didn't work. So I deleted the old one, which was named "Time" and replaced it with the new one "NewBehaviourScript", I later renamed "NewBehaviourScript" to "Time" and it stopped working. Guess it was the file name the whole time. Anyway thanks a lot makeshiftwings and Loius
File name == class name. By naming the file "Time", you're overwriting the Time class in Unity. This makes it difficult to use Unity's Time class instead of your own.
Finally finished the advanced time system I've been working on. Complete dates with even the number of days for each individual month and even for leap years. Thanks a lot. Let me know if you any of you may want it