private void UpdateTouches() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); switch (touch.phase) { case TouchPhase.Began: Touches = new Queue <MobileTouch>(); CurrentTouch = new MobileTouch(touch, true); ReferenceCameraSnapshot.CopyFrom(ReferenceCamera); break; case TouchPhase.Moved: if (Touches.Count == 0 || Vector2.Distance(touch.position, CurrentTouch.Position) > DistanceBetweenTouches) { Touches.Enqueue(new MobileTouch(touch, true)); } break; case TouchPhase.Ended: Touches.Enqueue(new MobileTouch(touch, false)); break; } } }
public TouchPath(Transform player, Camera referenceCamera, float maxDistanceDelta = 1.5f, float distanceBetweenTouches = .02f, float rotationSpeed = .65f) { Touches = new Queue <MobileTouch>(); CurrentTouch = MobileTouch.InactiveTouch(); Player = player; ReferenceCamera = referenceCamera; ReferenceCameraContainer = new GameObject(); ReferenceCameraContainer.name = "Reference Camera Container"; ReferenceCameraSnapshot = ReferenceCameraContainer.AddComponent <Camera>() as Camera; ReferenceCameraSnapshot.tag = "Untagged"; ReferenceCameraSnapshot.depth = referenceCamera.depth - 1; DistanceBetweenTouches = distanceBetweenTouches; MaxDistanceDelta = maxDistanceDelta; RotationSpeed = rotationSpeed; }