Search Unity

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

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

  1. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574

    Yeh, I just bought it as well. I am with zhx too, multi-fingers tracking support would be top of my list for what I wanna see in upcoming release too.

    If possible, would you be able to support as many fingers a device allow as possible? For example iPad can track up to 10 fingers, while iPhone/iPod Touch up to 5 fingers. Is it possible?
     
  2. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Yeah, I'm going to make some changes to how this is handled so it will default to maximum per device.
     
  3. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @Spk
    thank you for your hard work to bring such an essential feature to FingerGestures. Our team is eagerly awaiting the release of multi-finger support(though we probably wont use more than 4 fingers at any time). Thank you again for taking fingerGestures to the next level :)!
     
  4. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    Hi, I just purchased this asset and it's awesome. But, I need to help with something a bit.
    (iphone / ipad)
    I have used TBDragOrbit script to move my MainCamera by finger around my character, it works good...but my character has SmoothFollow script too and if it is enabled, it is fighting with drag orbit movement. Can you tell me how to handle this?
    Next question is, how to use this TBDragOrbit on part of the screen only. This is because I have GUI throttle slider on the right side of the screen, and if I move with this slider, camera moves to because of finger is draging...

    thank you
     
  5. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You can't use these two different components together because they are mutually exclusive: they are both camera controllers that modify the camera position and angle on each update. Since this has been requested before, I'm planning on enhancing the TBDragOrbit script to support smoothing in a future update, but until then you will have to do this yourself. I've posted some instructions and pseudo code on how to achieve this in one of the previous pages in this post.

    Short answer: at the moment, you cannot do this using any of the toolbox scripts, so you will have to modifying the TBInputManager and prevent it from firing off the drag messages to the TBDrag script when you detect the the finger screen position is within a UI region. I will try to provide a special component to do that in the future though, so thank you for the suggestion.
     
  6. oliverdb

    oliverdb

    Joined:
    Jan 30, 2010
    Posts:
    165
    Using the TBDrag script, if its disabled. I am still able to drag the object. Dunno if thats a bug?
     
  7. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    More like an omission ;) There should be a check either in the TBInputManager or the TBDrag component when sending or receiving the OnDrag events to see if the component is enabled or not before modifying the position.
     
  8. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    SPK: thank you. I just solve it. But I found some strange thing (maybe a bug)... if I load the scene, orbit view works fine, but after some time (cca 10s, or maybe a few orbit movements) it starts to be very jerky and laggy (every movement gesture make it unplayable for a moment, until movement stop). :(
    This was by default scripts too, so my code changes didn't cause that. Any idea how to solve it?
     
  9. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hm that's odd... looks like a performance spike. Have you managed to reproduce this on the sample scene with the orbit camera? And does it always happens after reloading the scene? And does it happen on desktop platform?
     
  10. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    I will try it in sample scene and let you know.
    This happens on my iphone 4G, but on the desktop it seems allright.
    It is always after some "orbit views" (camera movements).... first few movements are perfect.
     
    Last edited: Sep 21, 2011
  11. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    Now I found out,that first orbit view is ok,but every next movement make it more and more laggy. It looks there is something that stores in memory and is never cleaned. I don't know how your plugin works exactly.
     
  12. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I designed the library to make no dynamic allocations at runtime, so this sounds a bit odd, but im going to investigate this and do some profiling on device. It might be something specific to the orbit script as it's one of the most recent additions, and I couldn't test it on iphone at the time I released it.
     
  13. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    OMG, it was my mistake. Something was wrong in my script, I tried to use yours default again and add my code again and it's ok now. So you can forget it. ;) Sorry and thank you!
     
  14. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hehe good, less investigation work for me ;)
     
  15. oliverdb

    oliverdb

    Joined:
    Jan 30, 2010
    Posts:
    165
    Hey

    After a alot of debugging I realised that fingergestures manipulate an objects transform and that makes it unusuable for physcis based games since its too easy to drag an object through physcis colliders.

    Do you have any suggestions to workarounds so that I will manipulate the object within the physics system?
     
  16. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Well the toolbox scripts are pretty basic and just provided as an extra help for people who purchase the package. However, they provide good foundations on which you can build to support more features.

    In your case, you should modify the TBDrag script to detect if the object being dragged is a rigidbody or not. If it's a rigidbody, you should use something like the "Drag Rigidbody" script that ships with Unity's standard asset scripts and adapt it to this particular context. The dragging finger would update an invisible anchor object around the screen, and your dragged object's rigidbody should be connected to this anchor by a joint. That will allow the physic object to be dragged around the screen while bumping into obstacles and not going through walls.
     
  17. oliverdb

    oliverdb

    Joined:
    Jan 30, 2010
    Posts:
    165
    Thank you for your reply. I rather like the TB framework and especially the TBInputmanager since it does raycast and collison detection for me, and the TBDrag has some nice message features. I would like to stay within that, you could perhaps consider altering the part of TBInputManager that transforms all TBDrag objects so its possible to decide if the transform should be altered or not.

    I have altered the TBInputmanager so it wont transform my inherited objects leaving me in control.
    Code (csharp):
    1.  
    2.  void draggable_OnDragMove( TBDrag sender )
    3.     {
    4.         Vector3 pos;
    5.  
    6.         if( ProjectScreenPointOnDragPlane( sender.transform, sender.FingerPos, out pos )  !(sender is WagRidgidBodyDrag) )         
    7.             sender.transform.position = pos;
    8.  
    9.     }
    10.  
    11.  


     
  18. ken m

    ken m

    Joined:
    Dec 27, 2007
    Posts:
    27
    Just purchased FG. Is there a simple way to do a two-finger pan?
     
  19. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Not out of the box with the current version, but if you can wait a few days, I've got version 2.0 coming out soon with tons of new goodies, multi-finger gesture support being one of them (that includes dragging with 2 or more fingers).

    Here's a little teaser to whet your appetite!
    Code (csharp):
    1.  
    2.         doubleSwipe = new FingerGestures.SwipeRecognizer();
    3.         doubleSwipe.RequiredFingerCount = 2;
    4.         doubleSwipe.Continuous = true;
    5.         doubleSwipe.MinDistance = 50.0f;
    6.         doubleSwipe.MinVelocity = 100.0f;
    7.         doubleSwipe.OnSwipe += OnTwoFingerSwipe;
    8.  
     
    Last edited: Sep 26, 2011
  20. ken m

    ken m

    Joined:
    Dec 27, 2007
    Posts:
    27
    Thanks for the super-quick reply! Looking forward to the update.
     
  21. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Also looking forward to 2.0 here - I've been on the fence with this product as most gestures I've been able to incorporate myself - however if it's going to support multi finger gesture recognition out of the box, you definitely have another sale. =D
     
  22. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    In 2.0, I went with a new design inspired by Appel's UIGestureRecognizers. In FingerGestures 2.0, each supported gesture has a corresponding GestureRecognizer that is self-contained and fully configurable individually (e.g. not just one global setting like in the previous versions). You can specify the number of simultaneous fingers desired for almost every gesture (except the pinch and rotation at the moment). The abstract finger data has also been exposed so people can write their own custom gesture recognizers.

    I'm trying to keep the previous interface intact so this new version will remain backward compatible with previous ones and not break your existing projects.

    So yeah Im pretty excited about 2.0 too :)
     
  23. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @Spk , thanks for the teaser. Your work to bring multi-finger support is appreciated! Cant wait to use it, we've not even installed finger gestures yet, even after our purchase, waiting patiently for the multi-finger release :)
     
  24. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Thanks Zhx. It shouldn't be much longer now, the bulk of the code is ready but I still need to do more code cleanup, testing, and documentation work before I can release this properly. I expect the release to happen either at the end of the week or early next week.
     
  25. markhula

    markhula

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

    Just found this thread and took a look at the web demo, am quite interested.
    A few questions.
    Presumably in the lib if I do a 'drag' for example I can get the direction (or angle) the drag went? i.e. I can tell which way the user wishes to drag.
    Secondly (and this is probably not what your asset is for!) can it recognise shapes? i.e. if I draw a circle will it know it's a circle, or a square, or an arch. I know that wasn't it's design feature but just wondering if any support for 'character' recognition is in there.

    Cheers
     
  26. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    In the current version (1.4) you're notified when the user starts dragging, move while dragging, and finishes dragging. For each of these events, you're given the finger position, which then allows you to keep track of the direction the user is dragging in. The upcoming version (2.0) will make this even easier.

    There is also a swipe gesture that's a simplified version of the drag gesture constrained to 4 directions (up/down/left/right). In this case, you're given the actual cardinal direction as part of the event response.

    This is not supported at the moment. As you mentioned, this isn't what FingerGestures is designed for at the moment. I want to focus on standard gestures before I take the library in a more exotic direction. Version 2.0 will allow advanced users to implement this themselves using the new framework/API. I believe there is another package on the asset store that does just that though (Gesture Recognition Engine if I remember correctly).
     
  27. markhula

    markhula

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

    Thanks for the prompt reply. I've read the entire thread and it sounds like a big time-saver for me.
    I will make a purchase!!. My only other question is will an upgrade to 2.0 be free if I purchase now?, and when is v2 due roughly?

    Thanks again, much appreciated

    Cheers
     
  28. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    @markhula: Good to hear!

    On the asset store, any future product update is free, so yeah. I haven't decided yet if I'm going to raise the price of the package when v2.0 comes out so you might even save some money by getting it now ;)

    And as stated above, by the way things are looking now, I should have v2.0 out at the end of the week or early next week.
     
  29. markhula

    markhula

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

    Ace :)
    Can you give any *insight* into how in v2 I might achieve some simple character recognition? - you did indicate it would be possible and I'm just wondering how it would be implemented and if there's any performance issue (especially on a low platform like Android/iphone).

    Cheers

    Purchasing now :)
     
  30. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
  31. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Well you will have to do the heavy lifting when it comes to recognizing the character, but the library can provide you with a good framework for implementing this. For instance, you will create a new "CharacterRecognizer" class that inherits from one of the existing base gesture classes, and implement the overridable methods that deal with:
    - deciding when to start the gesture tracking (e.g. making sure the correct amount of fingers are down, and moved beyond a certain threshold)
    - while active, deciding whether the gesture recognition failed, succeeded, or should continue.

    It will also provide you with a useful Finger/Touches abstractions that make it easy to implement gesture recognition, no matter what input device you are using (mouse or touch screen).

    As for the actual character recognition algorithm, I am not very familiar with that but I guess you could do something pretty simple such as representing a letter as an ordered set of 2D-waypoints defined in a local coordinate system, and you would make the recognizer fail if the user's finger moves beyond a tolerance threshold from the current segment. You'd obviously need something a bit more elaborate to handle the cases where a letter needs several strokes to be recognized. You could maybe do that by creating a chain of simpler gesture recognizers.
     
    Last edited: Sep 27, 2011
  32. markhula

    markhula

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

    Thanks. I did think that 'waypoints' were probably the fastest and simplest method for very basic character recognition so I shall look into that. I only need to deal with single keystrokes i.e. circle, square etc. so I guess it shouldn't be too tricky (he says!) :)
    Thanks again, will let you know how I get on.

    Cheers
     
  33. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Please do! Maybe we can include it in a future version of FingerGestures ;)
     
  34. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    A little status update: I've been hard at work on 2.0 and it's getting close to release state. I still need to update a few samples and add some more documentation for the new systems, but I hope to be done with this tomorrow (friday) and hopefully get it published the same day.

    I'm very excited about the new features and changes coming in 2.0. They drastically increase flexibility, ease of use, and potential for extension. You will see what I mean soon! ;)
     
  35. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Awesome! Will there be a price change for 2.0?
     
  36. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I might bump it up slightly yeah. Just put over 70 hours into the new version
     
  37. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Looks like it's gonna be a monday release afterall... The documentation effort was bigger than I anticipated! But maybe that will give me time to do a nice intro video :)

    In the meantime, here's a little sneak-peek at the Upgrade Guide for the new version: http://www.fatalfrog.com/?page_id=325.
     
    Last edited: Sep 30, 2011
  38. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    thanks for the upgrade guide. We're ready and waiting, please dont hesitate to upload the package to unity until monday, unless there's additional coding needed... we've halted all gesture code in our pipeline until the update is in the asset store. Thank you again for the hard work you've done on FingerGestures
     
  39. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I've just submitted version 2.0 to the Asset Store, so it's now pending review and should be available soon. I have also updated my website in advance, so you can start reading the changes here: http://www.fatalfrog.com/?page_id=140

    Also, I've made a first tutorial video that gives a quick demo on how to setup and detect a tap gesture, using two different methods.



    I will update the front post when the package is live.
    All I can say is, pffffewwww, this was one hell of a huge update :p
     
  40. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
    Hey,

    Excellent news on V2.
    I have a slight problem with the current version though.
    I keep finger gesture persistent for when I go between scenes. I wish any finger touches to 'carry over' to the next scene.
    For example, you are touching the right side of the screen for a player to run towards. Once they get there they are in another 'room' and are therefore back at the left hand side of the screen - you though are still touching the screen and they should still continue towards it.
    FingerGesture chucks out though:

    "unexpected phase transition: Stationary to none. Forcing finger release"

    Of course this is exactly what I don't want :)

    How can i solve my problem?

    Cheers :)
     
  41. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Wow, talk about the edge case scenario, literally :p
    I'm not sure I can do much about it, as I'm simply using the input data provided by unity. When you load a new scene, Unity probably resets its internal touch buffer as well, which is what is being picked up by FingerGestures. Did that event work before, we the 1.4 version?

    You could play around a bit with the Finger.Update() method, but at the moment I can't come up with any solution to your problem that wouldn't be an ugly hack... I'll let you know if I come up with something.
     
    Last edited: Oct 4, 2011
  42. markhula

    markhula

    Joined:
    Sep 3, 2011
    Posts:
    630
    :))))
    Hey Spk, you know what it's like as soon as you release something then someone's always going to mis-use it or break it somehow :))))))
    I'm still on 1.4 so don't know on v2 - assume though (as you say) probably still an issue.
    I *guess* an ugly hack would be to store the touched coordinates before going into the scene transition and then plug them back in once the new level has loaded. If you did have a nice simple hack that would be cool - and yeah, I guess Unity dumps any touched input on a new scene load :-(

    Thanks in advance

    Cheers
     
  43. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Oops my mistake here, I assumed 2.0 was already out... but apprently it's still pending revue, doh!
     
  44. markhula

    markhula

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

    I've almost got this working.
    On the actual device (i.e. iPhone) I simply create a finger initialiser per scene non persistent - it works :)
    But the same setup with the mouse causes a button to almost 'get held' i.e. if you are click-holding the screen and go to the next scene the mouse position isn't recognised until you release i.e. the click-held position is still the same from the previous screen. I can't quite see anything in my code that would do that (as it works with a touch screen) - is there something in the actual mouse code that might cause that??.

    Cheers
     
  45. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    @markhula: hm take a look at the MouseGestures.cs file, there might be code you can tweak in there to work around this issue. I can't look at it right now though, sorry.
     
    Last edited: Oct 5, 2011
  46. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Version 2.0 is now live! Go update or get it! :)

    - Multi-finger support: two-fingers swipe, three-fingers tap, four-fingers drag… you name it!
    - Brand new object-oriented framework composed of a set of fully customizable gesture recognizer components
    - A lot more data exposed for advanced users to extend the features provided by the library
    - New samples

    For the rest of the changes, click here.
     
  47. markhula

    markhula

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

    Thanks - will take a look.
    Hey does v2 support 11-finger drag? lol!

    Cheers
     
  48. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    What is the correct way to change the timing for the long press event? At the moment I just hack the code in the initializer, is that the right way to do it? I see there is now a default prefab for Long Press but what do you do with it?
     
  49. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You have two possiblities:
    A) if you are using the default gesture events (FingerGestures.OnLongPress, or FingerGestures.OnFingerLongPress) then you can change the long press duration time by modifying the "duration" property of the default long press gesture prefab, in the FingerGestures > Prefabs > Components folder. If you want to do this by code, you must access FingerGestures.Defaults.longPress.duration or FingerGestures.Defaults.Fingers[X].longPress.duration.

    B) If you are directly using a LongPressGestureRecognizer object in your scene, then simply edit the same "duration" field on this component. You can do this via the editor or directly by code.

    A corresponds to the "basic method" in the video, while B corresponds to the "advanced method".
    Hope this helps. Let me know how it goes.
     
    Last edited: Oct 6, 2011
  50. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Ok I went with A. Didn't realise that those prefabs don't need to be actually in the scene!