how to detect double tap in unity code example
Example: how to detect double tap in unity
var tapping : boolean;
var LastTap : float;
var tapTime : float;
function Update(){
if(Input.GetKeyDown("f")){
if(!tapping){
tapping = true;
SingleTap();
}
if((Time.time - LastTap) < tapTime){
Debug.Log("DoubleTap");
tapping = false;
}
LastTap = Time.time;
}
}
function SingleTap(){
yield WaitForSeconds(tapTime);
if(tapping){
Debug.Log("SingleTap");
tapping = false;
}
}