Hello forum ![]()
My problem is this. I am trying to differentiate between a tap and a swipe.
Lets say I want to move my camera with a swipe, no problem!
Or I want to tap and do something, again, no problem.
The problem is when I swipe and lift my finger it also counts as a tap.
So I thought of condition, but in my script once I do a swipe, the tap stops working ![]()
I did a lot search in google, but with no success ![]()
Is it there a proper way to distinguish between a swipe and a tap and not interfere with each other.
Here is my code in JS
And thank you for your time ![]()
private var Moved : boolean = false;
private var Began : boolean = false;
function Update () {
for (var i = 0; i < Input.touchCount; ++i) {
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
var hit : RaycastHit;
if (Input.GetTouch(i).phase == TouchPhase.Moved)
{
Moved = true;
}
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
Began = true;
}
if (Input.GetTouch(i).phase == TouchPhase.Ended) {
if (Began == true Moved == false ) {
Moved = false;
Began = false;
if (Physics.Raycast(ray,hit)) {
var gunRotate = GameObject.Find("gun_parent").GetComponent(Gun_Rotate);
gunRotate.Turn(hit.point);
cooldownGun();
explosionSphere();
SphereRestart();
Began = false;
Moved = false;
}
}
}
}
}