void Update() { if (Input.GetKeyDown(KeyCode.P)) { if (IsInputEnabled()) { DisableInput(); } else { EnableInput(); } } if (_currentMode != Mode || _input == null) { InitializeFreeCamInput(); } _input.Update(); //Update the target rotation if (_input.ShouldRotate()) { _targetLookEuler.y -= _input.GetPrimaryDelta().x *Time.deltaTime *RotationSensitivity.x *_sensitivity; _targetLookEuler.x += _input.GetPrimaryDelta().y *Time.deltaTime *RotationSensitivity.y *_sensitivity; } if (_targetLookEuler.x > 90) { _targetLookEuler.x = 90; } if (_targetLookEuler.x < -90) { _targetLookEuler.x = -90; } //Update the target position if (_input.ShouldDrag()) { float scaleFactor = Mathf.Clamp(Mathf.Abs(_actualZoom) / PositionalZoomScale, 1, float.MaxValue); _targetMovePosition += transform.up * _input.GetPrimaryDelta().y *Time.deltaTime *PositionalSensitivity.y *scaleFactor *_sensitivity; _targetMovePosition += transform.right * _input.GetPrimaryDelta().x *Time.deltaTime *PositionalSensitivity.x *scaleFactor *_sensitivity; } //Update the target zoom _targetZoom -= _input.GetZoomDelta() * Time.deltaTime * ZoomSensitivity * ZoomFollowCurve.Evaluate((Mathf.Abs(_targetZoom) / ZoomFollowCurveStart)); _targetZoom = Mathf.Clamp(_targetZoom, MinZoom, MaxZoom); //When mid mouse is released and if it was released within the 'click' threshold, //raycast from the currnet mouse position to try and find an object to center on if (_input.ShouldCenterOnTarget()) { var ray = ChildCamera.ScreenPointToRay(Input.mousePosition); var hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, 1000, CenterClickMask)) { _targetMovePosition = hit.collider.transform.position; } } }