I’m trying to make a 2D overhead shooter and for my character I was thinking about using a state machine, but when I started creating the states I realised I only really need two which being moving and standing still. Even with only needing two states would it be worth it to use?
They aren’t required. It’s important to understand your state-ful program, state machines can help with this, but I’ve also seen them hurt the legibility significantly. Personally I rarely use state machines and opt to create mostly “pure” functions which avoid modifying state themselves, only taking arguments and returning a new value.
You probably do have more than two states, I’d say walking and standing still are the same state, but there may be a dying state, interacting state, taking damage. Anyting that should inhibit the shooting part of your shooter, but these could be done with a timer and animation, I don’t think a state machine is necessary for such a game.
As a test if you find yourself constantly wrapping odd lines code with if $HurtTimer.is_stopped():
then you should use a state machine.
Building on what @gertkeno says, state machines are really a tool for complexity management. If you don’t have a complex setup, there’s no point adding something to manage it.
Thx for the advice.