Currently my movement allows me to change directions instantly, including 180 degree turns. In most of the games I've played this is not possible as rotating is noticeably delayed.
Is it possible to solve this problem without sacrificing precise and responsive movement?
func _allow_movement(delta: float) -> void:
movement_direction = Vector3(input_direction.x, 0.0, input_direction.y).normalized()
movement_direction = movement_direction.rotated(Vector3.UP, camera.rotation.y)
if not movement_direction.is_zero_approx():
if horizontal_velocity.length() < target_velocity:
current_horizontal_velocity = move_toward(current_horizontal_velocity, target_velocity, (acceleration * delta))
else:
current_horizontal_velocity = move_toward(current_horizontal_velocity, target_velocity, (friction * delta))
velocity.x = (movement_direction.x * current_horizontal_velocity)
velocity.z = (movement_direction.z * current_horizontal_velocity)
var bas: Basis = Basis.looking_at(velocity.slide(Vector3.UP).normalized())
global_basis = global_basis.slerp(bas, (rotation_speed * delta))
else:
horizontal_velocity = velocity.move_toward(Vector3.ZERO, (friction * delta))
velocity.x = horizontal_velocity.x
velocity.z = horizontal_velocity.z