/// <summary> /// Rotates the camera around the object /// </summary> protected virtual void Rotation() { if (!RotationEnabled) { return; } if (Mode == Modes.Touch && (Input.touchCount > 0)) { if ((Input.touches[0].phase == TouchPhase.Moved) && (Input.touchCount == 1)) { float screenHeight = Screen.currentResolution.height; if (Input.touches[0].position.y < screenHeight / 4) { return; } float swipeSpeed = Input.touches[0].deltaPosition.magnitude / Input.touches[0].deltaTime; _angleX += Input.touches[0].deltaPosition.x * RotationSpeed.x * Time.deltaTime * swipeSpeed * 0.00001f; _angleY -= Input.touches[0].deltaPosition.y * RotationSpeed.y * Time.deltaTime * swipeSpeed * 0.00001f; _stepBuffer += Input.touches[0].deltaPosition.x; _angleY = MMMaths.ClampAngle(_angleY, MinVerticalAngleLimit, MaxVerticalAngleLimit); _desiredRotation = Quaternion.Euler(_angleY, _angleX, 0); _currentRotation = transform.rotation; _rotation = Quaternion.Lerp(_currentRotation, _desiredRotation, Time.deltaTime * ZoomDampening); transform.rotation = _rotation; } else if (Input.touchCount == 1 && Input.touches[0].phase == TouchPhase.Began) { _desiredRotation = transform.rotation; } if (transform.rotation != _desiredRotation) { _rotation = Quaternion.Lerp(transform.rotation, _desiredRotation, Time.deltaTime * ZoomDampening); transform.rotation = _rotation; } } else if (Mode == Modes.Mouse) { _angleX += Input.GetAxis("Mouse X") * RotationSpeed.x * Time.deltaTime; _angleY += -Input.GetAxis("Mouse Y") * RotationSpeed.y * Time.deltaTime; _angleY = Mathf.Clamp(_angleY, MinVerticalAngleLimit, MaxVerticalAngleLimit); _desiredRotation = Quaternion.Euler(new Vector3(_angleY, _angleX, 0)); _currentRotation = transform.rotation; _rotation = Quaternion.Lerp(_currentRotation, _desiredRotation, Time.deltaTime * ZoomDampening); transform.rotation = _rotation; } }