Skip to main content
1 of 2
UserUser
  • 171
  • 1
  • 11

Unity Coroutine freezes game even though no loop

Every time I call this function that starts the coroutine Faint, it freezes the game. I do not understand why this freezes the game though, because the coroutine does not have any loop.

public void StartFaint()
{
    faintSecs = 1.5f;
    StartCoroutine("Faint");
}

IEnumerator Faint()
{
    ChangeState(true);
    yield return new WaitForSeconds(1.5f);
    ChangeState(true);
    yield break;
}

ChangeState() just changes the value of some variables. The Coroutine is just being started once.

According to the internet, yield break is supposed to terminate the coroutine...but maybe I'm mistaken?

Thank you in advance.

UserUser
  • 171
  • 1
  • 11