Hi.
So I just learned about co rotines.
And I wanted two coroutines that whenever one finishes it calls the other.
So I did this script:
void Start() {
StartCoroutine(CorOnAir());
}
IEnumerator CorOnGround() {
Debug.Log("Ground DoBefore");
while (!onAir) {
yield return new WaitForEndOfFrame();
Debug.Log("Ground DoWhile");
}
StartCoroutine(CorOnGround());
yield break;
}
IEnumerator CorOnAir() {
Debug.Log("Air DoBefore");
while (onAir) {
yield return new WaitForEndOfFrame();
Debug.Log("Air DoWhile");
}
StartCoroutine(CorOnAir());
yield break;
}
But It dosen’t work.
Can somebody help with this?
Just change StartCoroutine(CorOnGround()); on line 13 to StartCoroutine(CorOnAir());
And StartCoroutine(CorOnAir()); on line 25 to StartCoroutine(CorOnGround()); and it should do the trick.