I’m trying to create a multiple animation system for the player, but I’m not sure what the best approach is. In particular, I need to handle these states:
idle
moving
idle + shooting
moving + shooting
throwing a grenade while idle
throwing a grenade while moving
animation when touching / pressing a button
In your opinion, what is the cleanest and most efficient method to manage this?
Is it better to use state variables, booleans, a finite state machine, or to manage everything directly through event conditions?
If you have examples, screenshots of events, or even just some practical advice, it would be really helpful
Thanks a lot in advance!
Hi - there’s a few different ways to order this - is it a platformer or top down? is it 2d? What behaviours are you using?
how many different movement states are there?
Do you have bespoke animations for shooting and moving? or just an animations for moving and an animation for shooting?
and same question for grenade
You could try something like this - there’s other ways to do it though.
i did it with a platformer and just 4 movement states
theres a boolean each for throw and shoot and three timers
Hi, thanks for your response. I’m developing a Metal Slug-style game where the player can shoot both while standing still and while moving, and can throw grenades in both cases. I’m also working on a multi-animation system to handle these situations (for example combining walking and shooting), as well as an animation for when the character reaches out to press a button.
Ok - looks like there’s a land state too and a crouch/crouch shoot
so quite a few states. ill have a think how best to order the logic but something like what i did above should work
No problem -
I’m sure that others might do it differently - so what i did was- it’s not strictly a finite state machine. There is the main movement variable - i used a number but you could easily replace this with a text to make it easier to read. This variable is over ridden by the booleans so that when state is Run (1 and 2) the animation is turned to Run but then turned immediately to Run shoot or run throw if one of those is true.
there are conditions that prevent running and shooting at the same time. The land state (5) is last so that it overrides other changes (you could add state not equal to 5 in the shooting conditions) The landgain variable increases when falling so that the land animation lasts longer if you’ve fallen further.