void Update() { if (GameCursor.isActivated) { if (PauseMenu.isPaused || STBInput.GetAxis("HorizontalRotate") != 0 || STBInput.GetAxis("VerticalRotate") != 0) { Destroy(cursor.gameObject); } } else { if (!PauseMenu.isPaused && (Input.GetAxis("Mouse X") != 0f || Input.GetAxis("Mouse Y") != 0)) { if (cursor == null) { cursor = Instantiate(cursorPrefab); } } } if (GameCursor.isActivated) { Ray ray = thisCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, LayerMask.GetMask("CursorDetector"))) { cursor.transform.position = hit.point; } if (Input.GetMouseButtonDown(0)) { cursor.SetFocus(true); } if (Input.GetMouseButtonUp(0)) { cursor.SetFocus(false); } } }
void LateUpdate() { //Movement Vector3 movement = Vector3.zero; float horInput = STBInput.GetAxis("HorizontalMove"); float verInput = STBInput.GetAxis("VerticalMove"); Matrix4x4 rotCamera = Matrix4x4.Rotate(Quaternion.Euler(0f, Camera.main.transform.eulerAngles.y, 0f)); if (horInput != 0 || verInput != 0) { movement.x = horInput * moveSpeed; movement.z = verInput * moveSpeed; movement = Vector3.ClampMagnitude(movement, moveSpeed); if (GameManager.IsDirectionAdjustOn) { float angle = Camera.main.AdjustAngle(transform.position, movement); Matrix4x4 adjust = Matrix4x4.Rotate(Quaternion.Euler(0f, angle, 0f)); movement = adjust * movement; } movement = rotCamera * movement; } if (GameCursor.isActivated) { Vector3 rotation = GameCursor.GetPosition() - transform.position; rotation.y = 0f; if (rotation != Vector3.zero) { Quaternion direction = Quaternion.LookRotation(rotation); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); } } else { float horRotInput = STBInput.GetAxis("HorizontalRotate"); float verRotInput = STBInput.GetAxis("VerticalRotate"); if (horRotInput != 0 || verRotInput != 0) { Vector3 lookDir = new Vector3(horRotInput, 0f, verRotInput); if (GameManager.IsDirectionAdjustOn) { float angle = Camera.main.AdjustAngle(transform.position, lookDir); Matrix4x4 adjust = Matrix4x4.Rotate(Quaternion.Euler(0f, angle, 0f)); lookDir = adjust * lookDir; } lookDir = rotCamera * lookDir; Quaternion direction = Quaternion.LookRotation(lookDir); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); } else if (movement.magnitude != 0f) { Quaternion direction = Quaternion.LookRotation(movement); transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); } } flame.CheckSpeed(movement); if (!charaController.isGrounded) { charaController.Move(new Vector3(0f, -9.8f, 0f) * Time.deltaTime); } movement *= Time.deltaTime; if (IsMovable) { charaController.Move(movement); } //Wingmen if (wingmen.Count != 0) { for (int i = wingmen.Count - 1; i >= 0; i--) { if (wingmen[i] == null) { wingmen.RemoveAt(i); } } } //Attack if (IsArmed) { timeFireRecharge += Time.deltaTime; if (STBInput.GetButton("Fire")) { if (timeFireRecharge > fireGap) { Fire(); } } else { timeFireRecharge = Mathf.Clamp(timeFireRecharge, 0f, fireGap); } } }