Yesterday, I has been needed in simple swipe-detection solution for one of my prototypes, and it turns out that there is no simple, effective and flexible solution over the web. Especially, which bugs me a lot, most of suggested scripts are ugly in code style - methods with a huge amount of lines, hardcoded values, ugly naming, etc.
So I found it easier to implement my own solution - and here it is at github.
Features:
- possible to use without of coding;
- extremely flexible;
- several built-in presets.
Try WebGL demo here:
http://bryarey.zzz.com.ua/SwipeController/index.html
What does it means "flexible"? Let me explain myself.
My solution based on comparsion of pointer movement vector with a set of Vector3 values, based on angle between. You can easely setup any number of any directions (even 3D!). So, it`s suitable for one-axis (left-right) swipe detection, for example, for runners; for 4 or 8 directions top-down games; for 6-directional hexagonal grid; for isometric (skewed) swipes detection.
In future, I plan to extend this system with XR input - for detect swipes in VR. And, of course, implement support of new Unity`s Input System.
Comments