Search Unity

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

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

  1. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    My new web host is failing on me completely - the site has been up and down for the last 2 days, and I'm in the process of finding a replacement solution. Right now, I'm thinking of giving up on the crappy shared hosting sites and put it on the Amazon EC2 cloud instead. Anyone else got some good web hosting suggestions?
     
  2. Sarus

    Sarus

    Joined:
    Sep 4, 2009
    Posts:
    6
    I'm sorry you're having so much trouble. I've been using http://www.dixiesys.com/ (medium plan) for almost 10 years now without any real problems. In that time frame I only remember one bad server crash where they had a couple days of downtime while they restored people's sites from backups they had. You might also want to try something like GoDaddy.com or NetworkSolutions which are bigger known names so I assume their service is decent. If you want to be really safe though using EC2 or something like Rackspace is the way to go (rackspace is expensive though).

    -------

    On your website I saw that 2.3 was released. Will this be on the asset store soon?

    --------

    Also, I was planning on posting on your dedicated forums but had a question on proper finger gesture usage for multiple "target" areas on the same screen. I'm working on a turn based game that uses a top down camera perspective which I'm moving around using the DragGestureRecognizer and the OnDragMove event. In addition to moving the main camera around I have a minimap in the lower left corner of the screen and I want users to be able to move the camera around by both tapping on the minimap and dragging their finger around on the minimap to provide a faster way to move in large increments.

    Is there a way to set this up when using FingerGestures? For example, if the user starts dragging on the main window to move the camera the movement should stop if their finger goes over the minimap. Basically I'd like some way to have two different target areas which provide back their respective coordinates for the view port.

    Thanks for putting out such a great product. It has saved me a ton of time so far.

    ~Sarus
     
    Last edited: Feb 29, 2012
  3. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hi Sarus, thanks for the nice comments tips for the webhost. I already got a few new candidates lined up, so Im optimistic ;)

    It's pending review on the asset store as we speak ;) They've been a bit slow approving it though... I submitted on Sunday :\

    As for your technical question, I apologize but I will have to get back to you later today on this, as right now my top priority is to get that damn website up and running again. Sorry :(
     
  4. qholmes

    qholmes

    Joined:
    Sep 17, 2010
    Posts:
    162
    Sucks on the web site man.. I am happy with my server service too but they are quirky.. but it is co run by a friend so it works for me.. Wish you luck..

    My issue turns out to be PlayMaker bug.. i seem to be a software bug magnet.. Cebas is still trying to fully recover from my last bug find there too... why meeeeeeee

    Sarus, for your multiple target areas.. you could use a collider system like i did to test for touching in certain areas of the screen.. I use my GUI Ortho camera and a box with no mesh render on it to test if my camera control touches are in that area of the screen.. no reason you could not have multiple ones..

    Onward.

    Q
     
  5. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Hello,

    I recently purchased FingerGestures and am having a little trouble figuring out the best way to handle a situation. I have many objects in the scene, so I want to use your Input Manager (as opposed to doing a lot of raycasting/position checking on each object) in conjunction with TBFingerUp and TBFingerDown.

    The behavior I'm trying to get is when you hold a touch/mouse-click down on an object it does something each frame while held - when you mouse/finger up it stops performing the action. This was very easy/intuitive to accomplish like so:

    Code (csharp):
    1.  
    2. void OnFingerDown(){
    3.         Debug.Log("OnFingerDown");
    4.         StopCoroutine("Held");
    5.         StartCoroutine("Held");
    6.     }
    7.    
    8.     void OnFingerUp(){
    9.         Debug.Log("OnFingerUp");
    10.         StopCoroutine("Held");    
    11.     }
    12.    
    13.     IEnumerator Held(){
    14.         while (true){
    15.             Debug.Log("Held " + Time.deltaTime);
    16.             HoldIndicator(Time.deltaTime);
    17.             yield return null;
    18.         }
    19.     }
    20.  
    However, the issue I'm having is that if the touch moves off from the object it never calls the Up code. How would you suggest approaching this? I was thinking of removing the TBFingerUp component entirely and simply having Held() track the FingerIndex of the "TBFingerDown" component and react as appropriate when that FingerIndex pushed an OnFingerUp event.

    Thanks for any feedback/suggestions! I just started using it, so I wanted to see if I was overlooking something obvious before I dove in with a probably hacky solution.
     
  6. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    For your performance concern issue, the TPInputManager is already taking care of that for you. It listens to the input gestures, performs a raycast, and then dispatch the event to the topmost object that it hit, granted it was valid. I designed it this way for that particular performance reason (although I kinda wished I didn't hehe, the other way around would offer more flexibility).

    For your finger down/up detection issue, you could simply poll the finger state on each frame after you received a OnFingerDown event on your object. You simply keep track of the finger index used to press on the object in the first place, and then you can use FingerGestures.GetFinger(the_finger_index).IsDown to check if the finger is still down.
     
    Last edited: Feb 29, 2012
  7. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hm there is no built-in system in place to implement this behaviour. You will have to implement the logic yourself. I think a good approach would be to create a "drag manager" that would abstract this for you by listening to the drag gestures and then dispatch the drag events to each of your subsystems/areas (minimap, main window, etc) based on the current finger position. Did that make sense? ;)
     
  8. Intrawebs

    Intrawebs

    Joined:
    Mar 24, 2011
    Posts:
    45
    I really need the new version as you say you have fixed unrecognized tap gestures. However, you only support 3.5 in the asset store, is there a technical reason for doing so? 3.5 has many issues and many devs are rolling back to 3.4. Can you make it 3.4 compatible?

    EDIT
    Dont worry about this, at least not for now. I got 3.5 up and running and since I have a 2D game and very little assets I doubt I will have the same probs as others. Oh, and guess what, your update fixed my issues and 100% of the taps are recognized....fantastic. Thanks much.
     
    Last edited: Mar 1, 2012
  9. milkcorp

    milkcorp

    Joined:
    Feb 26, 2012
    Posts:
    11
    Hello.
    How can I detect quick flick gestures on iPhone?
    I wanna detect quick flick gestures when the finger is moving on the screen.

    I already tried two ways.

    1) SwipeGestureRecognizer.OnSwipe
    This event fired when the finger released on screen.

    2) FingerGestures.OnFingerDragMove
    This event didn't fired when the gesture was very quickly.

    any better suggestions?

    thanks
     
  10. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hello Milkcorp,
    Can you give me a description on what you mean exactly by quick flick gesture please?
     
  11. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I tried really hard to keep it running on 3.4 version, but the sample scenes broke when I imported them from my 3.5 version via package. I'm trying to find a workaround for this, as it's just not a good idea to only support the latest Unity version.
     
  12. Sarus

    Sarus

    Joined:
    Sep 4, 2009
    Posts:
    6
    Thanks! That's all I needed to know.
     
  13. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    UPDATE: Added a "max fingers" property to KTBOver, defaults to 1.
    UPDATE 2: Rewrote it a bit so that OnStay properly updates the FingerPos - when tracking multiple fingers the FingerPos is still only going to return the position of the finger that most recently shot off an event though.

    Update 3: Added a new "sticky behavior" - will cause the KTBOver component to believe it is still hovered over until any/all fingers down on it have been lifted. This is useful for things you want to have follow the finger without worrying about moving too quickly and leaving the collider (once you finger down on it, it'll track the finger until you finger up anywhere on the screen).

    Note: It seems to work with more than 1 "max finger" fine both with and without sticky behavior. However, it has not been tested thoroughly (as I am not using it in any situations where I want to track more than one finger).

    Hello, just wanted to let you know that I'm pretty thoroughly loving the product so far. I came up with a more universal solution for that behavior (since I want to use it in many different places) similar to your own components. However, it required that I extend TBInputManager - which is not a big deal at all - I just made to make some of your functions "protected virtual void" so I could either overwrite them or extend them.

    Anyway, if anyone is interested in it - here is my "KTBOver" script:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. /// <summary>
    7. /// ToolBox LongPress Component
    8. ///
    9. /// Put this script on any 3D GameObject to detect when they are long-pressed
    10. /// </summary>
    11. [AddComponentMenu( "FingerGestures/Toolbox/KTBOver" )]
    12. public class KTBOver : TBComponent
    13. {
    14.     public int maxFingers = 1;
    15.     public bool raiseOverOnlyOnDown = false;
    16.     public bool useStickyLogic = false;
    17.    
    18.     public Message message = new Message( "OnFingerOver" );
    19.     public Message outMessage = new Message( "OnFingerOut");
    20.    
    21.     public bool raiseStay = true;
    22.     public Message stayMessage = new Message("OnFingerStay");
    23.    
    24.     public event EventHandler<KTBOver> OnOver;
    25.     public event EventHandler<KTBOver> OnOut;
    26.     public event EventHandler<KTBOver> OnStay;
    27.    
    28.     public List<int> fingersOver = new List<int>();
    29.    
    30.     public bool RaiseStay( int fingerIndex, Vector2 fingerPos )
    31.     {    
    32.         if (useStickyLogic) return false;
    33.        
    34.         if (!fingersOver.Contains(fingerIndex)) return false;
    35.         FingerIndex = fingerIndex;
    36.         FingerPos = fingerPos;
    37.        
    38.         if (OnStay != null)
    39.             OnStay(this);
    40.        
    41.         Send (stayMessage);
    42.         return true;
    43.     }
    44.    
    45.     public bool RaiseOver( int fingerIndex, Vector2 fingerPos, bool fromDown )
    46.     {
    47.         if (raiseOverOnlyOnDown  !fromDown) return false;
    48.         if (!fingersOver.Contains(fingerIndex)  fingersOver.Count >= maxFingers) return false;
    49.        
    50.         FingerIndex = fingerIndex;
    51.         FingerPos = fingerPos;
    52.         if (!fingersOver.Contains(fingerIndex)){
    53.             fingersOver.Add(fingerIndex);
    54.         }
    55.            
    56.         if( OnOver != null )
    57.             OnOver( this );
    58.  
    59.         Send( message );
    60.        
    61.         if (useStickyLogic){
    62.             StopCoroutine("StickToFinger");
    63.             StartCoroutine("StickToFinger");    
    64.         }
    65.        
    66.         return true;
    67.     }
    68.    
    69.     public bool RaiseOut(int fingerIndex, Vector2 fingerPos )
    70.     {
    71.         if (useStickyLogic) return false;
    72.        
    73.         FingerIndex = fingerIndex;
    74.         FingerPos = fingerPos;
    75.         if (fingersOver.Contains(fingerIndex)){
    76.             fingersOver.Remove(fingerIndex);    
    77.            
    78.             if( OnOut != null )
    79.             OnOut( this );
    80.            
    81.             Send(outMessage);
    82.         }
    83.         return true;
    84.     }
    85.    
    86.     IEnumerator StickToFinger(){
    87.         List<int> fingersLifted = new List<int>();
    88.        
    89.         while (fingersOver.Count > 0){
    90.            
    91.             foreach(int fingerIndex in fingersOver){
    92.                 if (!FingerGestures.GetFinger(fingerIndex).IsDown){
    93.                     fingersLifted.Add(fingerIndex);
    94.                 }
    95.             }
    96.            
    97.             foreach(int fingerIndex in fingersLifted){
    98.                 if (fingersOver.Contains(fingerIndex)){
    99.                     fingersOver.Remove(fingerIndex);    
    100.                 }
    101.             }
    102.            
    103.             fingersLifted.Clear();
    104.            
    105.             if (fingersOver.Count > 0){
    106.                 FingerPos = FingerGestures.GetFinger(fingersOver[0]).Position;
    107.                
    108.                 if (OnStay != null)
    109.                     OnStay(this);
    110.                
    111.                 Send (stayMessage);
    112.             }
    113.            
    114.             yield return null;
    115.         }
    116.     }
    117. }
    118.  
    119.  
    And to use that, you need to use my KTBInputManager script instead of the usual TBInputManager:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class KTBInputManager : TBInputManager {
    7.     Dictionary<int,KTBOver> _fingerOverDict;
    8.    
    9.     void Awake () {
    10.         _fingerOverDict = new Dictionary<int, KTBOver>();
    11.     }
    12.    
    13.     public bool trackMovement = true;
    14.    
    15.     void OnEnable()
    16.     {
    17.         base.OnEnable();
    18.        
    19.         if (trackMovement){
    20.             FingerGestures.OnFingerMove += FingerGestures_OnFingerMove;
    21.             FingerGestures.OnFingerStationary += FingerGestures_OnFingerStationary;
    22.         }
    23.     }
    24.    
    25.     void OnDisable()
    26.     {
    27.         base.OnDisable();
    28.        
    29.         if (trackMovement){
    30.             FingerGestures.OnFingerMove -= FingerGestures_OnFingerMove;
    31.             FingerGestures.OnFingerStationary -= FingerGestures_OnFingerStationary;
    32.         }
    33.     }
    34.    
    35.     #region Fingers Input Events
    36.    
    37.     protected override void FingerGestures_OnFingerUp( int fingerIndex, Vector2 fingerPos, float timeHeldDown )
    38.     {
    39.         GameObject go = PickObject(fingerPos);
    40.         if (trackMovement  _fingerOverDict.ContainsKey(fingerIndex)){
    41.             _fingerOverDict[fingerIndex].RaiseOut(fingerIndex, fingerPos);
    42.             _fingerOverDict.Remove(fingerIndex);
    43.         }
    44.        
    45.         if (go == null) { return; }
    46.        
    47.         TBFingerUp fingerUpComp = go.GetComponent<TBFingerUp>();
    48.         if( fingerUpComp  fingerUpComp.enabled )
    49.             fingerUpComp.RaiseFingerUp( fingerIndex, fingerPos, timeHeldDown );
    50.     }
    51.    
    52.     protected override void FingerGestures_OnFingerDown( int fingerIndex, Vector2 fingerPos )
    53.     {
    54.         GameObject go = PickObject(fingerPos);
    55.        
    56.         if (go == null) { return; }
    57.        
    58.         if (trackMovement){
    59.             KTBOver oc = go.GetComponent<KTBOver>();
    60.             bool isSame = CleanFinger(fingerIndex, fingerPos, oc);
    61.            
    62.             if (oc  oc.enabled  !isSame){
    63.                 oc.RaiseOver(fingerIndex, fingerPos, true);
    64.                 _fingerOverDict.Add(fingerIndex, oc);
    65.             }
    66.         }
    67.        
    68.         TBFingerDown fingerDownComp = PickComponent<TBFingerDown>( fingerPos );
    69.         if( fingerDownComp  fingerDownComp.enabled )
    70.             fingerDownComp.RaiseFingerDown( fingerIndex, fingerPos );
    71.     }
    72.    
    73.     void FingerGestures_OnFingerMove (int fingerIndex, Vector2 fingerPos)
    74.     {
    75.         if (!trackMovement) return;
    76.        
    77.         KTBOver oc = PickComponent<KTBOver>(fingerPos);
    78.         bool isSame = CleanFinger(fingerIndex, fingerPos, oc);
    79.        
    80.         if (oc  oc.enabled){
    81.             if (!isSame){
    82.                 _fingerOverDict.Add(fingerIndex, oc);
    83.                 oc.RaiseOver(fingerIndex, fingerPos, false);
    84.             } else {
    85.                 oc.RaiseStay(fingerIndex, fingerPos);    
    86.             }
    87.         }
    88.     }
    89.    
    90.     void FingerGestures_OnFingerStationary(int fingerIndex, Vector2 fingerPos, float elapsedTime )
    91.     {
    92.         FingerGestures_OnFingerMove(fingerIndex, fingerPos);
    93.     }
    94.    
    95.     protected bool CleanFinger(int fingerIndex, Vector2 fingerPos, KTBOver oc){
    96.         bool isSame = false;
    97.         if (_fingerOverDict.ContainsKey(fingerIndex)){
    98.             isSame = _fingerOverDict[fingerIndex] == oc;
    99.            
    100.             if (!isSame){
    101.                 _fingerOverDict[fingerIndex].RaiseOut(fingerIndex, fingerPos);
    102.                 _fingerOverDict.Remove(fingerIndex);
    103.             }
    104.         }
    105.        
    106.         return isSame;
    107.     }
    108.    
    109.     #endregion
    110. }
    111.  
    112. }
    113.  
    114.  
    NOTE: To use KTBInputManager you need to change the following (all just voids by default):
    protected void OnEnable()
    protected void OnDisable()
    protected virtual void FingerGestures_OnFingerUp
    protected virtual void FingerGestures_OnFingerDown


    ----------------------------------------------------------------------------------------------

    Usage:
    KTBOver has three different events:

    OnOver - Called whenever a finger moves over the object.
    OnOut - Called whenever a finger moves out of the object.
    OnStay - Called whenever at least one finger is staying on the object.

    There is also a bool:
    raiseOverOnlyOnDown - Prevents OnOver (and thus, OnStay) from being called unless it originates from a FingerDown event. Useful for things like buttons that you want to hold down/repeat until the finger moves out from the button - but you don't want to trigger if someone just happens to swipe the finger/mouse across said button.

    Anyhow, there was probably a cleaner solution to this - but now I have a component I can just drop onto whatever I want just like with the built in ones.
     
    Last edited: Mar 1, 2012
  14. qholmes

    qholmes

    Joined:
    Sep 17, 2010
    Posts:
    162
    Hey cool thanks for sharing!!!! will look at it later. Is it the new version?

    q
     
  15. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Yea, the code in there should be the latest (update 3).
     
    Last edited: Mar 1, 2012
  16. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hey everyone, I've just finished migrating most of the stuff from the crappy host to my new one, so the forums should be back up and running again. New address is:

    http://forum.fatalfrog.com

    The fatalfrog.com website should also be up and running smoothly now, with quite a few broken links though. Still trying to catch up, but things are finally getting back in order now :)

    Also, i'm planning on releasing a brand new dedicated fingergestures website tomorrow with online documentation wiki and all the jazz. Can some of you do me a favor by visiting fingergestures.fatalfrog.com and letting me know what you think and if you're experiencing any issues? It's still missing a bit of content here and there, but i'm filling it in as we speak.
     
  17. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    It Works fine for me!

    Tested on IE9
     
  18. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
  19. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    to continue on the TUIO / Multitouch stuff from about page 8, you can do it pretty easy by copying/modifying the TouchScreenGestures.cs file to a TUIOGestures.cs file, recording for anyone else who's trying to do this.

    (Using the uniTUIO package that creates fake Input.touches, the main difference is that it keeps incrementing the fingerID every time there is a new touch on the screen, so the 1-1 mapping for touch index doesn't work... its a pretty simple change though:

    in the TUIOGestures, adjust the return for GetTouch( Finger finger ) to be :
    Code (csharp):
    1. return Input.touches[finger.Index];
    and in the finger2TouchMap change
    Code (csharp):
    1.  
    2.             if( fingerIndex < finger2touchMap.Length )
    3.                 finger2touchMap[fingerIndex] = i;
    4.  
    to

    Code (csharp):
    1.  
    2. finger2touchMap[i] = fingerIndex;
    3.  
    now with that, i can have TUIOGestures as my standalone and editor, and TouchScreenGestures as my iOS/Android exports.

    sweet :)

    I still need to figure out some issues with the
    "Correcting bad FingerPhase transition (FingerPhase.Began skipped)" error.. it seems to cause inputs to stop working for a time?...
     
    Last edited: Mar 3, 2012
  20. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Thanks for sharing your code with the rest of us!

    The warning message isn't really something to worry about unless you get it very often. It might happen occasionally when an input phase is missed between updates. This just means that instead of going through states A > B > C, the finger/touch went directly from A > C, skipping B in the process. FingerGestures tries to catch these scenarios and fix them as best as possible, but it gives you a warning when it happens.
     
  21. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    yea it actually happens quite a lot

    <removed blatanly wrong info>
     
    Last edited: Mar 5, 2012
  22. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    I purchased FingerGestures a few weeks ago and it's been absolutely awesome to work with. A total godsend so great job!

    Now to my question. I just purchased NGUI and while it's awesome and the built-in input system is great I'm having some issues with FingerGestures and NGUI's input systems firing simultaneously. Ideally, I'd like to use NGUI's system for the UI and use FingerGestures for everything else but I'm not sure if there's a way to tell FingerGestures not to fire when NGUI elements are selected. I can certainly hack something together to prevent my FingerGesture callbacks from functioning by using flags and whatnot to indicate where input is coming from, etc, but I'd obviously prefer a more elegant and built-in solution. Any ideas?

    Thanks!

    Dennis
     
  23. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hi Dennis, thanks for the kind words.

    I'm also using NGUI for my own project (I recommend it) along with FingerGestures and there are several ways to go about doing what you want:

    1) You can add a check at the beginning of each of your gesture event handler code to check if the finger position corresponds to a UI area (e.g. you simply raycast and see if you hit a GUI layer object)

    2) Starting with the latest v2.3, you can now specify a global touch filter via FingerGestures.GlobalTouchFilter. I haven't properly documented this yet, but it's quite straightforward. You simply provide a delegate method that will return false if the touch should be ignored, or true if it should be let through. That's where you would put your UI-raycast check, for instance:

    Code (csharp):
    1. bool MyGlobalTouchFilter( int fingerIndex, Vector2 position )
    2. {
    3.     if( IsUIRegion( position ) )
    4.       return false;
    5.    
    6.    return true;
    7. }
    8.  
    And then you would set the filter on the FingerGestures singleton, somewhere in your initialization code:
    Code (csharp):
    1.  
    2. FingerGestures.GlobalTouchFilter = MyGlobalTouchFilter;
    3.  
    The IsUIRegion() is a method you'll have to implement yourself, but it should simply return true if it hits an collider that belongs to your GUI layer.

    Let me know if you have more questions.
     
    Last edited: Mar 5, 2012
  24. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    Awesome man. That's exactly what I was looking for! Thanks for being so responsive and helpful. And again, great job on this package it's saved me many hours of dev time!
     
  25. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You're welcome, glad to hear you're happy with it :)
     
  26. matis1989

    matis1989

    Joined:
    Mar 23, 2011
    Posts:
    162
    Hi, I like this package a lot, good job.
    Just one question - how can I add rotation by gesture? I know it is with pinch zoom in sample scene but I dont know how to use it separately, where I can find script for rotation or how can I program that?
    Thank you for answer.
     
  27. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hello Matis, I'm glad you're happy with it as well :)

    You have several options here:
    1) Use the default rotation gesture events (FingerGestures.OnRotationBegin, OnRotationMove and OnRotationEnd)
    2) Use the RotationGestureRecognizer (Plugins/FingerGestures/Components/RotationGestureRecognizer.cs)

    For examples on how to use these, you can take a look at the Samples/Basic Mode/PinchRotation and the Samples/Advanced Mode/Advanced PinchRotation samples. Let me know if you need more help.
     
  28. matis1989

    matis1989

    Joined:
    Mar 23, 2011
    Posts:
    162
    ok Iam try use this on my object what I need rotate, but this dont work. Iam new in programing that is problem;)
    Code (csharp):
    1. public class rotate : MonoBehaviour {
    2.  
    3.     public bool Rotating = false;
    4.  
    5.     void FingerGestures_OnRotationBegin( Vector2 fingerPos1, Vector2 fingerPos2 )
    6.     {
    7.             Rotating = true;
    8.     }
    9.  
    10.     void FingerGestures_OnRotationMove( Vector2 fingerPos1, Vector2 fingerPos2, float rotationAngleDelta )
    11.     {
    12.         if( Rotating)
    13.         {
    14.             gameObject.transform.Rotate( 0, 0, rotationAngleDelta );
    15.         }
    16.     }
    17.  
    18.     void FingerGestures_OnRotationEnd( Vector2 fingerPos1, Vector2 fingerPos2, float totalRotationAngle )
    19.     {
    20.         if( Rotating)
    21.         {
    22.             Rotating = false;
    23.         }
    24.     }
    25. }
     
  29. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You're almost there, you simply need to subscribe to these events in your OnEnable() and OnDisable() functions. Check the quickstart instructions here (Detecting Tap, Method A section).

    Here, you need add this code to your rotate script:

    Code (csharp):
    1.  
    2. void OnEnable()
    3. {
    4.    // subscribe to the rotation events
    5.    FingerGestures.OnRotationBegin += FingerGestures_OnRotationBegin;
    6.    FingerGestures.OnRotationMove += FingerGestures_OnRotationMove;
    7.    FingerGestures.OnRotationEnd += FingerGestures_OnRotationEnd;
    8. }
    9.  
    10. void OnDisable()
    11. {
    12.    // unsubscribe from the rotation events
    13.    FingerGestures.OnRotationBegin -= FingerGestures_OnRotationBegin;
    14.    FingerGestures.OnRotationMove -= FingerGestures_OnRotationMove;
    15.    FingerGestures.OnRotationEnd -= FingerGestures_OnRotationEnd;
    16. }
    17.  
    Also keep in mind that in its current shape, your script will trigger regardless of which object it is put on. If you want to only rotate the object you put it on, you will have to add some additional logic to do this (e.g. raycasting into the scene to see if the collider under the fingers is your object).
     
  30. matis1989

    matis1989

    Joined:
    Mar 23, 2011
    Posts:
    162
    Excellent, now it work. Thanks a lot!
     
  31. joyceanblue

    joyceanblue

    Joined:
    Jul 26, 2010
    Posts:
    43
    Dave did you try it with any particular touch screen monitor?
     
  32. victor-biosphera

    victor-biosphera

    Joined:
    Jun 21, 2010
    Posts:
    67
    Hello Spk,

    im a new FG user, and it helps a me a lot! Its a very nice product,
    My problem is a not very good programing in C, im more a javascipt...

    Did you have more scripts in javascript than the base JavascriptSkeleton?
    The ones im using right now is: TBDragOrbit and TBTap, did you have a javascript version of this?

    Thanks, and congrats on you product!
     
  33. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hi Victor, thanks for the kind words.

    There are one or two extra javascripts included in the samples, but they're quite short.

    The toolbox scripts are not available in javascript version. If you need to access their properties/methods from javascript, you should move the Toolbox folder to your Assets/Plugins/FingerGestures directory.
     
  34. J450N

    J450N

    Joined:
    Nov 25, 2010
    Posts:
    20
    Dave,

    I just got a copy of FingerGestures and just began playing around getting it to work with uniTUIO.

    In your example you say uniTUIO maps touches to the UnityEngine.Input.touches?!? Maybe I missed something awesome, but as far as I've seen, it just maps the TUIO data to newly constructed touches (actually deprecated iPhoneTouch), but these touches are NOT accessible by calling Input.touches. Does this not jive with your experience or am I missing something?

    If my above assumption is correct, are you swapping Input.touches with a reference to the uniTUIO touches?
     
  35. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
  36. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I've been hesitating on this - At the moment, I would rather not because I already have enough support work on my hands :)
     
  37. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    I see your point. You have a great time saver tool and soon you'll have a new customer to support anyway... ;)
     
  38. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    And I'm always happy to hear that :D
     
  39. mwildoer

    mwildoer

    Joined:
    Oct 8, 2010
    Posts:
    1
    Hello,

    I have a collision plane at the back of a scene and I want to be able to pan the main camera around the scene by dragging in the xy directions using FingerGestures (ie. a raycast detects a touch collision to the plane), such that the drag gesture also has momentum (ie. the camera continues moving but decelerating after the finger release). I also want to set a boundary to the panning, maybe with a bounce when it hits a boundary whilst it's moving.

    Is this easy to do with FingerGestures? This is a very common control mechanism in games, and I really need it for my app. Could you provide some advice on how to implement this? It would be great if you could add it as an example scene to the FingerGestures package.

    Thanks in advance.

    Michael
     
  40. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Hi Micheal, thanks for the suggestion.

    The current camera scripts don't exactly provide what you're after, but they'll get you pretty close.
    If your camera plane is parallel to your desired drag plane, you can simply set the drag plane mode to "Camera" so that the camera will be dragged along its own screen plane. There is currently no support for panning boundaries bouncing, but that's definitely something I could look into for a future update, as I'm sure more people could benefit from it too.
     
  41. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Spk,
    Not that you don't have enough work. I think this would be very useful, and could possibly be a an add on to Finger Gestures as well as an additional Asset Store product. (Sub-conscious enticement)
    I love Finger Gestures and it has been a fantastic help for our early stage dev.
     
  42. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Quick announcement: due to popular request, FingerGestures will be joining the asset store madness afterall :) Just giving a heads up to the few of you about to purchase it, just hold off a few more hours and get a discounted price!
     
  43. helioxfilm

    helioxfilm

    Joined:
    Apr 23, 2008
    Posts:
    259
    I was just hoping this, but now I am happy :)
     
  44. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    That is simply great, thank you!
     
  45. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Ok, FingerGestures is now officially on the Asset Store Madness train, with a time-limited offer of $35 - that's 35% OFF for you!!!

    It won't be up for very long, so grab it while it's still hot ;)
     
  46. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Even though I`m interested in the upcoming Playmaker integration, I just couldn`t resist such an offer.
    Thank you sir.
     
  47. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    You're welcome Mark!
    By the way, I've been in touch with Alex, the author of Playmaker, and we're going to work out this fingergesture <-> playermaker integration pretty soon :)
     
  48. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    Great news! As I've seen it on your roadmap, that was one of the key factors of my purchase... But I wasn't expecting it that soon. :)
     
  49. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    My hat off to you Sir, and a second Thank You!

    Really looking forward the day I can touch everything and make it doing what I want! :)
     
    Last edited: Mar 20, 2012
  50. AllSynergy

    AllSynergy

    Joined:
    Nov 1, 2011
    Posts:
    47
    Playmaker + fingergestures ... great :D Hope to see results soon.