Author Topic: Tap and Swipe Recognition  (Read 3752 times)

binsint

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Tap and Swipe Recognition
« on: August 17, 2014, 03:37:32 AM »
Hi, im havng trouble with my project...

I have this big plane with a collider.... i want to perform action A if it is tapped(once finger begins contact with screen). and i also want to perform action B after swipe(needs detection after finger released from screen) on the same....

my problem is:
I cant perform the swipe since a swipe needs a "begin" touch... and it performs action A

my goal:
I need to do succesful swipe without action A performing... i need action A for "touch begin" and action B for "swipe" on the same collider...

Hope to hear from you guys.. Thank you and more power.

Binsint

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tap and Swipe Recognition
« Reply #1 on: August 17, 2014, 08:47:24 AM »
What is this regarding? There are touch recognition systems for Unity sold on Asset Store.

binsint

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Tap and Swipe Recognition
« Reply #2 on: August 17, 2014, 11:23:36 AM »
i have a runner game which i want to tap to JUMP... and swipe right to DASH... instead of dashing, player performs JUMP 1st if swiped.

here is my code:

  1. void OnPress(bool pressed)
  2.         {
  3.                 if(!GameManager.isGameOver)
  4.                 {
  5.                         if(pressed)
  6.                         {
  7.                                 startPos = UICamera.currentTouch.pos;
  8.                                //JUMP
  9.                         }
  10.                         else
  11.                         {
  12.                                 endPos = UICamera.currentTouch.pos;
  13.                                 if(endPos.x - startPos.x < 40f)  //DASH
  14.                         }
  15.                 }
  16.         }