diff --git a/Assets/Mirror/Examples/Movement/Scripts/Move.cs b/Assets/Mirror/Examples/Movement/Scripts/Move.cs index c8614656b..aacaff598 100644 --- a/Assets/Mirror/Examples/Movement/Scripts/Move.cs +++ b/Assets/Mirror/Examples/Movement/Scripts/Move.cs @@ -16,11 +16,13 @@ void Update() if (!isLocalPlayer) return; // 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 + float vertical = Input.GetAxis("Vertical"); 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); // shoot