I’m trying to push an object in the direction of the user’s swipe in my Android game. This is the code I’m using. It doesn’t seem as though TouchPhase.Ended is ever called, though. Does anyone know what’s up?
function Update () {
for (var touch : Touch in Input.touches) {
if (touch.phase == TouchPhase.Began) {
startPos = touch.position;
if (touch.phase == TouchPhase.Ended) {
endPos = touch.position;
rigidbody.AddForce(Vector3(endPos.x-startPos.x,endPos.y-startPos.y,0) * 500 );
myGUI.text = (endPos.x-startPos.x).ToString() + " " + (endPos.y-startPos.y).ToString();
}
}
}
}