Problems with changing of State in IEnumeration

Hello dear Community

first of all i want to introduce myself. My name is Eddy, I’m 25 years old, from Germany and quit new in Unity3D and C#. I have work a long time with the Game Maker Studio Engine and I decided to finally go to Unity3D. I have seen a lot of tutorials and till now I works all the way I wanted. But now I got a problem and I dont know why it exists. I am using the Free Version 5.5 of Unity. I hope that I can explain my problem correctly.

My code looks simply like this:

public class GameController : MonoBehaviour {

    public enum Status {start, attacke, action, wait, value, nix , playerWin, enemyWin};

    public Status state = Status.start;
    public Text text = "";

void Start(){
StartCoroutine(GameStart());
}


void FixedUpdate(){
       switch (state)
    {
        case Status.attacke:    text.text = "Jump";
            state = Status.action;
            break;

        case Status.action:
            // (Hier passiert die ganze Action)
            break;
    }
   
}


IEnumerator GameStart()
    {
        text.text = "3";
        yield return new WaitForSeconds(1);
        text.text = "2";
        yield return new WaitForSeconds(1);
        text.text = "1";
        state = Status.attacke;
      
    }

}

So my problem is now, the code itself work’s but not everytime.
A few times all this works like it should and a few time it stops in GameStart() before the state change to Status.attacke; Has anyone an idea why this is so ? … OK I think I solved this problem… all works right when i have the switch in the update but not in the fixedupdate now i just set a bool in the update on true so it works

Hello,

FixedUpdate is unreliable if you want to call certain events, as FixedUpdate is not called every frame like Update is this might create issues when doing things like movement or logic triggering. Update is called eachframe and is thus the best way for you to go.