From c8a2d3d2a82eeb92e3d8cbc8bb4678326ce04991 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:57:13 -0400 Subject: [PATCH] fix(PlayerControllerBase): Turning is now persisted when AutoRun is enabled. --- .../Controllers/PlayerController/PlayerControllerBase.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Examples/_Common/Controllers/PlayerController/PlayerControllerBase.cs b/Assets/Mirror/Examples/_Common/Controllers/PlayerController/PlayerControllerBase.cs index 635fc4c92..bb9583070 100644 --- a/Assets/Mirror/Examples/_Common/Controllers/PlayerController/PlayerControllerBase.cs +++ b/Assets/Mirror/Examples/_Common/Controllers/PlayerController/PlayerControllerBase.cs @@ -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); }