I’m trying to wait for a nestesd coroutine to end inside another coroutine.
I have the following code:
public IEnumerator Fall()
{
controller.DisableMovement();
animationManager.animator.SetBool("Falling", true);
while (!controller.IsGrounded())
{
yield return null;
}
animationManager.animator.SetBool("Falling", false);
print(1);
if (controller.HardLanding())
{
yield return StartCoroutine(HardLand());
}
else
{
yield return StartCoroutine(Land());
}
print(4);
}
public IEnumerator HardLand()
{
print(2);
animationManager.animator.SetTrigger("Hard Land");
yield return new WaitForSeconds(animationManager.GetAnimationClip(animationManager.clipNames.hardLanding).length + 5f);
animationManager.animator.ResetTrigger("Hard Land");
controller.EnableMovement();
print(3);
}
The print order should be 1, 2, 3 & 4. But I’m getting 1, 2, 4, 3, and don’t know how to fix this.