mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
movement: improve code
This commit is contained in:
parent
a773df4905
commit
6a11335050
@ -16,11 +16,13 @@ void Update()
|
|||||||
if (!isLocalPlayer) return;
|
if (!isLocalPlayer) return;
|
||||||
|
|
||||||
// rotate
|
// rotate
|
||||||
transform.Rotate(0, Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime, 0);
|
float horizontal = Input.GetAxis("Horizontal");
|
||||||
|
transform.Rotate(0, horizontal * rotationSpeed * Time.deltaTime, 0);
|
||||||
|
|
||||||
// move
|
// move
|
||||||
|
float vertical = Input.GetAxis("Vertical");
|
||||||
Vector3 forward = transform.TransformDirection(Vector3.forward);
|
Vector3 forward = transform.TransformDirection(Vector3.forward);
|
||||||
agent.velocity = forward * Input.GetAxis("Vertical") * agent.speed;
|
agent.velocity = forward * Mathf.Max(vertical, 0) * agent.speed;
|
||||||
animator.SetBool("Moving", agent.velocity != Vector3.zero);
|
animator.SetBool("Moving", agent.velocity != Vector3.zero);
|
||||||
|
|
||||||
// shoot
|
// shoot
|
||||||
|
Loading…
Reference in New Issue
Block a user