I'm creating a touch controlled game that rotates platforms as you touch and drag however I can't get it to ignore touches over the jump button causing it to think that you've very quickly moved the same finger over it as one long swipe. I've tried tracking the start point and id however I've realised that none of these will work without a way to detect whether the touch is over the jump button.
My code for detecting touches:
int x = 0;
while (x < Input.touchCount)
{
Touch touch = Input.GetTouch(x); // get the touch
if (touch.phase == TouchPhase.Began) //check for the first touch
{
fp = touch.position;
lp = touch.position;
}
else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved
{
lp = touch.position;
}
else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen
{
lp = touch.position; //last touch position. Ommitted if you use list
}
if (!EventSystem.current.IsPointerOverGameObject(x))
{
int movement = ((int)(fp.x - lp.x));
if (previous_fp != fp ^ x != previous_id)
{
previous_rotate = 0;
}
previous_fp = fp;
previous_id = x;
if (!game_over) { Platform_Control.transform.Rotate(0f, 0f, -((movement - previous_rotate) * 0.15f), Space.World); }
previous_rotate = movement;
}
x++;
}