// Coroutines are complicated. You don't have to understand them fully to make Unity games, but they are powerful.
// The basic setup looks like this:
StartCoroutine(PlayFlagpoleAnimation());
IEnumerator PlayFlagpoleAnimation()
{
// Do stuff
yield return someCondition;
// Do more stuff
}
// The coroutine you will use the most (by far) is Unity's built-in WaitForSeconds coroutine:
yield return new WaitForSeconds(1.5f);
// everything after this yield happens after 1.5 seconds
// The "yield" keyword means "keep going with the rest of the game." Everything after "return" is called the yield condition. It is something that will eventually be true. For example, after 1.5 seconds have passed.
// You can have more than one yield statement. It works the same way; the "bookmark" just moves to the latest yield statement.
// Yielding, in traffic, is a specific type of merging. You have to wait your turn to get onto the highway.