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
    So I take it everything is sorted now?
     
  2. fschneider

    fschneider

    Joined:
    May 26, 2014
    Posts:
    42
    Unfortunately, no, but I guess you can't help me on this one. I suspect something is broken with my license or sth. similar.
     
  3. Silverlode

    Silverlode

    Joined:
    Apr 9, 2013
    Posts:
    41
    Posting this in case others find it useful.

    Detecting short taps (even from the tap demo scene in a fresh project) was failing 95% of the time, when I was testing on an iPad Mini 2, via Unity Remote (Windows 7, Unity 5.1). It was fixed by unticking "Auto DPI Scaling" box found on the "InputTouches" object -> "IT_Gesture" component. I'm not technical enough to understand why, my guess is the "Default test device DPI" was unsuitable for a retina-quality screen.

    Hope this helps someone. :)
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for your post.

    One of the criteria for tap to register is that it shouldn't have too much on screen movement (otherwise it could be interpreted as swipe). Therefore there's a value maxTapDisplacementAllowance on TapDetector component to prevent this. With the default value, detecting taps on mobile device with high dpi can be a bit tricky. This is due to the high pixel density count on the screen. A slight movement of the finger when tap down can register a movement pass the threshold value of maxTapDisplacementAllowance. To solve this, you can either increase the value of maxTapDisplacementAllowance, or adjust the auto-DPI-scaling value on the IT_Gesture. The later automatically adjust all the threshold value according to the device DPI.

    Hope this explains it.
     
  5. dharms

    dharms

    Joined:
    Nov 10, 2012
    Posts:
    26
    In case anyone else is getting an IL2CPP error in XCode associated with InputTouches or demo scenes will not work out of the box in an existing project (Unity 5):

    - IF YOU USE PLAYMAKER ACTIONS: Remove the entirety of the InputTouches custom scripts associated with Playmaker. Maybe updating the package at https://hutonggames.fogbugz.com/?W961 will solve it but I'd first remove the old files. This will cause issues in the demo scenes by just having the unused scripts in the project.

    - Make sure you download the latest InputTouches and import it in. I did a clean sweep of my existing InputTouches folders as I use git and otherwise it can cause some funky meta file issues.

    - For taps (I test on a Retina iPad) - Do one of the methods stated above by songtan. For the time being, I unchecked Auto DPI Scaling on the IT_Gesture script on the InputTouches prefab, and adjusted the maxTapDisplacementAllowance to 20 and the MultiTapPosSpacing to 80.

    I can't explain why there seemed to be IL2CPP issues related to the asset but it appears that the above fixed them according to my debug log.

    All running smoothly for me now - will update with how the custom Playmaker actions interface in Unity 5 soon. Thanks for being so responsive here songtan - I've been a happy customer for over a year and am thrilled to see the asset continue to work thanks to your version updates.
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks a bunch for the feedback. It should be helpful cause I don't use PlayMaker myself.

    And no need to thank me for the update. I was merely doing my part. I imagine the PlayMaker team is putting more effort than me keeping the custom action interface up to date with Unity. :)
     
  7. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    I was having trouble with multitouch drag for two objects with my script. Frustrated I brought this lol great asset and instantly worked for all touch needs. I was wondering how how to limit drag in certain axis? lets say I want to only drag vertically. Just modified the demo code and only left the drag functions which can drag x and y. Thank you.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DragDemo : MonoBehaviour {
    5.  
    6.  
    7.    
    8.     public Transform dragObj1;
    9.     public Transform dragObj2;
    10.  
    11.    
    12.     // Use this for initialization
    13.     void Start () {
    14.        
    15.     }
    16.    
    17.     void OnEnable(){
    18.  
    19.         IT_Gesture.onDraggingStartE += OnDraggingStart;
    20.         IT_Gesture.onDraggingE += OnDragging;
    21.         IT_Gesture.onDraggingEndE += OnDraggingEnd;
    22.     }
    23.    
    24.     void OnDisable(){
    25.  
    26.        
    27.         IT_Gesture.onDraggingStartE -= OnDraggingStart;
    28.         IT_Gesture.onDraggingE -= OnDragging;
    29.         IT_Gesture.onDraggingEndE -= OnDraggingEnd;
    30.     }
    31.  
    32.    
    33.     void Update(){
    34.         //Debug.Log(currentDragIndex+"   "+dragByMouse);
    35.     }
    36.    
    37.     /*
    38.     bool cursorOnUIFlag=false;
    39.     void OnDraggingStart(DragInfo dragInfo){
    40.         if(IsCursorOnUI(dragInfo.pos)){
    41.             cursorOnUIFlag=false;
    42.             return;
    43.         }
    44.        
    45.         cursorOnUIFlag=true;
    46.     }
    47.     void OnDraggingEnd(DragInfo dragInfo){
    48.         if(!cursorOnUIFlag) return;
    49.         if(IsCursorOnUI(dragInfo.pos)) return;
    50.        
    51.         //insert custom code
    52.     }
    53.     */
    54.    
    55.     private Vector3 dragOffset1;
    56.     private Vector3 dragOffset2;
    57.    
    58.     private int currentDragIndex1=-1;
    59.     private int currentDragIndex2=-1;
    60.     void OnDraggingStart(DragInfo dragInfo){
    61.         //currentDragIndex=dragInfo.index;
    62.        
    63.         //if(currentDragIndex==-1){
    64.             Ray ray = Camera.main.ScreenPointToRay(dragInfo.pos);
    65.             RaycastHit hit;
    66.             //use raycast at the cursor position to detect the object
    67.             if(Physics.Raycast(ray, out hit, Mathf.Infinity)){
    68.                 //if the drag started on dragObj1
    69.                 if(hit.collider.transform==dragObj1){
    70.                     Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, dragInfo.pos.y, 30));
    71.                     dragOffset1=dragObj1.position-p;
    72.                    
    73.                     //change the scale of dragObj1, give the user some visual feedback
    74.                     dragObj1.localScale*=1.1f;
    75.                     //latch dragObj1 to the cursor, based on the index
    76.                     Obj1ToCursor(dragInfo);
    77.                     currentDragIndex1=dragInfo.index;
    78.                 }
    79.                 //if the drag started on dragObj2
    80.                 else if(hit.collider.transform==dragObj2){
    81.                     Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, dragInfo.pos.y, 30));
    82.                     dragOffset2=dragObj2.position-p;
    83.                    
    84.                     //change the scale of dragObj2, give the user some visual feedback
    85.                     dragObj2.localScale*=1.1f;
    86.                     //latch dragObj2 to the cursor, based on the index
    87.                     Obj2ToCursor(dragInfo);
    88.                     currentDragIndex2=dragInfo.index;
    89.                 }
    90.             }
    91.         //}
    92.     }
    93.    
    94.     //triggered on a single-finger/mouse dragging event is on-going
    95.     void OnDragging(DragInfo dragInfo){
    96.         //if the dragInfo index matches dragIndex1, call function to position dragObj1 accordingly
    97.         if(dragInfo.index==currentDragIndex1){
    98.             Obj1ToCursor(dragInfo);
    99.         }
    100.         //if the dragInfo index matches dragIndex2, call function to position dragObj2 accordingly
    101.         else if(dragInfo.index==currentDragIndex2){
    102.             Obj2ToCursor(dragInfo);
    103.         }
    104.     }
    105.    
    106.     //assign dragObj1 to the dragInfo position, and display the appropriate tooltip
    107.     void Obj1ToCursor(DragInfo dragInfo){
    108.         //~ LayerMask layer=~(1<<dragObj1.gameObject.layer);
    109.         //~ Ray ray = Camera.main.ScreenPointToRay (dragInfo.pos);
    110.         //~ RaycastHit hit;
    111.         //~ if (Physics.Raycast (ray, out hit, Mathf.Infinity, layer)) {
    112.             //~ dragObj1.position=hit.point;
    113.         //~ }
    114.        
    115.         Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, dragInfo.pos.y, 30));
    116.         dragObj1.position=p+dragOffset1;
    117.        
    118.         if(dragInfo.isMouse){
    119. //            dragTextMesh1.text="Dragging with mouse"+(dragInfo.index+1);
    120.         }
    121.         else{
    122. //            dragTextMesh1.text="Dragging with finger"+(dragInfo.index+1);
    123.         }
    124.     }
    125.    
    126.     //assign dragObj2 to the dragInfo position, and display the appropriate tooltip
    127.     void Obj2ToCursor(DragInfo dragInfo){
    128.         Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, dragInfo.pos.y, 30));
    129.         dragObj2.position=p+dragOffset2;
    130.        
    131.         if(dragInfo.isMouse){
    132. //            dragTextMesh2.text="Dragging with mouse"+(dragInfo.index+1);
    133.         }
    134.         else{
    135. //            dragTextMesh2.text="Dragging with finger"+(dragInfo.index+1);
    136.         }
    137.     }
    138.    
    139.     void OnDraggingEnd(DragInfo dragInfo){
    140.        
    141.         //drop the dragObj being drag by this particular cursor
    142.         if(dragInfo.index==currentDragIndex1){
    143.             currentDragIndex1=-1;
    144.             dragObj1.localScale*=10f/11f;
    145.            
    146.             Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, dragInfo.pos.y, 30));
    147.             dragObj1.position=p+dragOffset1;
    148. //            dragTextMesh1.text="DragMe";
    149.         }
    150.         else if(dragInfo.index==currentDragIndex2){
    151.             currentDragIndex2=-1;
    152.             dragObj2.localScale*=10f/11f;
    153.            
    154.             Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, dragInfo.pos.y, 30));
    155.             dragObj2.position=p+dragOffset2;
    156. //            dragTextMesh2.text="DragMe";
    157.         }
    158.        
    159.     }
    160.  
    161. }
    162.    
    163.  
    164.  
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, try something like this:

    Code (csharp):
    1.  
    2.    public bool moveHorizontalOnly=true;
    3.    public bool moveVerticalOnly=false;
    4.  
    5.    //assign dragObj1 to the dragInfo position, and display the appropriate tooltip
    6.    void Obj1ToCursor(DragInfo dragInfo){
    7.      //get the screen position of the object
    8.      Vector3 screenPos=Camera.main.WorldToScreenPoint(dragObj1.position);
    9.    
    10.      if(moveHorizontalOnly){
    11.        //move horizontal, so we discard the y-axis movement of the drag and use the object default y-axis position on screen
    12.        screenPos=new Vector3(dragInfo.pos.x, screenPos.y, 30);
    13.      }
    14.      else if(moveVerticalOnly){
    15.        //move vertical, so we discard the x-axis movement of the drag and use the object default x-axis position on screen
    16.        screenPos=new Vector3(screenPos.x, dragInfo.pos.y, 30);
    17.      }
    18.    
    19.      //now the screen pos has been modified with only just one axis of movement,
    20.      //transform it back to world space would have the object retain it's position in the other axis
    21.      Vector3 p=Camera.main.ScreenToWorldPoint(screenPos);
    22.      dragObj1.position=p+dragOffset1;
    23.    }
    24.  
    I hope the comment explains the code well enough.
     
    GhulamJewel likes this.
  9. GhulamJewel

    GhulamJewel

    Joined:
    May 23, 2014
    Posts:
    351
    Thank you very much. This works great. Slight problem even though moves vertically or horizontally. The player can drag across the screen and the object will appear where the finger was last lifted! lol

    **solved**

    not to worry solved it with some mathclamps thank you.
     
    Last edited: Jan 1, 2016
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    My guess is you are using the default example script but haven't apply the same change to OnDraggingEnd? That function would set the dragObj position to the drag position as well so you will have to apply the axis limit to that function as well.
     
  11. dharms

    dharms

    Joined:
    Nov 10, 2012
    Posts:
    26
    Hey songtan,

    Sort of a silly question, but do you know a good way to modify the portion of the TapDemo script to make dragging a gameobject usable for XZ axis dragging instead of XY as you have it implemented? I only ask because it seems 'dragInfo' is stored as a Vector2 in IT_Gesture (If I just replace the Z assignment '30' in the script with dragInfo.pos.z, I get errors as it's not a V3) and I didn't want to screw up anything in IT_Gesture for other events.
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, you just need to swap the 40 and dragInfo.pos.y. Like so:
    Code (csharp):
    1. Vector3 p=Camera.main.ScreenToWorldPoint(new Vector3(dragInfo.pos.x, 30, dragInfo.pos.y));
    Now the dragged object should move along xz axis instead of xy axis (the position on y-axis is constant.
     
  13. gringofxs

    gringofxs

    Joined:
    Oct 14, 2012
    Posts:
    240
    i import PlayMakerInputTouches.unitypackage, but ther are to many errors in unity 5


    Assets/PlayMaker Input Touches/Internal/Actions/InputTouchesGetPosition.cs(10,48): error CS0246: The type or namespace name `FsmStateAction' could not be found. Are you missing a using directive or an assembly reference?

    How i can solve this?
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm sorry but I'm afraid I'm not the one responsible for the PlayMaker/InputTouch integration. You would have much better luck asking the PlayMaker dev team.

    From the error tho, it sounds like there are some missing dependency in your project. Perhaps you have accidentally delete some files or haven't got all the necessary files imported?
     
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Just a quick announcement that I'll be away for 2 weeks starting tomorrow. During that period I may or may not have internet access so I might be a bit slow in respond on any issue/post. Also since I won't be having access to my work station, some issue will have to wait until I'm back. My apologies for any inconvenience in advance.
     
  16. dharms

    dharms

    Joined:
    Nov 10, 2012
    Posts:
    26
    Hey songtan, thanks for the quick reply. I tried that as well and for some reason it's not keeping the Y constant. Dragging the object makes the Y value change as well. I double checked and it's applied as you mentioned in each portion of the script. Any idea what could cause that? My object has a rigidbody and a box collider.

    edit: For the meantime I got it working by applying this script to the gameobject that locks the y position on lateupdate, but you may have a better solution. I also apologize for asking about your demo script as it isn't directly related to the touch events but nonetheless, I really appreciate it!

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LockYAxis : MonoBehaviour {
    5.  
    6. float yPos;
    7.  
    8.     void Awake ()
    9.     {
    10.         yPos = transform.position.y;
    11.     }
    12.  
    13.     void LateUpdate ()
    14.     {
    15.         transform.position = new Vector3(transform.position.x, yPos, transform.position.z);
    16.     }
    17. }
     
    Last edited: Feb 1, 2016
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    My apologies, I think I have misunderstood the my own code. So the code is actually camera angle dependent. The default code depends on the camera to look in the direction of z-axis (as it's setup in the demo). If you swap the y and z value like I suggested in my earlier post, the camera will have to point toward y-axis. So everything is very much depend on the camera angle. If your camera is not aligned to either axis (using an isometric view for instance), I'm afraid the existing code wouldn't work. In that case, the easiest way to do that would be to put a plane collider on xz-axis, and use raycast to see which point the cursor is hitting on. Something like this:
    Code (csharp):
    1.  
    2. Ray ray = Camera.main.ScreenPointToRay(dragInfo.pos);
    3. RaycastHit hit;
    4. if(Physics.Raycast(ray, out hit, Mathf.Infinity)){
    5.    transform.position=hit.point;
    6. }
    7.  
     
  18. tealm

    tealm

    Joined:
    Feb 4, 2014
    Posts:
    108
    Hello, is it possible to stop preceding related drag events from happening if certain conditions are fulfilled in the onDraggingStartE event?

    Ie:
    Code (CSharp):
    1. void OnDraggingStart(DragInfo dragInfo)
    2. {
    3.     if(sth == true) return false;
    4. }
    Which would stop onDraggingE and onDraggingEndE events to not trigger?
     
  19. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, you can try something like this:
    Code (csharp):
    1. private bool ignoreDragNEnd=false;
    2.  
    3. void OnDraggingStart(DragInfo dragInfo){
    4.    //check condition
    5.  
    6.    if(condition){
    7.      ignoreDragNEnd=true;
    8.    }
    9.    else{
    10.      ignoreDragNEnd=false;
    11.    }
    12. }
    13.  
    14. void OnDragging(DragInfo dragInfo){
    15.    if(ignoreDragNEnd) return;
    16. }
    17.  
    18. void OnDragginEnd(DragInfo dragInfo){
    19.    if(ignoreDragNEnd) return;
    20. }
    onDraggingStartE will always fire before onDraggingE and onDraggingEndE. So in the code above, we check the condition in OnDraggingStart to determine if we should ignore the subsequent function call.[/CODE]
     
  20. habsi70

    habsi70

    Joined:
    Jan 30, 2013
    Posts:
    25
    Hello,
    in a current project I use input-touches to page through a book. Everything is straight forward and works just fine. There is just one thing, that I came across after implementing all my paging-logic: A drag event is ended when another touch occurs while dragging. Is there a way to prevent this or continue the drag event? I ask because catching the dragEnd Event now causes a lot of change in the paging-logic.
     
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, you can try enable multi-drag. That should stop the drag event to end whenever there's more than 2 touch on the screen. However I'm not sure if that would interfere with your logic when there's two drag event occur simultaneously.

    The other alternative would be to change the code in DragDetector.cs itself. You can try change the line183 to while(Input.touchCount>0){. This would allow the drag event to continue even when there's multiple finger on screen. However I'm not entirely sure if another touch on screen would disrupt the readings for on-going drag event so please keep that in mind.
     
    habsi70 likes this.
  22. habsi70

    habsi70

    Joined:
    Jan 30, 2013
    Posts:
    25
    Thank you very much for your quick reply. I will try both solutions. If it does not work I will have to go the longer way, but it would be nice not to spend too many hours.

     
  23. habsi70

    habsi70

    Joined:
    Jan 30, 2013
    Posts:
    25
    fyi: the second solution worked perfectly, thank you again. That saved me a ton of rewriting my code.
     
  24. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    This thread is long and the searches are not working right. I am trying to figure out if the swipe (like moving the ball in the swipe demo) is platform independent. I hacked the demo to work more like I wanted.. (removed the part that made the ball goto where the finger is)... and just left it where the ball moves if swiped. it works well! The camera can even have code to follow it when pointing down at the ball... though I wanted to transfer this to my game with a 3rd person camera and it seems like swipping up does not make the ball go up. I am sure its a vector issue or I am misunderstaning how to use the swipe (dove right in) so just a nudge in what to look at? It seems very dependent on the camera orientation... hopefully this thread is semi active still I just bought the input touches asset...



    Camera code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Baby_Camera : MonoBehaviour {
    5.  
    6.     public Transform target;
    7.  
    8.     public float distance = 5.0f;
    9.     public float height = 4.0f;
    10.  
    11.     public float heightDamping=2.0f;
    12.     public float rotationDamping=3.0f;
    13.     public float distanceDampingX=1f;
    14.     public float distanceDampingZ=1f;
    15.     public bool smoothed=true;
    16.  
    17.     void LateUpdate() {
    18.         if(!target)
    19.             return;
    20.  
    21.         float wantedRotationAngle = target.eulerAngles.y;
    22.         float wantedHeight = target.position.y + height;
    23.         float wantedDistanceZ = target.position.z - distance;
    24.         float wantedDistanceX = target.position.x - distance;
    25.  
    26.         float currentRotationAngle = transform.eulerAngles.y;
    27.         float currentHeight = transform.position.y;
    28.         float currentDistanceZ = transform.position.z;
    29.         float currentDistanceX = transform.position.x;
    30.  
    31.  
    32.         currentRotationAngle=Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping*Time.deltaTime);
    33.  
    34.  
    35.         currentHeight = Mathf.Lerp(currentHeight, wantedHeight, heightDamping*Time.deltaTime);
    36.         currentDistanceZ = Mathf.Lerp(currentDistanceZ, wantedDistanceZ, distanceDampingZ *Time.deltaTime);
    37.         currentDistanceX = Mathf.Lerp(currentDistanceX, wantedDistanceX, distanceDampingX *Time.deltaTime);
    38.  
    39.         Quaternion currentRotation = Quaternion.Euler(0, currentRotationAngle, 0);
    40.         transform.position -= currentRotation*Vector3.forward*distance;
    41.  
    42.         transform.position = new Vector3(currentDistanceX, currentHeight, currentDistanceZ);
    43.         //transform.position.x = currentDistanceX;
    44.         //transform.position.z=currentDistanceZ;
    45.         //transform.position.y=currentHeight;
    46.  
    47.         LookAtMe();
    48.  
    49.     }
    50.     // Use this for initialization
    51.     void Start () {
    52.  
    53.     }
    54.  
    55.     // Update is called once per frame
    56.     void Update () {
    57.  
    58.     }
    59.  
    60.     void LookAtMe()
    61.     {
    62.         float camSpeed = 2.0f;
    63.  
    64.         if(smoothed)
    65.         {
    66.             Quaternion camRotation = Quaternion.LookRotation(target.position-transform.position);
    67.             transform.rotation = Quaternion.Slerp(transform.rotation, camRotation, Time.deltaTime*camSpeed);
    68.         }
    69.         else
    70.         {
    71.             transform.LookAt(target);
    72.         }
    73.     }
    74. }
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The reason why the ball doesn't move up when swipe is that the code doesn't account for vertical movement. The original demo is intended for full top down view and thus the ball only move in x and z axis (horizontal plane). The only thing the camera affects is the starting point of the ball movement (It starts at where the swipe starts).

    To have the ball move in vertical axis you will have to do some modification to the code. The problem is it's not always straight-forward to translate a 2-axis input such as swipe to a 3-axis action (move the ball in 3D space). You will have to have some kind of algorithm that do that.
     
  26. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    I might of misspoke: When I said up, I didn't mean off the ground I really meant forward. It is like the vector/direction changes. The 3d camera changes and rotates depending upon speed etc of the player. I really was hoping to have it where swiping up would add the force in that general direction etc. I wish I could post a demo to show how it behaves... would make more sense. hmmm Ty for the fast reply
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I see. I'm not sure what went wrong exactly. At any rate, the demo script is set to work in a very specific setting with a fixed camera. it's very unlikely that it will behave like how you expect it in a different setting.
     
  28. Lindrae

    Lindrae

    Joined:
    Jun 13, 2013
    Posts:
    8
    Hi Songtan,

    I have been playing with the multitap detection and I am experiencing a kind of an extra delay before things are triggered when Enable MultiTap Filter is ON.
    So I have been looking to your code, trying to figure out stuff, and it seems I spotted a small possible improvement in IT_Gesture.TapCoroutine :
    When a tap is detected, the coroutine is waiting maxMultiTapCount*maxMultiTapInterval seconds before triggering the multitap. Say for a double tap, with a 1 second max interval, it would wait 2 seconds after the first tap, whereas it should wait 1 second from the first tap to record the second tap isn't it ?

    If you agree the code should then be :
    Code (CSharp):
    1. IEnumerator TapCoroutine(Tap tap){
    2.         yield return new WaitForSeconds((maxMultiTapCount-1)*maxMultiTapInterval); // added -1 to MaxMultiTapCount
    3.        
    4.         if(tapExisted==tap.count){
    5.             tapExisted=0;
    6.             if(onMultiTapE!=null) onMultiTapE(tap);
    7.         }
    8.     }
    I tested it a little bit and it seems to be working, but you are the boss ;)
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You sir, are absolutely right. I've made the change so this will be the case in future update. Thanks a bunch for the feedback and suggestion. :)
     
  30. Lindrae

    Lindrae

    Joined:
    Jun 13, 2013
    Posts:
    8
    So glad I could participate a tiny bit to your great asset :)
     
  31. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    how can i use it for gui?
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, this package doesn't contain any visual gui element. You can only use it to detect certain mouse/touch input.
     
  33. usernameHed

    usernameHed

    Joined:
    Apr 5, 2016
    Posts:
    93
    Hello, i have a little problem, I hope someone can find out:

    I use RTS Cam on an object. At some point, i desactivate the script RTS Cam. then i move in the code the position of the Main Camera manualy (And I make sure that the camera always looks at the focus object). And then I want to reactivate the RTS Cam script and... the camera return to it's original position... why ?

    Thanks !

    EDIT: my bad... i was translating the mainCamera, and I should rotate the CameraParent !
    sry !
     
    Last edited: Feb 2, 2017
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure if I fully understand the problem here. So the problem is solved?
     
  35. Maosoto

    Maosoto

    Joined:
    Aug 22, 2014
    Posts:
    5
    Hello. Im looking to buy this asset but I need to understand something. Will be possible to have multitouch on 2 or 3 images at the same time. For example to change position and rotation of the images by 2 or 3 diferent users on a Windows PC touch screen?. Also this will work with unity event system so I can mix this with UI buttons and 3d touches implemented in Unity touch system?. Thanks
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It depends on the input type. For instance, you can have multiple fingers touching or dragging on the screen, each interacting with a different object. But if you are using pinch or rotate, there can be only one input at any given time. Also, The last time I checked (mind you this is quite some time ago), touch input does not work with some window touch screen. So I can't guarantee that the plugin is compatible for what you are looking to do.

    Sadly no, it doesn't work with unity UI system. You will have to do your own integration.
     
  37. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Maybe you answered this before... but, I have a simple grid-based 2d game which lets the user drag rows or columns. They should be able to drag multiple rows simultaneously if they want to.

    I have the drag events working, but I can't see how to keep track of multiple drags.

    Let's say the startdrag event fires and I figure out which row the finger is in, then start dragging that row.

    When the continuedrag event fires, how can i tell which row to continue dragging, given e.g. one finger might stay stationary and another may be moving?

    similarly with enddrag, how will i be able to tell that this 'ending of a drag' corresponds to a drag which began on a certain row? especially if the finger maybe slipped up the screen and is over a different row?

    so like, how do you discreetly keep track of individual 'finger actions', like 3 separate drag operates, and keep those drags separate, and allow each one to receive the proper events to move only the rows the events relate to?

    like on enddrag I can figure out from DragInfo.pos where the finger is 'now', but this has nothing to do with which row "that finger" touched when the drag began.
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for the slow respond.

    You can check which finger is corresponding to which drag event by checking the value of index of the DragInfo passed. Each time a drag is initiated, it will be assigned a index value that is unique to the drag sequence. So when you have multiple drag sequence going on, you can use that index value to determine which event belongs to which sequence. Make sense?
     
  39. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    ah yes i see it now, wonderful, thank you! your asset is really helpful :)
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thank you!
     
  41. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'm using this in my game, working well so far. Only one thing I noticed, if I open a screen resolution which is not the native full resolution, e.g. I open 1024x768 on a 1920x1080 display, while the system automatically scales the screen to fit, the "pos" coordinate in the drag/click event object (dragdata etc) seems to have coordinates that are relative to the top left of the physical screen and not the top left of the actual screen.... cus there are black bars on either side. So instead of returning 0,0 when the mouse etc is actually in the top left of the visible area, it returns some other higher number as though the 0,0 origin is in the top left of the black bar area.

    I had to workaround this by, instead of opening a specific resolution, instead checking the resolution and if it was e.g. >1280 wide or high, halving the resolution, so that the native res is still showing a full-screen display. Any res I choose whose aspect ratio is different to the native display ends up with black bars (normal) and then the coordinates are off. Not sure how to account for this as I don't think you can get any grasp of what the native res is in comparison without opening in native res first and getting a feel for it ?
     
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've to say I'm not aware of this and don't know any solution on top of my head. Unfortunately I'm away for the week. I'll try to look into this as soon as I can. Very sorry for the inconvenience.
     
  43. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    It might not be your issue, it may just be how the system does this sort of thing. I did a workaround where I detect the screen width and height (which starts off with native resolution) and if it's above say 1280 pixels then I halve those numbers and set the new resolution. This works, then e.g. on iphone I don't get any black bars and the coordinates of clicking work fine because the res matches the full space of the screen. I'm not sure whether to say this is a unity thing or just a device/apple thing or something with your tool. If it's just how the device behaves and reports coordinates that way, there isn't a whole lot to do about it other than workarounds.
     
  44. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are right. I've done some testing of my own. It's just how the system handle the scaling. My code doesn't interfere with any of this. It simply pull the value from the system.
     
  45. Catttdaddy

    Catttdaddy

    Joined:
    Mar 17, 2015
    Posts:
    55
    I am using unity 2018.1.1f1 and a number of the Demos do not work. The OrbitCam, RotateObject and RTSCam demos do not work.
    I am also attempting to have a Icon follow multiple touches. I have edited the SwipeDemo code in an attempt to have swipes follow my fingers. It seems like I can get one to work at a time but touches can not be detected.
    Also when I use particles in this demo, they seem to be too close to the camera. Can anyone help me with these problems?
     
  46. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'll take a look at the issue where the demos doesn't work. Unfortunately I'm currently away from work for a few days so it will have to wait until Friday.

    I'm not sure what exactly is the issue with the particle you are using without actually see how it looks like. It could be that they are indeed too close to the camera, or just the size of the particles.
     
  47. Catttdaddy

    Catttdaddy

    Joined:
    Mar 17, 2015
    Posts:
    55
    Please look into it. I can not get any of the gesture demos working. Thank you
     
  48. Catttdaddy

    Catttdaddy

    Joined:
    Mar 17, 2015
    Posts:
    55
    I am attempting to make a touch Icon. The Swipe demo lags behind quite a bit. Is it a way to make it follow the touches directly?
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've just tested the demo using Unity2018.1, both in editor and on a touch device. They work just fine. Can you elaborate how they doesn't work? Do you see any error message?

    Swipe demo are a bad example if you want to make an icon to follow the cursor/finger position. Try the drag object in TapDemo.
     
  50. Catttdaddy

    Catttdaddy

    Joined:
    Mar 17, 2015
    Posts:
    55
    I reloaded the asset into a new project and it did work. Thanks.
    I do have a question about how to implement the rotate. I can get the swipe rotate like in the demos. Do you have a gesture for a "2 finger twist" gesture to rotate?