Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pinch and Swipe together issues #58

Open
Ladimaco opened this issue Jul 21, 2017 · 4 comments
Open

Pinch and Swipe together issues #58

Ladimaco opened this issue Jul 21, 2017 · 4 comments

Comments

@Ladimaco
Copy link

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

@darthbator
Copy link
Contributor

darthbator commented Aug 29, 2017

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

@Arvin6
Copy link
Contributor

Arvin6 commented Sep 11, 2017

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
Copy link
Contributor

Arvin6 commented Sep 12, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@darthbator @Arvin6 @Ladimaco and others