From 051d24bf65475e08fb7c11e258e503192c0cb52e Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 5 Mar 2026 19:39:08 +0100 Subject: new movement math varies less with tick rate --- client/player/player.gd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'client') diff --git a/client/player/player.gd b/client/player/player.gd index dd705423..a72104b5 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -21,8 +21,8 @@ const ITEM_BUBBLE: PackedScene = preload("res://player/item_bubble.tscn") const EFFECT: PackedScene = preload("res://player/particles/effect.tscn") const PLAYER_SIZE: float = 0.4 -const PLAYER_SPEED = 55 -const PLAYER_FRICTION = 15 +const PLAYER_ACCELERATION = 10 +const PLAYER_SPEED = 3.8 const BOOST_FACTOR = 2.5 const BOOST_DURATION = 0.3 const BOOST_RESTORE = 0.5 @@ -145,10 +145,9 @@ func update_movement(dt: float, boost: bool): if boosting: stamina -= dt / BOOST_DURATION else: stamina += dt / BOOST_RESTORE stamina = max(min(stamina, 1.0), 0.0) - var speed = PLAYER_SPEED * (BOOST_FACTOR if boosting else 1.) - velocity_ += direction * dt * speed + var target_v = direction * PLAYER_SPEED * (BOOST_FACTOR if boosting else 1.) + velocity_ = target_v + (velocity_ - target_v) * exp(-dt * PLAYER_ACCELERATION) position_ += velocity_ * dt - velocity_ = velocity_ * exp(-dt * PLAYER_FRICTION) collide(dt) func collide(dt: float): -- cgit v1.3