Tutorial: Coroutines (pt. 1) – Waiting for Input.
If you’re new to Unity, you may have heard some phrases being tossed around like “coroutine” and “yield”.
What is a coroutine you ask? Wait a minute, I can tell a method to pause for a frame and then continue doing whatever it was it was doing? Huh? I can specify an amount of time (in seconds) that I can pause the function for, too?
I know there are some people out there probably calling b/s but I’m being serious here. Yes, you can do all of the aforementioned with a coroutine.
When I first started I will admit I didn’t know what a coroutine was and even now I have come to learn that I have only seen the tip of that proverbial iceberg. But from what I do know – I am going to share what I have found out in some basic, but somewhat practical examples (both in C# and Unity’s Javascript dialect) and as time goes by I’ll make them more and more “real world” examples in the following versions of this tutorial.
18