TouchKit icon indicating copy to clipboard operation
TouchKit copied to clipboard

Pinch and Swipe together issues

Open Ladimaco opened this issue 7 years ago • 4 comments

I have added a swipe recognizer to my character, to move him around the screen.

I also added a pinch recognizer to zoom the camera in and out.

The problem I am running into is that occasionally, while zooming the camera, the character will recognize a swipe and start walking around. Any idea how to get the swipe recognizer to see that a pinch is in progress, and ignore any swipes it thinks it is detecting?

Any help is appreciated. -Larry

Ladimaco avatar Jul 21 '17 02:07 Ladimaco

I also have similar problems. when i add pan and swipe recognizer, i also get swipe and pan event, but i just want to fire one gesture on the same time , have you solved this problem ?

wangjianpeng avatar Aug 29 '17 06:08 wangjianpeng

IMO you'll want to address this concern at a "higher level". I tend to wrap all my subscribed gestures and other touch processing code into a single class that can have some concept of "game specific control state". Then I can make a determination of what to do central there based on the state the games controls are in (for example don't run swipe based movement code while zooming the camera with a pinch). This lets you isolate gesture recognition from game specific functionality.

The recognizers do not have knowledge of one another and that's actually a good thing for the flexibility it allows

darthbator avatar Aug 29 '17 06:08 darthbator

I have the same problem, I couldn't find a proper solution. In my case, I control my GameObject's rotation, scale with gestures. I also have UI elements on swipe. When I pinch to scale my GO, It tends to open the UI element frequently. I tried to control this by setting the maximumNumberOfTouches = 1 in the Swipegesture script, but it doesn't recognize swipe events after a certain time. I don't really know a way to control the gesture events by setting some kind of state in my case.

Arvin6 avatar Sep 11 '17 05:09 Arvin6

Raised a PR for this issue. We can add a maximum distance variable when checking for swipe. (Also set triggerWhenCriteriaMet = false) This solved my problem and works flawlessly.

Arvin6 avatar Sep 12 '17 08:09 Arvin6