godot-wildlings / cyberpunk-jam-2019

https://itch.io/jam/cyberpunk-jam-2019
MIT License
2 stars 0 forks source link

loss of momentum problem in Player State Machine #42

Closed plexsoup closed 5 years ago

plexsoup commented 5 years ago

Currently, each state in the player state machine handles movement, which means keeping track of velocity vectors and gravity.

That creates a problem when players change states. The states lose track of their previous velocity.

For example: When jumping or falling, if the player gets hit by a bullet, they'll freeze in mid-air.

Can solve this in two ways:

  1. Move velocity and movement logic back into the core player object.
  2. Always pass current velocity between states.
plexsoup commented 5 years ago

I already pass velocity around with quite a few (most) states, so I don't know if it's simpler to pass it to ALL states, or move that logic back out into the player object.

plexsoup commented 5 years ago

player state machine was refactored. state.gd now has get_velocity() and set_velocity() functions. Those are utilized inside player set_state() method to pass velocities around.