mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix(TankControllerBase): Turning is now persisted when AutoRun is enabled.
This commit is contained in:
parent
e467be0d90
commit
d67a087265
@ -246,13 +246,17 @@ void HandleTurning(float deltaTime)
|
||||
{
|
||||
float targetTurnSpeed = 0f;
|
||||
|
||||
// Q and E cancel each other out, reducing targetTurnSpeed to zero.
|
||||
// TurnLeft and TurnRight cancel each other out, reducing targetTurnSpeed to zero.
|
||||
if (moveKeys.TurnLeft != KeyCode.None && Input.GetKey(moveKeys.TurnLeft))
|
||||
targetTurnSpeed -= maxTurnSpeed;
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user