void Update() { var input = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical")); if (Input.GetButton("Run")) { movement = runBehavior; } else { movement = walkBehavior; } movement.Update(input); // rotate the player to look in the direction of the input transform.LookAt( transform.position + Vector3.ProjectOnPlane(viewCamera.rotation * input, Vector3.up) ); player.Move(movement.RelativeTo(viewCamera)); }