Velocity.x zeroing using FSM when colliding with wall tile while jumping

Godot Version



Using a 2d character finite state machine , I’m having trouble maintaining horizontal velocity if I’m already moving left/right when transitioning from “ground” state to the “in air” state by jumping.

What happens is my velocity.x is zeroed when colliding with a wall while in the air, I am holding left or right down the whole time, and I then need to release and press left or right again to resume horizontal movement.

If I press jump then move left or right while in the air, horizontal velocity is maintained after hitting a wall and I continue to move horizontally, as expected, once returning to “ground” state.

I have a zip file of the offending FSM project, and another for a non-FSM “works as intended/expected” project. However I was unsure where to upload and link from, any suggestions welcome.

Thanks in advance, I hope I provided enough info to be able to figure it out.

My best guess is I need a way to keep track of or store velocity.x outside of each individual state?