Search Unity

Input.Touches - Simple Gesture Solution

Discussion in 'Assets and Asset Store' started by Song_Tan, Apr 28, 2012.

  1. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Yes. Look for IT_Gesture.onPinchE. There's an example in OrbitCam.cs
     
  2. Casanuda

    Casanuda

    Joined:
    Dec 29, 2014
    Posts:
    53
    Hi,

    Hope you can assist.
    I am trying to differentiate between a drag and swipe/flick gesture to trigger different events.

    When I use swipe and drag in conjunction, the drag triggers the swipe.
    When I try use the isFlick bool, in never registers as true.

    Can you give any insight?

    Thanks
    Cas
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Swipe and drag are similar except swipe can be subjected to a minimum speed and distance check. You can really stop a drag event from firing when a swipe is taking place.

    Concerning isFlick, it is only set to true in the onDraggingEndE event, and only if the event doesn't take more than 0.5 seconds. You can change the value in DragDetector.cs, line 112. If you don't need the speed and distance check with the swipe, and only using onSwipeEndE, you can effectively replace swipe with drag event

    Hope that answer your questions.
     
  4. kulpajj

    kulpajj

    Joined:
    Aug 24, 2018
    Posts:
    11
    I am using Input.Touches, and using your OrbitCam Demo script as a model for my unity project. I am using the latest model of an Apple Magic Trackpad as my input, but single finger and multi finger drag are producing the exact same results: both move the camera around...thus far, I am not finding a difference in single vs multi-finger drag:

    The demo script is calling IT_Gesture.onDraggingE, not IT_Gesture.onMFDraggingE, but again, multiple fingers are causing the camera to move around. As a further test, I tried to employ DragInfo.fingerCount, but its the same issue.
    The following bits of code produce the exact same behavior:
    void OnDragging(DragInfo dragInfo)
    {
    if( dragInfo.fingerCount == 1 )
    {
    orbitSpeed = dragInfo.delta * orbitSpeedModifier / IT_Gesture.GetDPIFactor();
    }
    }

    void OnDragging(DragInfo dragInfo)
    {
    if( dragInfo.fingerCount == 2 )
    {
    orbitSpeed = dragInfo.delta * orbitSpeedModifier / IT_Gesture.GetDPIFactor();
    }
    }
     
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure what's going on here. The code won't call IT_Gesture.onDraggingE at all if the finger count of the dragInfo is >1. So your second set of code shouldn't be doing anything at all. Can I look at you full code?

    To clarify, there's multi-finger-drag and multi-drag. Multi-finger-drag involves a single drag input using multiple fingers. Multi-drag is multiple independent drag instances happen simultaneously. So even if you are using OnDragging, dragging multiple fingers across the screen will still trigger the event. You will probably want to disable the EnableMultiDrag option on DragDetector.
     
  6. kulpajj

    kulpajj

    Joined:
    Aug 24, 2018
    Posts:
    11
    ok thanks for the response! Let's just start fresh with what I am trying to accomplish. I want to use my trackpad on macOS and be able to differentiate between single finger input ( drag or slide around without click depressed ) and multiple finger input ( drag or slide around without click depressed ). Is this possible with this asset package? Sorry, I have checked out the demos and read the manual to some extent, but am just posting this question directly here. Thanks so much!
     
  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You should be able to. You will need to listen to both onDraggingE and onMFDraggingE. The former is for single finger input and the later is for multiple fingers input.
     
  8. kulpajj

    kulpajj

    Joined:
    Aug 24, 2018
    Posts:
    11
    I will try to play with these two methods and report back.

    In addition, backing up one step, I am trying to understand the OrbitCam demo. At least thus far, on this demo, neither pinch nor rotate are working for me. Pinch maximizes the Game Window, I think because Unity itself is using that gesture. And rotate doesn't do anything. So thus far, there is the zoom that works from Input.GetAxis("Mouse ScrollWheel"), and there is the ability to rotate the camera that occurs by both single and multi-finger drag.
     
  9. kulpajj

    kulpajj

    Joined:
    Aug 24, 2018
    Posts:
    11
    I have single vs multi finger drag working but I couldn't get it to work without calling the onMFDraggingE from within the onDraggingE, as it seems you did in the RTSCam demo:
    Code (CSharp):
    1.     void OnDragging(DragInfo dragInfo){
    2.         //if the drag is perform using mouse2, use it as a two finger drag
    3.         if(dragInfo.isMouse && dragInfo.index==1) OnMFDragging(dragInfo);
    4.         //else perform normal orbiting
    5.         else{
    6.             //apply the DPI scaling
    7.             dragInfo.delta/=IT_Gesture.GetDPIFactor();
    8.             //vertical movement is corresponded to rotation in x-axis
    9.             orbitSpeedX=-dragInfo.delta.y*rotXSpeedModifier;
    10.             //horizontal movement is corresponded to rotation in y-axis
    11.             orbitSpeedY=dragInfo.delta.x*rotYSpeedModifier;
    12.         }
    13.     }
    When the OnMFDragging method isn't embedded in the OnDragging method, nothing happens.
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I tested the scene on my phone and everything works as expected. Multi-finger doesn't work.

    I'm not sure what exactly is going on here but I have to say that's a possibility that it's the hardware you are using. As far as I'm aware not every multi-touch hardware is supported by Unity. If you have copied all the code from RTSCam as it's, I'm pretty sure that the code works because it's fired from mouse. That means some how a multi-finger drag is interpret as right-mouse input on your hardware..
     
  11. khrysller

    khrysller

    Joined:
    Mar 14, 2019
    Posts:
    125
    Hi @songtan. I am looking to buy an asset that do this:

    - When I tap the screen it shows a particle (that I already have) on screen in the tap x and y position.

    I found a way to tap and show the particle but I am struggling in showing it in the current x and y position. If your asset do that I am willing to buy it...

    Thanks
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The asset does not do that. It just detect various input which you have already figure out. What you need is more. It depends on your scene setting. The type of camera projection you are using and how far the particle has to be from the camera? It's not terribly complicated to be honest. I'm sure someone will be more than happy to do that for you for the amount of money you are willing to pay. You will be better off doing just that if this is the only thing you need.
     
  13. khrysller

    khrysller

    Joined:
    Mar 14, 2019
    Posts:
    125
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I posted a possible solution on your thread. Check it out. :)
     
  15. khrysller

    khrysller

    Joined:
    Mar 14, 2019
    Posts:
    125
    OMG... Dude... YOU ROCK...
    Thanks a lot,

    I know this isn`t part of your asset and still you helped me.... amazing....
    I will keep an eye on your stuff here...

    thanks again.:)
     
  16. Yiorgos

    Yiorgos

    Joined:
    Jun 5, 2013
    Posts:
    26
    Hello, I bought your asset 5 years ago (!!!) and I just happened to need it, but I cannot find any documentation or API reference. The official site link given in the asset store description https://www.songgamedev.com/inputtouches is wrong, the page is about Grid Defense. Can you point me to a url with documentation?

    PS: what I need is to map some gestures to specific keystrokes (eg, long press = ESC), I suppose that'll be an easy task with this asset, right?
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's a pdf documentation included with the package that should contain all the information you needed.

    If you need some example, just look at any of the demo script. TapDemo.cs in particular contains example for long press.
     
  18. Yiorgos

    Yiorgos

    Joined:
    Jun 5, 2013
    Posts:
    26
    Thanks, I'll take a look.
     
  19. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    865
    Hello guys, I have a question about swipe sensitivity, what is the proper way of handling that?
    I have Auto DPI scaling set for the device
    in editor works good but on the device is too sensitive. i am changing min distance, for example it works good in editor for values 30 but on the device (ipad pro) it is very sensitive
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You will have to use 2 sets of values if you have 2 devices with very different sensitivity. I'm afraid there is no other solution that I know of.