- Home /
yield, Coroutines, InvokeRepeating...
On my way learning game development with unity, I frequently had to pause a process for a short while, be it in the update, or in an event, or else where. But I still can't get a good hold of the difference between them, when each should be used and where. Luckily I always managed to find a work around or else I used InvokeRepeating (which is the easiest to understand), but I really wish to have a good understanding of yield waitforseconds and coroutines.
Please point me to the right sources to understand these functions and maybe other functions that are similar and I didn't mention.
Here are a few article on this topic.
http://unitygems.com/coroutines/
http://unitygems.com/advanced-coroutines/
http://unitygems.com/mistakes1/ in this one go down to "$$anonymous$$ake things happens in the future"
Answer by jeango · Dec 28, 2012 at 06:32 PM
YieldInstruction is where you want to look at for starters
http://docs.unity3d.com/Documentation/ScriptReference/YieldInstruction.html
it is the base class for everything Yield-related
About InvokeRepeating, there's not much to understand other than what its name says: it repeatedly invokes a method... everything you need to know for this (and for many other things) is in the scripting reference
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.InvokeRepeating.html