Doing FSM and sometimes you want the same logic to be applied for multiple states, for instance, aiming a weapon should be allowed when the player is idle, walking or running.
For such common situation normally I would do, as you guessed:
#AIM WEAPON - logic
func Something_Foobar() -> void:
if STATE == "IDLE" or STATE == "WALK" or STATE == "RUN": pass
# Allow aim weapon code check.
# Allow firing weapon.
How I would go about on doing them like this: if STATE == ("IDLE" or "WALK" or "RUN"):
or better even if STATE == ("IDLE","WALK","RUN"):
or the inverse if ("IDLE" or "WALK" or "RUN") in STATE:
I would avoid using (arrays
or dictionaries
or for
) loops just for this.
Thanks for reading,