How to Make Swipe Mechanic

How can I make a swipe mechanic in GDevelop? I’d like to make a character to go in the direction that the player has swiped in.

I think you would want to use a multitouch condition. Something like this maybe?

If touch has started { set Variable(swipe_start) to touch.X() }
If touch has ended { set Variable(swipe_end) to touch.X() }
if swipe_start > swipe_end {swipe right events}
if swipe_start < swipe_end {swipe left evens}

1 Like

I made this example GitHub - jumpingjh/Multitouch: Multituch Manage


thank you for making the example. however, i’m accessing this from my pc. is there a way to configure it with mouse click?

Instead of using touch started or ended, use mouse button pressed or released. And instead Touch X and Y, use Mouse X and Y position.

1 Like

If you want to run it on PC you can check my soccer game example GitHub - jumpingjh/Swipe-Soccer: Soccer GDevelop Game

1 Like