When i double Tap single Tap function also Executing..

Hi all,
I need help in this , I write jump function for Single touch, and Double touch for other function,
here the problem is when i double touch the single touch function also executing , here is my code.

void Update ()
    {
        //
        for(int i = 0; i < Input.touchCount; i++)
            {
                if(Input.GetTouch(i).phase == TouchPhase.Began)
                {
                   
                if(Input.GetTouch(i).tapCount == 1)
                {
                    if(isGameStart==true)
                    {
                        Jump();
                        _animator.enabled=true;
                       
                       
                        if (!this._animator.GetCurrentAnimatorStateInfo (0).IsName ("jumping1"))
                        {
                            _animator.SetBool("jumping",false);
                        }
                        else
                        {
                            _animator.SetBool("jumping",true);
                        }
                    }
                }
                if(Input.GetTouch(i).tapCount == 2)
                    {
                        print("Double Touch");
                        StartCoroutine(SlowMotion());
                    }
                }
            }
        }

Move the tapcount 2 if-statement above the tapcount 1, and change the tapcount 1 to an else-if.

You mean i have to put Double Tap Function First?

i think it’s better like this

if(Input.GetTouch(i).tapCount == 2)
{
//Double Tap
}
else if(Input.GetTouch(i).tapCount == 1)
{
//Tap
}

ya , ill try this.

No this one also not working.
Same problem. Any other solution?

check how many touches you have… I would kinda expect the first tap to make one touch (tapcount 1) and the second tap to make another touch (with tapcount 2). Since you’re looping through all touches you are triggering both functions. One on the first touch, the other on the second. It’s not logically possible for @kemar 's code to execute both branches with the same i value afterall.

Ya thats why i post this question here, i dont know how to loop?

if you wrote the code in the OP you already are, the for loop goes through each touch…

Ya i know, What is the solution plz, or any other way for single tap and double tap?

Here’s how i would do it, not saying that it’s good, but it could work (probably)

private float doubleTapTimer = 0.3;   //How much time we allow for the double tap
void Update ()
{
  for(int i = 0; i < Input.touchCount; i++)
  {
      if(Input.GetTouch(i).phase == TouchPhase.Began)
      {
        if(Input.GetTouch(i).tapCount == 1)
        {
          Invoke("singleTapAction", doubleTapTimer);
        }
        if(Input.GetTouch(i).tapCount == 2)
        {
            print("Double Touch");
            CancelInvoke("singleTapAction");
            StartCoroutine(SlowMotion());
        }
      }
  }
}
       
void singleTapAction(){
  if(isGameStart==true)
  {
      Jump();
      _animator.enabled=true;
    
    
      if (!this._animator.GetCurrentAnimatorStateInfo (0).IsName ("jumping1"))
      {
          _animator.SetBool("jumping",false);
      }
      else
      {
          _animator.SetBool("jumping",true);
      }
  }
}

ok ill try this.