Hey,
This is more of an advice question than a coding one, I wanted to ask how you guys have had the most success with organizing player behaviour in games. My projects tend to range on the smaller side, from jams to games I work on for a few months, and Ive been wondering how to go about organizng complex behaviours for things like players with lots of movement options or complex enemy AI.
Most sources have pointed me to a state machine, and in a recent game jam, I tried using a hierarchical state machine that basically built a state tree where parent states could run logic and have child states that ran more precise logic. Ex a parent has movement and cinematic state, with movement having child states grounded, airborne, and dash
Anyways, it ended up having a ton of bugs and it was a pain in the butt to navigate between states and manage parent/child node navigation. I wouldnt mind trying to remake it, but honestly it just seems like so much more of a hassle compared to a flat state machine.
I've also heard of using object hierarchies, with gameobjects that you enable/disable representing states, but idk if this is a good idea or not. Theres also Unity's built-in animation editor, but I dont have much experience with that and tutorials I've watched have made it look kinda tricky to use
Alternatively, I could just not have a state machine, but that usually ends up with large conditionals in movement scripts and unclear state handling. However, if thats not the case for your projects, please let me know how you went about it!
So how do you guys go about it? Do you use hierarchichal or flat state machines? Do you make them in code, use object hierarchies, or use Unity's animation cycles editor? Are certain methods different for different sized games? What kind of structure would be best for reuse in multiple projects while being scaleable? I just want something thats easy to implement/use while being useful in various games with more complex mechanics.
Thanks!