Godot Version
4.2.1.stable.mono
Question
Hello everyone! After finishing my second game jam, I was finally tired enough of the spaghetti code of nested if-statement chains that I wanted to find a better way to do it!
I am pretty new to game dev., but not to programming so I had a feeling there was a better way besides using the if-statement BEAST! I stumbled upon “State Machines”, and let me tell you, they are amazing. Well at least in theory, in practice it seems they can be kind of clunky and require A LOT of setup.
Basically my question(s) are, how do you guys implement your State Machines? What kind of tips do you have to make them operate better or more efficiently. And how do you tackle readability? Do you recommend using a paradigm other than State Machines (and the “BEAST”)? What sort of indicators let you know that a State Machine should OR shouldn’t be used? OH! And how do you implement the use of functions that are “activated” by signals from another node? It seems to me so far that State Machines are only used for callback functions (i.e., process
, input
, physics_process
, etc.)
I would really appreciate any tips thrown my way! And feel free to drop in some of your own examples, I would love to dig through them. Excited to implement your help in my next game jam!
P.S.: I can use C# and GDScript, but I prefer C#.