Sorry for such an awful question, but I have checked the Scripting API and did a good amount of googling. But basically I still don’t understand the purpose of it. I need a basic understanding of how it works, and how and when to use it. Maybe an example of a for statement and an IEnumerator method? I also don’t really understand loops. Sorry for asking of so much, but if anyone is willing to explain anything it would be greatly appreciated!
a for loop is primarily used for iterating arrays, lists, stacks, queues… everything basically that contains more than one value.
one example is the returned array of a Physics.RaycastAll. if you want to check for some condition on all items in the array run a for loop.
An indepth understanding of IEnumerator is not needed for using them in Unity and if you must know check out MSDN for C#.
They are primarily used for scripting time events like cutscenes. every method with that return type is capable of yielding. it means you can start them with StartCoroutine and do stuff like “wait 5 seconds”, “wait for another coroutine to finish”… this can all be written down like a script for a movie without worrying about counting time or something.