- Home /
Splash screen timer is too fast
When I build and run the project to a unity web player the splash screen doesn't stay for the desired amount of time(5 seconds). I think this is because when unity player is loading the counter starts before the unity player is fully loaded.
Is there any way to start updating the timer after the unity player is loaded?
This code below is what I am currently using, it should wait for 5 seconds but in the web player it only stays for less than 1 second:
var timer : float = 5;
function Update () {
timer -= Time.deltaTime;
if (timer >= 0){
//Do Stuff
}
}
timer >= 0 will be true at the start when the first Update is called, is this correct?
Answer by Tarlius · May 30, 2013 at 07:11 AM
Should the >= not be
Time at the start is 5. 5 is greater than or equal to 0 (ie timer >= 0). So anything inside that if will trigger on first frame.
On a side note, I think you could just yield new WaitForSeconds(5f) in Start() and then do away with the update altogether. (JS syntax may be slightly different, not sure)
Answer by danielskovli · May 30, 2013 at 05:31 AM
Does Time.time or Time.timeSinceLevelLoad provide you with any better results?
If so, then:
var timer : float = 5;
function Update() {
if (Time.time < timer) {
return;
}
}