Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Swipe in all directions Touch and Mouse

$
0
0
Hi Everyone!

I had trouble finding good information how to get out swipes in different directions, so I fixed one to share to the community!
Feel free to tweak the "0.5f" number to get the right feel for how narrow you want to detect the swipe.

This is for ONE touch, you can add several touches by using a foreach and loop through the Input.touches.

Code is in C#.

Touch:

Code (csharp):
  1.  
  2. //inside class
  3. Vector2 firstPressPos;
  4. Vector2 secondPressPos;
  5. Vector2 currentSwipe;
  6.  
  7. public void Swipe()
  8. {...
Swipe in all directions Touch and Mouse

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>