Skip to content

Commit

Permalink
Make camera roll configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveplays28 committed Jun 21, 2022
1 parent 946f4e3 commit fec7742
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/PlayerControllerKinematic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public class PlayerControllerKinematic : KinematicBody
[Export] public float JumpLength = 0.25f;
[Export] public float JumpSpeed = 100f;
[Export] public int JumpAmount = 2;
[Export(PropertyHint.Range, "0, 100")] public float CameraRollMultiplier = 0.1f;
[Export(PropertyHint.Range, "0, 100")] public float CameraRollSpeed = 0.05f;
[Export(PropertyHint.Range, "0, 100")] public float CameraPitchMultiplier = 0.1f;
[Export(PropertyHint.Range, "0, 100")] public float CameraPitchSpeed = 0.05f;
[Export] private readonly NodePath FloorRayCastNodePath;
[Export] private readonly NodePath CameraNodePath;
[Export] private readonly string AnimationTreeNodePath;
Expand Down Expand Up @@ -141,13 +145,13 @@ private void HandleMovementInput(float delta)
{
inputDirection += Transform.basis.x;

cameraRotationDegrees.z = Mathf.Clamp(cameraRotationDegrees.z - 0.1f * maxMovementSpeed, -2f, 2f);
cameraRotationDegrees.z = Mathf.Clamp(cameraRotationDegrees.z - CameraRollSpeed * maxMovementSpeed, -CameraRollMultiplier * maxMovementSpeed, CameraRollMultiplier * maxMovementSpeed);
}
if (Input.IsActionPressed("move_left"))
{
inputDirection -= Transform.basis.x;

cameraRotationDegrees.z = Mathf.Clamp(cameraRotationDegrees.z + 0.1f * maxMovementSpeed, -2f, 2f);
cameraRotationDegrees.z = Mathf.Clamp(cameraRotationDegrees.z + CameraRollSpeed * maxMovementSpeed, -CameraRollMultiplier * maxMovementSpeed, CameraRollMultiplier * maxMovementSpeed);
}
inputDirection = inputDirection.Normalized();
camera.RotationDegrees = cameraRotationDegrees;
Expand Down

0 comments on commit fec7742

Please sign in to comment.