- Home /
Delay Function (problem with Time.deltaTime)
Hello, Guys,
I created a function which objective is delay something from happening. Here it is:
bool delay (float time){
float delay = 0;
while (delay < time)
delay += Time.deltaTime;
Debug.Log (delay.ToString());
return true;
My problem is that it's not working properly. This only works if I put the code directly into the update() function, or else, it goes too fast (that is, instantaneously). Does anyone know what's happening?
And please, don't suggest me to use the WaitForSeconds() function : P
is the function name "delay" the same as the variable???
Answer by sparkzbarca · Nov 15, 2012 at 05:54 AM
http://unitygems.com/mistakes1/
open up the Make Something Happen in the future
its got like 5 different ways to delay an action, make something happen in the future, wait for x seconds etc
if you dont like any of those use a coroutine
A co routine is basically using update except not written inside update.