Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. foreach (Touch t in Input.touches)
  2. {
  3. if (t.phase == TouchPhase.Began)
  4. {
  5. initialTouch = t;
  6. }
  7. else if (t.phase == TouchPhase.Moved && !hasSwiped)
  8. {
  9. float deltaX = initialTouch.position.x - t.position.x;
  10. float deltaY = initialTouch.position.y - t.position.y;
  11. distance = Mathf.Sqrt((deltaX * deltaX) + (deltaY * deltaY));
  12. bool swipedSideways = Mathf.Abs(deltaX) > Mathf.Abs(deltaY);
  13.  
  14. if (distance > 100f)
  15. {
  16. if (swipedSideways && deltaX > 0 && keyHit == false && krayLeft == false) //swiped left
  17. {
  18.  
  19. }
  20.  
  21. else if (swipedSideways && deltaX <= 0 && keyHit == false && krayRight == false) //swiped right
  22. {
  23.  
  24. }
  25. else if (!swipedSideways && deltaY > 0) //swiped down
  26. {
  27.  
  28. }
  29. else if (!swipedSideways && deltaY <= 0 && keyHit == false) //swiped up
  30. {
  31.  
  32. }
  33. hasSwiped = true;
  34. }
  35. }
  36. else if (t.phase == TouchPhase.Ended)
  37. {
  38. initialTouch = new Touch();
  39. hasSwiped = false;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement