mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
PlayerMove: Revised HandleTurning
This commit is contained in:
parent
96c7850cf5
commit
b8c62a1cd4
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user