I’m attempting to create a gesture handler that may detect each swipes/pans – inside one contact – in Unity. I ought to have the option, inside one contact occasion, to pan slowly to the left or proper. Throughout the identical contact, with out lifting my finger, I ought to be capable of then swipe to the left or proper. How do I do that? Right here is my code beneath.
non-public void Replace() {
if (Contact.activeFingers.Rely == 1)
{
swipeAllowed = true;
var contact = Contact.activeTouches[0];
// all collected touches should be transformed to display screen -> world level for use in calculations
if (contact.section == TouchPhase.Started)
{
startPos = Digicam.major.ScreenToWorldPoint(contact.screenPosition);
StartCoroutine(CheckForAnimation(contact));
}
if (contact.section == TouchPhase.Stationary)
{
DragAndDrop(contact);
}
if (contact.section == TouchPhase.Moved)
{
Debug.Log("moved");
currentPos = Digicam.major.ScreenToWorldPoint(contact.screenPosition);
StartCoroutine(DragOrSwipeCamera(startPos, currentPos, contact));
}
}
}
IEnumerator DragCamera(Vector3 startPos, Vector3 currentPos, Contact contact)
{
distance = currentPos - startPos;
var velocity = (float) (Vector3.Distance(currentPos, startPos) / (contact.time - contact.startTime));
// PSEUDOCODE: Based mostly on velocity, resolve whether or not it ought to be a drag or a swipe? Unsure what to do right here?
yield return null;
}
````