So, i'm currently making a fast fps movement controller (something similar to Quake), and i'm struggling on how to keep the velocity momentum while being in air, after pressing a direction input.
Here's my movement code part :
var input_dir = Input.get_vector("left", "right", "frontward", "backward")
var direction = (cameraHolder.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_on_floor():
if direction:
velocity.x = lerp(velocity.x, direction.x * moveSpeed, moveAcceleration * delta)
velocity.z = lerp(velocity.z, direction.z * moveSpeed, moveAcceleration * delta)
else:
velocity.x = lerp(velocity.x, direction.x * moveSpeed, moveDecceleration * delta)
velocity.z = lerp(velocity.z, direction.z * moveSpeed, moveDecceleration * delta)
elif !is_on_floor():
if direction or !direction:
velocity.x = lerp(velocity.x, direction.x * moveSpeed, airControlForce * delta)
velocity.z = lerp(velocity.z, direction.z * moveSpeed, airControlForce * delta)
move_and_slide()
So, does anyone know how i can do that ?