public void ProcessMessage(InputMessage message) { if (message.InputType != InputMessage.InputTypes.OneFingerDrag) { return; } if (message.MessageType == InputMessage.MessageTypes.Update || message.MessageType == InputMessage.MessageTypes.Begin) { _raycast.Invalidate(); Vector2 delta = message.FingerDeltas[0]; //Debug.Log(string.Format("mag: {0}, didHit: {1}", _input.Delta.magnitude, _raycast.DidHit)); if (delta.magnitude > _startThreshold && _raycast.DidHit) { float angle = AngleMath.AngleSigned(Vector3.forward, _targetCamera.transform.forward, Vector3.up); _worldDelta = Quaternion.AngleAxis(angle, Vector3.up) * FlexiUtils.SwapYZ(message.NormalisedFingerDeltas[0]) * (_panFactor * _raycast.Distance) * (_invert ? -1f : 1f); _worldDelta = Vector3.ClampMagnitude(_worldDelta, _deltaClamp); float distance = Vector3.Distance(_center, _raycast.HitPoint); if (_limited && distance > _limitStart) { float overshoot = (distance - _limitStart); float factor = 1f - Mathf.Clamp((overshoot / _limitEnd), 0f, 1f); float a = Vector3.Angle(_worldDelta.normalized, -_raycast.HitPoint.normalized); if (a > 90f) { _worldDelta *= factor; } } _deltaPos = _worldDelta; _pendingUpdate = true; message.Use(); } } else { if (_worldDelta.magnitude > _startThreshold) { Vector3 mod = _worldDelta; _worldDelta *= _dampingFactor; _deltaPos = mod; _pendingUpdate = true; return; } } }