fix: squating was making the player fall troght the floor
authorEduardo Fernandez <[email protected]>
Sun, 11 Feb 2024 23:12:07 +0000 (00:12 +0100)
committerEduardo Fernandez <[email protected]>
Sun, 11 Feb 2024 23:12:07 +0000 (00:12 +0100)
player/Player.gd

index b55106541c00ff1121ad7656726f8bff10f0dd82..7d040ae39ce64ff0567f60dafbed472b3229f559 100644 (file)
@@ -20,9 +20,9 @@ signal recharge_battery
 var target_velocity := Vector3.ZERO
 var noise: float = 0
 
-const squat_position := 0.6  # Position to which the camera moves when squatting
-const stand_position := 1.7  # Position to which the camera moves when standing
-const move_speed := 8.0  # Speed at which the camera moves from stand to squat and back
+const squat_scale := 0.4  # Position to which the camera moves when squatting
+const stand_scale := 1  # Position to which the camera moves when standing
+const squat_speed := 2.5  # Speed at which the camera moves from stand to squat and back
 var is_squatting := false
 
 var object_detected: Object = null
@@ -43,10 +43,10 @@ func _physics_process(delta):
        elif Input.is_action_just_released("squat"):
                is_squatting = false
 
-       if is_squatting and camera.position.y > squat_position:
-               scale.y = scale.y * -move_speed * delta
-       elif not is_squatting and camera.position.y < stand_position:
-               scale.y = scale.y * move_speed * delta
+       if is_squatting and scale.y > squat_scale:
+               scale.y = scale.y - squat_speed * delta
+       elif not is_squatting and scale.y < stand_scale:
+               scale.y = scale.y + squat_speed * delta
 
        if Input.is_action_pressed("squat"):
                speed_mod = squating_speed_mod