Updating TouchSwipe & Introducing TouchDrag Next Week

[Update] November 26, 2024


Hi Creators!

We’re excited to announce that next week, we’ll be updating our TouchSwipe API and releasing a new TouchDrag API! Our goal is to support consistent input interfaces to unlock player interaction within your experiences.

:sunny: What’s changing?

Previously, the TouchSwipe API exhibited inconsistent behavior between touch-based Android and iOS devices by default, which was unintended. With this update, TouchSwipe will behave consistently across all devices, and we’ve added a new TouchDrag API to support additional touch behaviors.

:sound: What do you need to do?

If you are currently using TouchSwipe within your experience, there is no work needed on your end; this update should be similar to a bug fix. If you are not, we encourage you to check out both TouchSwipe and TouchDrag if they make sense for your experience. Please let us know if you spot any additional inconsistencies!


APIs

TouchSwipe and TouchDrag are both part of UserInputService, Roblox’s service that detects and captures the different types of input available on a user’s device. TouchSwipe and TouchDrag are both triggered on TouchEnabled devices, such as supported mobile phones and tablets.

TouchSwipe

Many of you may already be familiar with TouchSwipe and use this API in your experience! The TouchSwipe event fires on a TouchEnabled device when a user places their finger(s) down on the screen, pans across it, and lifts their finger at a certain speed. This event is used to detect these swipe gestures and the direction of the swipe.

Property Description
swipeDirection: Enum.SwipeDirection An Enum.SwipeDirection, indicating the direction the user swiped.
numberOfTouches: number Number of touches (e.g. fingers) involved in the gesture.
gameProcessedEvent: bool Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, gameProcessedEvent would be true. This is also true for input events connected via ContextActionService.

TouchDrag

The TouchDrag event fires on a TouchEnabled device when a user places their finger(s) on the screen and begins panning at a certain speed. The event is triggered the first time this speed is exceeded, even if the user has not lifted their finger yet. This event is useful for detecting the start of a directional drag gesture, allowing you to track finger movement along a specific axis.

TouchDrag can be used alongside TouchSwipe. For example, in a music app, TouchDrag could be used to detect when a user horizontally drags on a song to reveal context actions. Meanwhile, TouchSwipe could track the user’s finger fling to add the song to their queue.

The API for TouchDrag has been kept identical to TouchSwipe for compatibility and familiarity.

Property Description
swipeDirection: Enum.SwipeDirection An Enum.SwipeDirection, indicating the direction the user swiped.
numberOfTouches: number Number of touches (e.g. fingers) involved in the gesture.
gameProcessedEvent: bool Indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, gameProcessedEvent would be true. This is also true for input events connected via ContextActionService.

What’s Next

  • Unifying the other Touch APIs: We’re working on creating consistent behaviors across all touch-related APIs within UserInputService. Stay tuned for more updates, and let us know if there are any other bugs you spot!
  • Applying these changes to GuiObjects: We will be applying these same changes to the built-in touch functionality within GuiObjects.

:blue_heart: Made with love

Special thanks to @PotionSeller33, @NoUniqueAddress, @merlin_codes, and @MetaVars for their hard work on this feature! :clap:

138 Likes

This topic was automatically opened after 10 minutes.

This is going to be useful for my game (specifally since it’s for all devices, not just mobile)

now imagine doomscrolling in roblox…

16 Likes

These changes sound really cool! Making the touch APIs in UserInputService work the same way everywhere will make things so much easier for us. It’s great that Roblox is fixing this!

And adding these changes to GuiObjects too? Even better! Can’t wait to see how much smoother everything gets.

5 Likes

Gonna be amazing for my upcoming game :fire::fire:

5 Likes

Good update! Would be nice to have a way to test multi touch in studio, eg for zooming.

7 Likes

Will there be multi touch support?

3 Likes

That’s definitly useful for a lot of drag and fling actions on mobile and with the expanded support for GuiObjects and the consistency improvements across different devices I might give this a try in such cases.

3 Likes

Hey @Vexcent77, we currently have trackpad gestures on supported laptops, and you can use our Touch APIs to support multi-touch on mobile! We’re currently working on improvements to support more platforms – stay tuned here.

5 Likes

Yes!! Thanks Roblox! Finally great update

3 Likes

Could you please implement a way for us to detect if the touch gesture was on the thumbstick or not?
I think this is a crucial feature that’s missing.

6 Likes

Thank you!! I remember last time I implemented touch swipe/drag having to work around many related issues. Especially not being to easily distinguish CoreGui touchpad drags vs legitimate ones.

3 Likes

Will this support Touchpad for Play-Station Controllers?

1 Like

Are these functions coming to the mobile device emulator any time soon?

1 Like

thats nice and all but, how about this bug with UI Drag Detectors?

https://devforum.roblox.com/t/ui-drag-detector-doesnt-behave-in-mobile/3266399

1 Like

Hi @Apenz1, thank you for the feedback! Can you expand on what you mean?

1 Like

I believe he is talking about the movement button (AKA thumbstick) on phones/tablets.
So if the character was moving, would it register under the API and would you be able to check it?

3 Likes

For example:
I have a radial selection menu that is opened up using the right thumb. This can happen while the left thumb is interacting with the thumbstick. Now that the menu is open, I want to detect the position of the finger over the radial menu.

Issue is that a naive ‘mouse.Position’ implementation uses the finger that was last moved, leading to undesirable results. The radial menu selection will constantly switch between detecting either finger.

What I need is a way to ignore the touch input that is dragging the thumbstick. This way I can only listen to the position of the other touch(es).

For some reason the thumbstick interaction doesn’t sink input. Not sure why this is the case, since it does ‘work’ as an input sink?

Afaik there’s no way to actually implement this without some form of rewrite of the thumbstick movement code.

There’s probably other usecases this would be useful for.

2 Likes

Hi Creators!

We have fully released updates to the TouchSwipe API, as well as our new TouchDrag API! These are now both available on Studio & client.

If you are currently using TouchSwipe within your experience, there is no work needed on your end; this update should be similar to a bug fix. For all developers, we encourage you to check out both TouchSwipe and TouchDrag to see if they make sense for your experience. We’ve also included sample scripts in our documentation!

Note: we are aware of some bugs with Studio emulator not working as expected with the new TouchSwipe/TouchDrag API changes and are actively working on a fix.

We’re excited to see what you create!

3 Likes