[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.
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.
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.
Made with love
Special thanks to @PotionSeller33, @NoUniqueAddress, @merlin_codes, and @MetaVars for their hard work on this feature!