From df007c51fa11bc1a423c67444d0ad6415c11b539 Mon Sep 17 00:00:00 2001 From: Shea Frembling <78270092+sfrembling@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:17:34 -0600 Subject: [PATCH] add friction to slow velocity rather than resetting it (#8) * add friction to slow velocity rather than resetting it * Resolve merge conflict * Revert "add friction to slow velocity rather than resetting it" This reverts commit b21ea684ba339d9dfa7d682ed490b5b8f5f2f9e3. * re-add change --- Player/player_controller.gd | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Player/player_controller.gd b/Player/player_controller.gd index e4a00d5..a41ae07 100644 --- a/Player/player_controller.gd +++ b/Player/player_controller.gd @@ -7,6 +7,8 @@ const BASE_MOVE_SPEED: float = 5 const SPRINT_MOVE_SPEED: float = 8 const BASE_HEIGHT: float = 2.0 const CROUCH_HEIGHT: float = 1.0 +const FRICTION: float = 0.2 +const AIR_FRICTION: float = 0.025 const CROUCH_TRANSITION_SPEED: float = 0.1 enum MovementMode { @@ -62,8 +64,17 @@ func handle_movement(delta: float) -> void: "move_forward", "move_backward") var movement_dir := transform.basis * Vector3(input.x, 0, input.y) - velocity.x = movement_dir.x * move_speed - velocity.z = movement_dir.z * move_speed + if movement_dir.x == 0: + velocity.x = lerpf(velocity.x, 0.0, + FRICTION if is_on_floor() else AIR_FRICTION) + else: + velocity.x = movement_dir.x * move_speed + + if movement_dir.z == 0: + velocity.z = lerpf(velocity.z, 0.0, + FRICTION if is_on_floor() else AIR_FRICTION) + else: + velocity.z = movement_dir.z * move_speed func handle_state_transition() -> void: match current_movement: