Input overlay to detect swipe movements
SwipeController initially utilizes old Unitys InputManager, but can be easely converted to use any input.
- Contains a bunch of presets: two-directions (like left-right), four directions, eight directions, hexagonal swipes.
- Can be easely configured (from code) to act with any number of directions.
- No-Code-Usage: just attach SwipeListener script onto gameobject, then find UnityEvents OnSwipe(string) and OnSwipeCancelled in Inspector.
- Same code for desktop (Mac, PC) and handheld (iOS, Android) versions.
How it works
In Update method, it looks onto Input events. When mouse button pressed (or touch started), it starts to wait, while pointer will be moved far enough to beat the treshold (based on sensetivity parameter). When it happened, OnSwipe event is invoked with a string parameter. In case when pre-defined preset (like FourDirections) is used, the parameter is one of pre-defined string constants of class DirectionId. If user releases button (or removed finger) without movement, or the movement is less than sensetivity treshold, OnSwipeCancelled event is fiered.
For set up the custom set of directions, you should call
Where is a List
Support me on Patreon: https://www.patreon.com/user?u=26313020&fan_landing=true
Subscribe on Games Garden channel on YouTube: https://www.youtube.com/channel/UCH6WybnFgT199Kkd6vm7-Lg
Games Garden web site: https://www.gamesgarden.net/