Modeling player mechanics with a finite state machine
        Posted  
        
            by 
                K..
            
        on Game Development
        
        See other posts from Game Development
        
            or by K..
        
        
        
        Published on 2014-06-11T02:27:53Z
        Indexed on 
            2014/06/11
            3:48 UTC
        
        
        Read the original article
        Hit count: 341
        
game-mechanics
|state
I have three states
standingwalkingjumping
When I press D standing transitions to walking. The velocity will be set to a defined value and the player moves.
When I release D walking transitions back to standing, which sets the velocity back to 0.
When I press W and the state is walking it transitions to jumping, but when the player hits the ground, it goes back to standing.
jumping has a transition land that always leads to standing because a state doesn't know about its previous states.
Since standing sets a velocity of 0 the player stops walking, when he hits the ground.
How do I prevent this?
© Game Development or respective owner