- Home /
 
               Question by 
               Rhylvin2015 · Jul 28, 2015 at 09:39 AM · 
                inputtouchtapholddouble-tap  
              
 
              codes for detecting mobile double tap and hold
hello i have 2d game that i want it to detect a mobile double tap and hold can anyone give me an idea or maybe a full c# script?
               Comment
              
 
               
              Answer by Nido · Jul 28, 2015 at 01:24 PM
For double tap: http://answers.unity3d.com/questions/369230/how-to-detect-double-tap-in-android.html
For hold:
 private float holdTime = 0.8f; //or whatever
 private float acumTime = 0;
 
 void Update()
 {
    if(Input.touchCount > 0)
    {
        acumTime += Input.GetTouch(0).deltaTime;
 
        if(acumTime >= holdTime)
        {
            //Long tap
        }
 
        if(Input.GetTouch(0).phase == TouchPhase.Ended)) 
        {
            acumTime = 0; 
        }
    }
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                