Hello Everyone!
I have a problem with my JS. I’m working on a mobile app and i’d like to use Touches for detecting if the touch is held or if it’s ended by the time the collision happens.
Here’s my code:
function Update () {
var count = Input.touchCount;
if (trigger == true) { //Var trigger is controlled by OnTriggerEnter
for(var i : int = 0; i < count; i++)
{
if (Input.GetTouch(i).phase == TouchPhase.Stationary)
{
Debug.Log("Held");
}
if (Input.GetTouch(i).phase == TouchPhase.Ended)
{
Debug.Log("Lifted");
}
}
trigger = false;
}
}
Stationary is working but the Problem is that if i’ve lifted my finger from the screen, count is 0 and the for loop doesn’t even start. I can’t find the workaround for that. Could you please help?
Thank You!