Swipe detection

How could I detect a swipe. I am making a mobile game and would like for my character to jump when I swipe up. I’m aware there is an extension for this but it doesn’t seem to work properly.

This topic has an example of a project for working with this extension: Extension Swipe Detector

I’ve tried using that but it doesn’t seem to work all that well. It seems to work for clicks but when I try it on mobile it doesn’t work.

Have you tried changing the behavior settings (the time it takes to make a swipe; the minimum swipe length)?

yes, it seems to work properly with my mouse but not with touchscreen.

Strange, I checked on my smartphone (web version and Android version of the test project) and everything works. I can only advise you to increase the time and decrease the length of the swipe for testing and selecting values ​​that are convenient for you.
The algorithm itself in the extension is as follows:
1.Tracking touching the screen, as soon as this happened, remember the current coordinates (starting point), set the time variable to 0, and set a value that indicates that the swipe has started;
2. if the pile has started, then we add the elapsed time from the last frame (TimeDelta) to the time variable;
3. if the touch is over or the time variable exceeds the minimum (specified in the settings), then we calculate the length of the swipe and, if it is greater than or equal to the specified minimum length, then the swipe is completed.
The length and direction values ​​are calculated from the values ​​of the start and end points of the swipe.
All the code can be viewed in the extension itself.

Can you provide a screen shot of the events that deal with the swiping/clicking?


What I mean by clicking is just using my mouse as if I where swiping.

I also have cursor and touch separate.

Does the object left have the swipe behaviour attached?

And is that one line the only event you have for swiping?

What do you mean by this?

[edit]

Do you deactivate moving the mouse cursor with touches?

image

Yes it has the behavior and it is the only event.

I deactivated moving mouse cursor with touches

Activate the moving mouse cursor on touch. The swipe extension uses MouseX() and MouseY() to get the touch co-ordinates.

Instead, use Hide the Cursor action:

image

2 Likes