gdquest-demos / godot-make-pro-2d-games

A-RPG demo made with Godot, MIT-licensed, from our Godot course
MIT License
1.01k stars 108 forks source link

Fixed player hanging in air when falling in holes #88

Closed codeinclined closed 6 years ago

codeinclined commented 6 years ago

I noticed that the player's height does not return back to 0 if they drop into a hole mid-jump. Thus, the player ends up inadvertently gaining the ability to fly until pressing the jump button again. This PR simply adds a check to PlayerStateMachine.gd to determine whether the player is switching to a state that would prevent the jump state's update method from completing the jump. If so, then the jump state's height is set to 0 with a newly added setter method in Jump.gd

I'm not sure if we intend to have the player able to jump over those holes in the future, but I think until that decision is made, this fixes an easily reproducible bug.

NathanLovato commented 6 years ago

Thank you again 😄