Noticing touch vs swipe

Hi Guys,

how would I notice the difference between a touch (a ball is shot for example) or a swipe (an object is rotated instead of the ball beeing shot). Is it simply checking touch.Phase == Began in FrameA and touch.Phase == Ended in FrameB to determine a touch vs a swipe? What’s your experience?

Kind regards

You can check the movement delta on touch.Phase == Ended.
If its 0 you dragged or touched.
If not the input was a swipe.

(i hope i don’t miss understand what exact is a swipe)

Yeah that sounds like a great idea, but still, if you only check that on “ended” you would still be able to swipe and afterwards, if you didn’t move anymore, shoot a ball because it thinks you didn’t move. Maybe something like this:

bool touched = false;
bool checkTouch = false;
bool swiped = false;
Vector2 delta;


void update(){
if(Input.touchCount != 0){
    if(input.GetTouch(0).Phase == Began) {
          checkTouch = true;
          touched  = false;
          swiped = false;
          delta = Vector2.zero;
     }
      else if(Input.GetTouch(0).Phase == Ended  delta == Vector2.zero){
          touched = true;
    }
    else if(Input.GetTouch(0).Phase == Moved){ 
          delta += Input.GetTouch(0).deltaPosition;
          touched = false;
          swiped = true;
    }

    if(touched)
             doTouched();

     if(swipe)
              DoSwipe();

but maybe another possibility would be to make it sort of check between a timer if the item has not moved (for example, 0.2 seconds) and then act as “touched”, and maybe “touchRepeat”.

just set the current touch position in a vector2 on start. Then on end set a different one. Do a Vector2.Distance and if its bigger than whatever distance you want, its a swipe.

Sounds like a reasonable solution!