Jump to content

  • Log In with Google      Sign In   
  • Create Account


FSMs in Platformers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Silgen   Members   -  Reputation: 178

Like
2Likes
Like

Posted 03 November 2012 - 11:26 AM

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?

Sponsor:

#2 ultramailman   Prime Members   -  Reputation: 1556

Like
1Likes
Like

Posted 03 November 2012 - 07:27 PM

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

#3 Silgen   Members   -  Reputation: 178

Like
0Likes
Like

Posted 04 November 2012 - 04:30 AM

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.

#4 ultramailman   Prime Members   -  Reputation: 1556

Like
1Likes
Like

Posted 04 November 2012 - 12:18 PM

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?


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

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.


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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS