diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-07-20 16:50:29 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-07-20 16:50:29 +0200 | 
| commit | c6733caa49e5b47c68c43b494c073ce7b34adec2 (patch) | |
| tree | 9df8c5b5af6a4784915cbebcfd6f8c85edd93469 /client/player/controllable_player.gd | |
| parent | b7b3799ae537566ff4afd97ecbbddb8e2bd79d91 (diff) | |
| download | hurrycurry-c6733caa49e5b47c68c43b494c073ce7b34adec2.tar hurrycurry-c6733caa49e5b47c68c43b494c073ce7b34adec2.tar.bz2 hurrycurry-c6733caa49e5b47c68c43b494c073ce7b34adec2.tar.zst  | |
fix incorrect friction value in client
Diffstat (limited to 'client/player/controllable_player.gd')
| -rw-r--r-- | client/player/controllable_player.gd | 20 | 
1 files changed, 10 insertions, 10 deletions
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index 5e3dba97..29110eb7 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -18,8 +18,8 @@  class_name ControllablePlayer  extends Player -const PLAYER_FRICTION = 10  const PLAYER_SPEED = 55 +const PLAYER_FRICTION = 10  const BOOST_FACTOR = 2.5  const BOOST_DURATION = 0.3  const BOOST_RESTORE = 0.5 @@ -80,28 +80,28 @@ func _process_movement(delta):  		)  	interact()  	var was_boosting = boosting -	update(delta, input, boost) +	direction = input +	update(delta, boost)  	if boosting and not was_boosting:  		Input.start_joy_vibration(0, 0, 1, 0.15)  	walking = input.length_squared() > 0.1  	position_anim = position_  	rotation_anim = rotation_ -func update(dt: float, input: Vector2, boost: bool): -	input = input.limit_length(1.); -	direction = input -	if input.length() > 0.1: -		self.facing = input + (self.facing - input) * exp( - dt * 10.) +func update(dt: float,boost: bool): +	direction = direction.limit_length(1.); +	if direction.length() > 0.1: +		self.facing = direction + (self.facing - direction) * exp( - dt * 10.)  	rotation_ = atan2(self.facing.x, self.facing.y); -	boost = boost and input.length() > 0.1 +	boost = boost and direction.length() > 0.1  	boosting = boost and (boosting or stamina >= 1.0) and stamina > 0  	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.) -	self.velocity_ += input * dt * speed +	self.velocity_ += direction * dt * speed  	self.position_ += self.velocity_ * dt -	self.velocity_ = self.velocity_ * exp( - dt * 15.) +	self.velocity_ = self.velocity_ * exp( - dt * PLAYER_FRICTION)  	collide(dt)  func collide(dt: float):  |