Hello! Recently, someone suggested that I should use a state machine for my combat system. However, I don’t really understand how a state machine works or what it actually represents in practice. I’m also not sure how to design or implement one for a combat system.
Could someone please explain the basic concept of a state machine, why it is useful in game combat systems, and how I can start creating one step by step? Examples or simple explanations would be greatly appreciated.
State machines basically tell the npc how it should and when to behave. It’s much better than handling multiple different possible edge cases.
A basic example would be
Listen for “Idle” state → If not state “Attacking” then → Free roam
Listen for “Attack” state → If state “Idle” then → Find and attack the nearest player
Yes that works, but what I did was create my own state manager module where it makes it easy to change states and detect changes. I would show but I’m currently away from my pc