• Advertisement
Sign in to follow this  

FSMs in Platformers

This topic is 1902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have got my platformer working in a very basic fashion: entity/tile management system, collision, movement, collectible/dangerous items, camera etc.

I have a long list of things that I would like to start adding/improving - and I think a state system for the entities would be a good place to start. My thinking was that this would simplify handling different kinds of behaviour - but also that I could link animations in with states.

However I am unsure of exactly how to structure this. I was considering states like grounded, jumping, underwater, dead - and then having nested states (moving left, moving right, stationary.)

How have you guys handled this in the past/would you handle this?

Share this post


Link to post
Share on other sites
Advertisement
Hello
I am not an expert on this, but I'd like to share and maybe discuss.
For my game objects, I have two fsm right now; one for input and one for motion.

In the input FSM, I have the following states: KEYBOARD (input comes from keyboard), INERT (object doesn't think), WANDER (walks around the area), HUNT (find things to kill), FLEE (run in opposite direction of danger). Theses states does not do much, they mostly change the states of the motion FSM.

In the motion FSM, I have the following states: IDLE (not moving), WALK (move), RUN (move faster).

I don't use nested states because I feel it's too complicated. I think I will add one more FSM for animation later on, but this is what I have right now.
What do you think? ;o

Share this post


Link to post
Share on other sites
Are you working on a platformer? Or maybe a 2D RPG type of game?

If you are working on a platformer, do you not need states for jumping and being on the ground? Or could you just represent them using a boolean variable? I like the idea of using a state machine for the animations - what I was actually going to do was just set the animations in the walk state, or in the run state etc. - but this seems like a better solution.

Share this post


Link to post
Share on other sites
[quote name='Silgen' timestamp='1352025024' post='4997129']
Are you working on a platformer? Or maybe a 2D RPG type of game?

If you are working on a platformer, do you not need states for jumping and being on the ground? Or could you just represent them using a boolean variable?
[/quote]

Right, It's a 2d rpg. If it was a platformer though, I would use a boolean value to represent grounded or not. That way, I don't have a seperate state just for one particular direction, and that's consistent with the way I lay them out in my 2d rpg.

Or maybe make it more general have 4 boolean values to represent touching south, touching east, touching north, and touching west. Most of the time touching south can be interpreted as grounded, but the other directions can be interpreted as grounded too if you decide to implement gravity scew. Just a thought ;o

[quote name='Silgen' timestamp='1352025024' post='4997129']
I like the idea of using a state machine for the animations - what I was actually going to do was just set the animations in the walk state, or in the run state etc. - but this seems like a better solution.
[/quote]

Animation is low priority for me right now, so I don't know how well that idea is because I don't have a working implementation of it. Still worth a try though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement