fix(PlayerControllerBase): Turning is now persisted when AutoRun is enabled.

This commit is contained in:
MrGadget 2024-09-17 15:57:13 -04:00
parent a154804c1a
commit c8a2d3d2a8

View File

@ -296,7 +296,11 @@ void HandleTurning(float deltaTime)
if (moveKeys.TurnRight != KeyCode.None && Input.GetKey(moveKeys.TurnRight))
targetTurnSpeed += maxTurnSpeed;
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, turnAcceleration * maxTurnSpeed * deltaTime);
// If there's turn input or AutoRun is not enabled, adjust turn speed towards target
// If no turn input and AutoRun is enabled, maintain the previous turn speed
if (targetTurnSpeed != 0f || !controlOptions.HasFlag(ControlOptions.AutoRun))
turnSpeed = Mathf.MoveTowards(turnSpeed, targetTurnSpeed, turnAcceleration * maxTurnSpeed * deltaTime);
transform.Rotate(0f, turnSpeed * deltaTime, 0f);
}