Player character stopping suddenly when grounded and moving into walls at an angle using move_and_slide()

Godot Version



I am currently creating a movement system heavily relying on momentum and wall sliding. The character is able to boost forward, losing all control until they hit the ground and begin to experience friction / react to player input. However, when the player is sliding on the ground while against a wall and the movement keys are held so that they attempt to move into the wall, their movement hitches for a split second before they get unstuck. When no keys are pressed, they simply slide along the wall as expected.

Since I cannot post attachments, here is my (janky) grounded movement code:

#create vector for horizontal movement directions only
var move_direction = Input.get_vector(Left, Right, Forward, Backward)
move_direction = move_direction.rotated(-cameraArm.rotation.y).normalized()
# create a vector2 to move_toward on horizontal axis
var horizontal_move = Vector2.ZERO
horizontal_move.x = player.velocity.x
horizontal_move.y = player.velocity.z
horizontal_move = horizontal_move.move_toward(move_direction*speed, acceleration)
player.velocity.x = horizontal_move.x
player.velocity.z = horizontal_move.y
player.velocity.y -= gravity * delta

Similar hitching also happens when just walking against a wall normally, albeit much more rarely than when sliding with momentum. All physics settings for my player are set to their defaults.