PlayerMove: Revised HandleTurning

This commit is contained in:
MrGadget1024 2023-04-03 07:10:16 -04:00
parent 96c7850cf5
commit b8c62a1cd4

View File

@ -183,21 +183,18 @@ void HandleMoveState()
void HandleTurning() void HandleTurning()
{ {
// Q and E cancel each other out, reducing the turn to zero. // Q and E cancel each other out, reducing the turn to zero.
if (Input.GetKey(KeyCode.Q)) // If neither pressed, reduce turning speed toward zero.
turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
// If both pressed, reduce turning speed toward zero.
if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E)) if (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta); turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
else if (Input.GetKey(KeyCode.Q))
// If neither pressed, reduce turning speed toward zero. turnSpeed = Mathf.MoveTowards(turnSpeed, -maxTurnSpeed, turnDelta);
if (!Input.GetKey(KeyCode.Q) && !Input.GetKey(KeyCode.E)) else if(Input.GetKey(KeyCode.E))
turnSpeed = Mathf.MoveTowards(turnSpeed, maxTurnSpeed, turnDelta);
else
turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta); turnSpeed = Mathf.MoveTowards(turnSpeed, 0, turnDelta);
if (moveState == MoveMode.Sneaking) //if (moveState == MoveMode.Sneaking)
turnSpeed /= 3; // turnSpeed /= 3;
transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f); transform.Rotate(0f, turnSpeed * Time.deltaTime, 0f);
} }