Distinguish between a tap and a hold on iOS

Just curious, but how do you distinguish between a tap and a hold on the iPhone. Just looking at the different keywords we have, I thought it might have something to do with TouchPhase.Began and TouchPhase.Stationary, but nothing I’ve tried works.

I’m trying to set up a timer through the update function that says GetMouseButton, timer += Time.deltaTime and then once the timer exceeds a certain value (0.7s) then it will be considered a hold but I can’t find a similar function for GetMouseButton via the Touch controls.

Whatever method I use, it will need to coexist with flick and double tap controls as well. :stuck_out_tongue:

Any suggestions or links to good iphone control resources?

This is the code that I’m juggling at the moment.

void Update()
{
  if(Input.touchCount > 0)
  {
     //start timer
     holdCount += Time.deltaTime;
     if(holdCount > 0.7f)
     {
        //input counts as a hold
        holdState = true;
        //User releases hold (works but reluctant to use as I've heard TouchPhase.Ended gets skipped a lot)
        if (Input.GetTouch(0).phase == TouchPhase.Ended)
        {
           //holdStuff happens & reset
           holdState = false;
           holdCount = 0;
           Debug.Log("Hold finished")
        }
     }
      else
        //input counts as tap
        if ((Input.GetTouch(0).phase == TouchPhase.Ended) && (holdState == false))
        {
           Debug.Log("Instantiate object");
           holdCount = 0;
        }
     }
}

I handle all touch stuff in an Update. Keep track of when a touch starts, and if it’s held past a certain amount of time, it’s a ‘long click’. Similar for double-tap, looking for touch begin/end and time between last end and next begin.