- Home /
Is the delay function in unity faster than WaitForSeconds()?
I have a project that needs delay function which is not taking long time .. I have tried using WaitForSeconds() but the result takes time too long as well.
I have already given small parameter 0.0000000001f and it still the same , nothing change.
How can I get the faster delay than this function (WaitForSeconds()) ???
Thanks in advance :)
$$anonymous$$ost processors now run at around 3 gigaherz. A time delay like the one you mentioned would only allow for 3 clock cycles of the processor. It seems like you're trying to delay for a shorter time than a processor clock cycle, which won't happen. I'm actually curious to know what would require such a short wait time.
I don't think that's possible. I believe the smallest delay in a coroutine is a frame. So at 60 FPS that would be 1/60th of a second. This is due to coroutines only being "updated" once per frame.
If you use a Thread() you can use Thread.Sleep(1) for milliseconds. But Thread.Sleep basically says "Wait for atleast 1 ms, but it could be 5 ms".
Answer by fffMalzbier · Dec 15, 2015 at 09:36 AM
What delay time are you targeting. WaitForSeconds(0f) -> next time the Coroutine checks for communion of execution -> Next frame (16.67ms on 60fps) or maybe WaitForEndOfFrame could be interesting for you
http://docs.unity3d.com/ScriptReference/WaitForEndOfFrame.htmlWaits until the end of the frame after all cameras and GUI is rendered, just before displaying the frame on screen.
Your answer
Follow this Question
Related Questions
Loading Screen and Lerp 3 Answers
JS WaitForSeconds Not Working? 1 Answer
Waiting for fractions of a Second 1 Answer
Coroutine confusion 1 Answer
How do i add a delay to how often a unity ui button may be used? 1 Answer