- Home /
Certain timers run too fast
I'm having a strange problem with timing in only certain scenes of my build. For instance, in my Loading scene, I use the following simple method for controlling my countdown:
void Update () { timer += Time.deltaTime; if (timer >= timeToWait) { Application.LoadLevel ("MainMenu"); } }
This works fine in the Inspector and when I compile a build and run it on my development machine. However, when I move it to my production machine, it counts down very quickly; probably hitting 0 after about two or three seconds.
In another scene, I "blink" some text by looping the alpha value in a method called from Update:
function UpdateTextAlpha()
{
// Fade font in proper direction.
if (c.a >= 1)
{
fontFadeIn = false;
}
if (c.a <= 0)
{
fontFadeIn = true;
}
if (fontFadeIn == true)
{
c.a += Time.deltaTime;
}
else
{
c.a -= Time.deltaTime;
}
}
Again, this is fine in the Inspector and when running a build on my development machine; however, on the production machine, it is way too fast.
On the other hand, I use the first method in other scenes, and the countdown is perfect. Any idea where I'm going wrong? Thanks.
Update: I tried copying my entire scene to a new project and testing just that scene. The countdown timer runs fine when I do that.
Is something setting Time.timeScale? It's certainly odd.
I thoroughly checked the three scripts that run in the loading scene, and verified that I don't change the timeScale anywhere, but just for the heck of it, I added time.Timescale = 1.0f to my loading script, and my ti$$anonymous$$g works perfectly now for that scene and the flashing text on the main menu. Bug report perhaps?
Lol. Done and done. Problem is fixed and bug report is submitted. Thanks for your help!
Answer by Geo.Ego · Dec 21, 2012 at 06:48 PM
I added this answer in case anyone else runs into this bug. Basically, Time.timeScale was off in any scenes that I added to this particular project. I fixed it by setting Time.timeScale = 1.0f in Start () for every one of my scripts.
Your answer
Follow this Question
Related Questions
countdown timer acivation 1 Answer
Countdown timer into text c# 1 Answer
Unity hand-made timer doesnt work? 1 Answer
How to restart a level with countdown? 4 Answers
Use timer to remove text 2 Answers