Search Unity

[RELEASED] FingerGestures - Robust input gestures at your fingertips!

Discussion in 'Assets and Asset Store' started by Bugfoot, Jul 8, 2011.

  1. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Slightly more complex question. I want to publish both to tablets and web, on web I'd like to change some of the gestures to mouse buttons, e.g drag becomes RMB, I assume I'm going to have to hack this in myself, any slick ways to do something like that?
     
  2. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Well if you go with the default gesture recognizers (option A aka "basic method"), FingerGestures creates the gesture recognizer objects for you so you don't have to do it, and holds them in the root FingerGestures singleton object in your scene. I did it this way to keep a certain consistency with the previous versions, and it's also easier to setup and get up and running quickly with this approach, without having to dig too deep in the code.

    I personally prefer the Option B (aka "advanced method") where I add new gesture recognizers to my scene and directly reference and manipulate them though code. It gives more flexibility and complete control over each gesture recognizer settings.
     
  3. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    It depends on exactly what you're trying to achieve. If you're sticking with the default gestures API, you can actually give a different Gesture Prefabs List object to the "Mouse Gestures" prefab, where you can change the Drag Gesture recognizer to a custom one, and this one will be used by the default drag gesture events instead. By default, FingerGestures use the same Default Gestures Prefab list on both touch screen (TouchScreenGestures prefab) and desktop (MouseGestures prefab).

    If you want to go the advanced way (option B), you could write a custom script to instantiate a different gesture recognizer at runtime, based on the current platform. One for touch screen, one for mouse.
     
  4. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
    Hey Spk,

    Had a look at the mouse code can see nothing obvious and my c# skills are a bit new :)
    Basically if you go from 1 scene to another and initialise a new finger gesture per scene the mouse coordinate held (at the time of scene change) seems to get messed up in the next scene unless you release the button and re-click.
    Hope that helps.

    Cheers
     
  5. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Well it's probably because the internal finger data structure is rebuilt, and reinitialized each time you load a new scene, when using non-persistent FingerGesture singleton. I'll see what I can do, but i cant promise anything. This is a very special edge case scenario...
     
  6. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
    Hi Spk,

    Thanks!; strange how it seems fine with touch gestures though....

    Cheers

    EDIT: It didn't work at all with just 1 singleton persistent finger initialiser ; because of the original error I mention being issued.
     
  7. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Is it possible to use this library with TUIO?
    Does it support Windows 7 touch?

    Sorry didn't have a change to buy your library. I'm just browsing C# "javadoc" and got a couple more questions: Is there a concept of touch belonging to some GameObject? In other words, how do I understand if this touch/gesture happened with specific object? How do you process touches for gestures when moe then 2 touches are active? For example 3 fingers pinch gesture. Do you ignore all but first two ones or generate some kind of point clusters there?

    The reason I'm asking these questions is that I am a multi-touch developer myself. I posted the link to our latest project lately: http://vimeo.com/30006025. Trying to figure out if your library is good to use.
     
    Last edited: Oct 8, 2011
  8. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Are you referring to this? In which case, that's the first time I hear about it, going to read up on this ;)

    This entirely depends on whether the Unity engine supports it or not. I haven't explicitly added support for Win7.

    The core FingerGestures API provides low level gesture detection, so it's up to you to use that however you want. The package includes a Toolbox folder that contains a bunch of higher level scripts that you can use to achieve this though. It does this by casting a ray into the scene to find if there's any object at the finger touch position.

    It depends ;) By default, the gesture recognizers are setup to only only fire if an exact number of fingers is touching the screen, no less no more. However, you can change this behaviour to enforce your own rules using GestureRecognizer.TouchFilter and GestureRecognizer.CanBeginDelegate.

    Your project looks great, pretty cool UI and input you're got going here ;) Are these touch-screens, or are the gestures detected by video/image processing?
     
    Last edited: Oct 8, 2011
  9. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes, TUIO is used in many multi-touch interfaces.

    Fingers are detected from infrared camera output. They are sent to the application using TUIO.

    Thanks for answering the questions. I see that your library is targeting devices. That's cool. But with large displays you'd see this approach is quite naive.
     
  10. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Well, it would work fine as long as your input device can tell the library that "finger X touched at pos X and moved to Y". I'm not familiar with how your particular device works, or what your exact needs are, but the library provides a layer of abstraction by using "fingers" to detect gestures. So as long as you can feed the correct finger data in there, the rest should work fine. Unless i'm missing something obvious?
     
  11. ChaosGaming

    ChaosGaming

    Joined:
    Oct 26, 2010
    Posts:
    65
    Hi, is it possible to use the swipe command to detect and read any direction rather than just up, down, right and left?
     
  12. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Yeah, just use the drag gesture instead.
     
  13. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Hi Spk, having read through this thread I haven't seen any questions asked about how things are handled when using different packages relying on input. For example if I want to use EZ GUI for my UI but still allow Finger gestures to process other input gestures. Can they play nicely together without stepping on each other?

    iByte
     
  14. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    @iByte: well it sort of depends on what you want to do. If you want to prevent gesture recognizers from kicking in when the user interacts with UI elements, you can provide a custom "CanBeginDelegate" method on the gesture recognizers you want to block. Alternatively, you can also turn gesture recognizers on off (using their "enabled" property). There are quite a few options to go about it. I've been using FingerGestures in my own projects, where I also use EZGUI, and haven't ran into any particular troubles.

    If you have a specific use case in mind, I can elaborate further.
     
  15. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Spk, thanks for the info. I wanted to check that there wasn't any known direct conflicts. I know that EZ GUI can detect/report non GUI inputs. I thought perhaps there was some kind of input chain (manager) that programs subscribed to etc ..

    I'll post if I run into any difficulties

    Thanks

    iByte
     
  16. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Yeah please do let me know, so I can tweak the library to make this easier in future versions.
     
  17. monkeyshines

    monkeyshines

    Joined:
    Oct 10, 2011
    Posts:
    2
    Hello,

    I'm not the strongest programmer. But, I payed my money and I'm forging ahead with fingerGestures to create UI with meshes.

    I'm looking for help using fingerGestures and javascript.

    So, I have "javascriptSkeleton.js" firing on the iOS devices no problems. I can get all the functions to print to Debug.log too!

    What I'm stuck on is a iOS friendly way of detecting which mesh the gesture is over. Picking apart the C# examples has left me confused.

    Can someone shed light or a little pickObject.js sample code?

    Thanks!
     
  18. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hi Monkeyshines,
    Thank you for picking up FingerGestures, I hope you will find it useful.

    I've attached a quick javascript sample that does what you are describing. Put it on a new empty object in your scene, and it should print some text when you press on any solid object (it's listening to FingerGestures.OnFingerDown event). You can optionally give it a GUIText object if you want to display the message directly on the screen.

    Let me know if you have any questions.
     

    Attached Files:

  19. monkeyshines

    monkeyshines

    Joined:
    Oct 10, 2011
    Posts:
    2
    That's it!

    Thanks for the support.

    Sincerely,

    A Happy Customer
     
  20. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Hi Spk,
    Just one question, we need to be able to use the orbit function to rotate around one object and then tap on another to switch to orbit around that. Will this kind of camera orbit function be straight forward to implement using FingerGestures?

    Many thanks in advance,

    Faye
     
  21. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Yeah, should be pretty straightforward... You'll need to a bit of extra coding, but it's simple stuff: raycast the object under the finger from the tap event, and change the OrbitCamera target to this object.
     
  22. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Thanks for the swift response Spk,
    I've just dealt with some scripts recently that make it hard to implement this kind of thing.

    Looking forward downloading!
     
  23. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Just let me know if you are having any troubles, I will help you out.
     
  24. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Thanks Spk,
    does it require 3.4.1 upgrade?
     
  25. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I think the Asset store requires this version for the download yeah, but if you already have the package it should work on previous version too.
     
  26. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    I'm not sure what we're doing regarding upgrade, is there anyway to download without for the time being?
     
  27. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Not at this point, no. As a possible workaround, you could install a temporary 3.4.1 unity version on another machine, download it from there, and export it as a package to your own dev machine.

    It is a bit stupid that the asset store requires the latest unity version to download the package, as FingerGestures can work with older versions of Unity just fine.Would be nice to be able to select the minimum supported version.
     
    Last edited: Oct 12, 2011
  28. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Agreed, Spk.
     
  29. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    I wondered what the best way to enable pinch/zoom into a target object combined with drag/orbit around it?
    At the moment they act independently because I'm guessing they alter the camera's position in isolation?

    Looking for FingerGestures code combination tips for achieving something seamless.

    Thanks in advance,

    Faye
     
    Last edited: Oct 12, 2011
  30. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Hello Spk!

    I have updated FingerGesture to version 2.0 and I have a big problem now:
    using TBDragOrbit all works fine but if I try to use TBPinchZoon my mouse wheel don't do any zoom.

    This appen in your examples and in my application.
    I have tryed this on 2 pc and result is the same... I am becoming crazy because all works fine with version 1.4.

    Is required any Unity3D special configuration to use mouse wheel zoom example?

    Can you give me some help?

    Thanks
    Kenshin
     
  31. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hi Kenshin,
    Hm, I must have forgot to mention this in the 2.0 release notes. I broke the mousewheel pinch support in the new version. I will try to provide a fix for this within the next few days. In the meanwhile, you can try to emulate it by manually calling the Pinch_OnMove callback with a "delta" set to the value of Input.GetAxis( "MouseWheel" ). Sorry for the inconvenience, this was a big update and it slipped off-radar...
     
  32. parnell

    parnell

    Joined:
    Jan 14, 2009
    Posts:
    206
    Hi Spk.
    I haven't been following this thread recently (as it's just gotten so large! Congrats!) but I bought this package for hopes that you'd integrate in gesture recognition. Is that in yet? If it isn't, will your package work with the other package on the Asset Store that does offer gesture recognition? (ie: records a gesture motion like writing a symbol)
    Thanks
    B
     
  33. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    This is a feature I've got on my roadmap, but it's not available right now and I don't have any ETA to offer you at this point. As for FingerGestures working with other asset store packages out of the box, I cannot give any grantees on this as I haven't tried myself.
     
  34. parnell

    parnell

    Joined:
    Jan 14, 2009
    Posts:
    206
    I sent you a PM.
    thanks again!
    B
     
  35. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Hi Spk,
    you have done a very good work with this package!
    I will try to emulati it but please, don't forget to do this update soon. :)
     
  36. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Thank you ;) As I said, I will do my best to have this out before monday.
     
  37. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Just chiming in to say this is great stuff; well worth the price!

    Thanks to William for "getting it" when it comes to Unity extensions :)
    (others could take note!) :)
     
  38. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Glad you enjoy the package, Joe! And thanks for the ego-boost ;)
     
  39. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Hello Spk,
    Got a question for you. Using the TBOrbit sample, are you able to make it so that you don't need to use the Y Clamp so that you can rotate the camera free around the target object?

    Many thanks,
     
  40. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You could comment out the following line in the FingerGestures_OnDragMove method in TBDragOrbit.cs:

    Code (csharp):
    1. y = ClampAngle( y, yMinLimit, yMaxLimit );
    So you would end up with a method looking like this:

    Code (csharp):
    1.  
    2.     void FingerGestures_OnDragMove( Vector2 fingerPos, Vector2 delta )
    3.     {
    4.         if( target )
    5.         {
    6.             x += delta.x * xSpeed * 0.02f;
    7.             y -= delta.y * ySpeed * 0.02f;
    8.  
    9.             //y = ClampAngle( y, yMinLimit, yMaxLimit );
    10.  
    11.             Apply();
    12.         }
    13.     }
    By the way, I'm going to do some updates to the TBDragOrbit script since it seems a lot of people are using it, so if you have any feature requests for it, now is your chance to speak up! ;)
     
  41. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Doesn't that reverse the X Axis when you do this...?
     
  42. Fixdit

    Fixdit

    Joined:
    Nov 6, 2010
    Posts:
    17
    Also, how would you get the delta for each finger in a pinch move function? Like in code we've previously created using iPhoneInputs:
    Code (csharp):
    1.  
    2. // fingers data
    3. iPhoneTouch f0 = iPhoneInput.GetTouch(0);
    4. iPhoneTouch f1 = iPhoneInput.GetTouch(1);
    5.  
    6. Vector3 f0Delta = new Vector3(f0.deltaPosition.x, f0.deltaPosition.y, 0);
    7. Vector3 f1Delta = new Vector3(f1.deltaPosition.x, f1.deltaPosition.y, 0);
    8.  
     
  43. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You can try this:

    Code (csharp):
    1.  
    2. Vector2 delta0 = FingerGestures.GetFinger(0).DeltaPosition;
    3. Vector2 delta1 = FingerGestures.GetFinger(1).DeltaPosition;
    4.  
     
  44. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
    Hey Spk,

    Having no probe with FingerGesture but still have this issue with the mouse (i.e. in the editor) being held and going wrong :) , in the next scene - any chance you could please take a butchers?

    Cheers
     
  45. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Sorry markhula, I haven't had much time to look into this yet. Would you mind making a simple test scene/project where this happens and send it to me please? This would save me quite a bit of time.
     
  46. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
    Hey Spk,

    No probs!; where you like the zip sent?

    Cheers
     
  47. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You can PM it to me through this forum I think.
     
  48. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Someone asked me by email how to make a script to move an object to the first contact position of a finger with the screen. I wrote a quick scrip that does that, and thought I would share it here for everyone's benefit. Put this script on any scene object you want to automatically move to the latest touch position.
     

    Attached Files:

  49. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    FingerGestures v2.1 is pending review. This new version includes an updated toolbox orbit camera and mouse-based pinchzoom gesture emulation for desktop.
     
  50. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Really great!! :)