How to detect a double tap touch gesture.

I seem to be unable to detect a double touch, it interferes with the slide gesture implemented already.

using UnityEngine;
using System.Collections;

public class SlideToMove_02 : MonoBehaviour
{
    private Touch initialTouch = new Touch();
    private float distance = 0;
    private bool hasSwiped = false;
    public float speed = 5;
   public static Rigidbody2D coby;
   Quaternion origRotation;
    Animator anim;

	void Awake()
	{
		
		Debug.Log ("Awake");
	}

	void Start()
    {
        anim = GetComponent<Animator>();
        coby = GetComponent<Rigidbody2D>();
        origRotation = transform.rotation;
    }

    void Update()
    {

        #region Tap to rotate
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint((Input.GetTouch(0).position)), Vector2.zero);
            if (hit.collider != null)
            {
                Debug.Log("Touched it");
                transform.Rotate(0, 180, 0);
            }
        }
        #endregion*/
    }

    void LateUpdate()
    {
        CheckBounds();
    }


    void FixedUpdate()
	{
		#region Computer Input
		float h = Input.GetAxis ("Horizontal");
		float v = Input.GetAxis ("Vertical");
		Vector2 move = new Vector2 (h, v);
		coby.AddForce (move * speed / 2);
		#endregion

		#region Touch Input
		foreach (Touch t in Input.touches) {
			if (t.phase == TouchPhase.Began) {
				initialTouch = t;
			} else if (t.phase == TouchPhase.Moved && !hasSwiped) {
				float deltaX = initialTouch.position.x - t.position.x;
				float deltaY = initialTouch.position.y - t.position.y;
				distance = Mathf.Sqrt ((deltaX * deltaX) + (deltaY * deltaY));
				bool swipedSideways = Mathf.Abs (deltaX) > Mathf.Abs (deltaY);
                

				if (distance > 10f) {
					if (swipedSideways && deltaX > 0) { //swiped left
						transform.rotation = origRotation;
						coby.AddForce (new Vector3 (-100f, 0f, 0f) * speed * Time.deltaTime);
						transform.Rotate (0, 180, 0);
						//anim.SetTrigger("SwipeLeft");
					} else if (swipedSideways && deltaX <= 0) { //swiped right
						coby.AddForce (new Vector3 (100f, 0f, 0f) * speed * Time.deltaTime);
						transform.rotation = origRotation;
						//anim.SetTrigger("SwipeRight");
					} else if (!swipedSideways && deltaY > 0) { //swiped down
						transform.rotation = origRotation;
						coby.AddForce (new Vector3 (0f, -100f, 0f) * speed * Time.deltaTime);
						transform.Rotate (90, 0, 0);
						//anim.SetTrigger("SwipeDown");
					} else if (!swipedSideways && deltaY <= 0) {  //swiped up
						transform.rotation = origRotation;
						coby.AddForce (new Vector3 (0f, 100f, 0f) * speed * Time.deltaTime);
						transform.Rotate (270, 0, 0);
						//anim.SetTrigger("SwipeUp");
					}
                    
					hasSwiped = true;   
				}

			} else if (t.phase == TouchPhase.Ended) {
				initialTouch = new Touch ();
				hasSwiped = false;
			}
		}
		#endregion
    }

  //Screen Wrapping	 done
    void CheckBounds()
    {
	        if (this.transform.position.x <= -9.11f)
	        {
	            this.transform.position = new Vector3(9.11f, this.transform.position.y, 0);
	        }
	        if (this.transform.position.x > 9.11f)
	        {
	            this.transform.position = new Vector3(-9.11f, this.transform.position.y, 0);
	        }
	        if (this.transform.position.y <= -5.6f)
	        {
	            this.transform.position = new Vector3(this.transform.position.x, 5.6f, 0);
	        }
	        if (this.transform.position.y > 5.6f)
	        {
	            this.transform.position = new Vector3(this.transform.position.x, -5.6f, 0);
	        }
    }
}

Do you have separate screen space for the double tap? That would be one way to separate them.

Really though when the touchphase starts start adding to a touch float (you’ll need a float for each possible touch. Let’s say touch[0] is your drag touch so in Update test if touch count is greater than 0 and if so add Time.deltaTime to each float e.g.

private float[] touchLength;

When the touch ends if that time is less than, say .25f it qualifies as a tap so call a Tap function and record the lastTap time and reset that array float to zero.

In update check for lastTap is not 0 and if lastTap +.5f is less than Time.time.

If it is (higher than lastTap + 0.5f) call a DoTap function to passing it a bool of false.

If another tap happens before Time .time > lastTap + .5f then call the DoTap function with a positive bool. You could do this in your Tap function

if(Time.time < lastTap + 0.5f)
     DoTap(true);

DoTap with negative does a single tap and with a positive does a double tap. You’ll have to test the timings to see what works and I’ve kind of written the script in my head but not in here. Remember to reset the floats (when touch ends) and lastTap (if it’s more than half a second gone by or whatever time works for you).

I have a really easy solution

 void LateUpdate()
    {
  if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
        {
            tapCount += 1;
            StartCoroutine(Countdown());    
        }
      
        if (tapCount == 2)
        {    
            tapCount = 0;
            StopCoroutine(Countdown());
          ///////// DO STUFF!!   
        }

    }
    private IEnumerator Countdown()
    { 
            yield return new WaitForSeconds(0.3f);
            tapCount = 0;  
    }

,I have a really easy solution

 void LateUpdate()
    {
  if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
        {
            tapCount += 1;
            StartCoroutine(Countdown());    
        }
      
        if (tapCount == 2)
        {    
            tapCount = 0;
            StopCoroutine(Countdown());
            
          //// DO STUFF!
        }

    }
    private IEnumerator Countdown()
    { 
            yield return new WaitForSeconds(0.3f);
            tapCount = 0;  
    }

What you want to do is to have a script that will detect the first touch and then wait until either another touch is detected or nothing happens if there is another touch while the script is waiting you can get a double tap effect you may also have to track the fingers to ensure that the same finger touched twice