void Update() { // Movement Input Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); Vector3 moveVelocity = moveInput.normalized * moveSpeed; // normalized 는 방향을 가리키는 단위벡터로 만드는 연산이다 controller.Move(moveVelocity); // Look Input Ray ray = viewCamera.ScreenPointToRay(Input.mousePosition); Plane groundPlane = new Plane(Vector3.up, Vector3.up * gunController.GunHeight); float rayDistance; if (groundPlane.Raycast(ray, out rayDistance)) { Vector3 point = ray.GetPoint(rayDistance); Debug.DrawLine(ray.origin, point, Color.red); controller.LookAt(point); crosshairs.transform.position = point; crosshairs.DectectTargets(ray); if ((new Vector2(point.x, point.z) - new Vector2(transform.position.x, transform.position.z)).sqrMagnitude > 1) { gunController.Aim(point); } //print((new Vector2(point.x, point.z) - new Vector2(transform.position.x, transform.position.z)).magnitude); } // Weapon Input if (Input.GetMouseButton(0)) { gunController.OnTriggerHold(); } if (Input.GetMouseButtonUp(0)) { gunController.OnTriggerRelease(); } if (Input.GetKeyDown(KeyCode.R)) { gunController.Reload(); } }