Register simple 2 finger tap

How can register a 2 finger tap event anywhere on the screen. Working for iOS.

So far I’ve tried…

void Update () {
if (Input.touchCount == 2) {
Debug.Log (“2 finger tap”);
}
}

Problem is that this gets fired multiple times as it’s part of the Update() loop. Do I need to start tracking and storing individual TouchPhases or is there a simpler solution for sending just one event per 2 finger tap? (Looking for solution in code, not a 3rd party library)

Yes, use the touch phase. I would say, if it were me I’d try something like what you wrote but check that at least 1 is in the touch phase began (and maybe that the other isn’t in ‘ended’), and if that’s the case, I’d (“Do Whatever”). :slight_smile:

Note: My ‘touch’ experience is limited, but what I wrote sounds reasonable :slight_smile:

1 Like

Since it’s highly likely that both fingers will touch at different times, you also need to decide how long between touches you will allow. If you have one finger held for three seconds, then put down the second one, is that still a two finger tap?

So as previously described, the process is something like this:

  • Listen for Touch1
  • Touch 1 begins, start a timer and listen for Touch2
  • if timer > timeLimit, reset timer and start over waiting for Touch1
  • Touch2 begins, has Touch1 not ended && timer <= timeLimit? If so, two finger tap happened
  • reset timer and start over waiting for Touch1.

Good point on timing it :slight_smile:

1 Like