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
    Thanks for your purchase. First you must understand, this package simply provides you a mean to detect various input sequence/gesture. But it doesnt cover the mechanic of you application after the input is detected. It would simply be impossible to do that. Every user uses the same input for different purpose, there's no way to have a generic solution that fit every need out there. Although some of the demo might seem to do what you need, please keep in mind they are just generic demo and examples of what the package can do how it can be used. They are not there to fit a particular type of application. Even if by coincidence the examples fits what you need, it's very likely that you will need to do some tweaks.

    In short, you will have to implement the application yourself. This package is just there to save you the trouble to write the input detection logic.

    instead of using onSwipeEndE, try to use onSwippingE. Then you object will rotate even when swiping.

    you can use onMultiTapE to detect if an object has been selected. If yes, store the object in an local reference. Then whenever a pinch is detected, you can then zoom your camera towards the reference object. It would probably be a lot easier if your camera is always focus on the object selected. Means as soon as the object is selected, your camera view will centered around that object.

    I'm not sure how proficient you are in coding so I'm just explaining this briefly. If you are struggling with any of that, please let me know and I'll give you some example code.
     
  2. JayCrossler

    JayCrossler

    Joined:
    Jul 10, 2013
    Posts:
    10
    Thanks. That helped. I'm happy implementing my own game play, I was just having trouble linking the great tools you've built into the best ways to implement them. I've made progress, and would love your feedback.

    On issue that it might be worth adding to the documentation is how best to handle inputs on multiple objects that all have the same script. The issue is that if I have a listener in the script, the listener fires on every object any time any of them have a touch on it. I'm not sure if I'm doing it correctly, but here's my solution.

    For example I have many planets that all have a 'rotator.js' script on it. Here's a simplified version of that script, which others might be able to use:

    Code (csharp):
    1.  
    2.     var turnSpeed:float = 0;
    3.     var originalTurnSpeed:float = 0;
    4.  
    5.     var scale:float = 1;
    6.     var originalScale:float = 1;
    7.  
    8.     function OnEnable(){
    9.         Gesture.onSwipingE += OnSwiping;
    10.         Gesture.onPinchE += OnPinch;
    11.     }  
    12.     function OnDisable(){
    13.         Gesture.onSwipingE -= OnSwiping;
    14.         Gesture.onPinchE -= OnPinch;
    15.     }
    16.     function DoesRayHitTransform(pointToCheck:Vector3):boolean{
    17.         var ray:Ray = Camera.main.ScreenPointToRay(pointToCheck);
    18.         var hit:RaycastHit;
    19.         var isHit:boolean = false;
    20.         if(Physics.Raycast(ray, hit, Mathf.Infinity)){
    21.             isHit = (hit.transform == transform);
    22.         }
    23.         return isHit;  
    24.     }
    25.  
    26.     function OnSwiping(sw:SwipeInfo){
    27.         if (DoesRayHitTransform(sw.startPoint)) Swiping(sw.direction.x);
    28.     }      
    29.     function Swiping(amount:float){
    30.         turnSpeed -= amount;
    31.     }
    32.     function OnPinch(pi:PinchInfo){
    33.         var midPoint = (pi.pos1+pi.pos2)/2;
    34.         if (DoesRayHitTransform(midPoint)) Pinch(pi.magnitude);
    35.     }
    36.     function Pinch(magnitude:float){
    37.         var magChange:float;
    38.         if (magnitude<0){ //Pinching out
    39.             magChange=-magnitude;
    40.             magChange=Mathf.Clamp(magChange,1,1.5);
    41.         } else if (magnitude>0) { //Pinching in, shrink
    42.             magChange=1-(magnitude/100);
    43.             magChange=Mathf.Clamp(magChange,.8,1);         
    44.         }
    45.         scale*=magChange;
    46.     }
    47.  
    48.     function Start () {
    49.         originalScale = transform.localScale.x;
    50.         originalTurnSpeed = turnSpeed;
    51.     }
    52.     function Update() {
    53.         turnSpeed = Mathf.MoveTowards(turnSpeed,originalTurnSpeed,1);
    54.         turnSpeed = Mathf.Clamp(turnSpeed,-1000,1000);     
    55.             transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
    56.  
    57.         scale = Mathf.MoveTowards(scale,originalScale,0.013);
    58.         scale = Mathf.Clamp(scale,0.35,5);
    59.         transform.localScale = Vector3(scale,scale,scale);
    60.     }
    61.  
    As a note, figuring out Pinching was a pain. It looks like the section on PinchInfo is missing from the included PDF. I was able to see from the 'DualFingerDetector.js' that it returns (Magnitude, pos1, pos2). The above numbers got an effect I liked, but should be tweaked and made into a more generic class - once I test on other devices, I'll do that.

    If these are of use, feel free to add them or something like them to the next version's examples - hopefully it will save someone time. Or, if anyone has suggestions, they might help me improve.
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can have a master listener that do all the listening so the event only fires on the master. The master can then forward the the event to the object being acted on. Sort of like the example in TapDemo. There's only 1 script instance that listen to the event but there's multiple objects in the scene that can react to the events. The master listener script can look like this:


    Code (csharp):
    1.     function OnEnable(){
    2.         Gesture.onSwipingE += OnSwiping;
    3.         Gesture.onPinchE += OnPinch;
    4.     }  
    5.     function OnDisable(){
    6.         Gesture.onSwipingE -= OnSwiping;
    7.         Gesture.onPinchE -= OnPinch;
    8.     }
    9.  
    10.     function OnSwiping(sw:SwipeInfo){
    11.         var rotaterInstance:rotater=GetObjectScriptInstance(midPoint);
    12.         if(rotaterInstance!=null){
    13.             rotaterInstance.Swiping(sw.direction.x);
    14.         }
    15.     }
    16.  
    17.     function OnPinch(pi:PinchInfo){
    18.         var midPoint = (pi.pos1+pi.pos2)/2;
    19.         var rotaterInstance:rotater=GetObjectScriptInstance(midPoint);
    20.         if(rotaterInstance!=null){
    21.             rotaterInstance.Pinch(pi.magnitude);
    22.         }
    23.     }
    24.    
    25.     function GetObjectScriptInstance(point:Vector3):rotator{
    26.         var ray:Ray = Camera.main.ScreenPointToRay(point);
    27.         var hit:RaycastHit;
    28.         var rotaterInstance:rotator;
    29.         if(Physics.Raycast(ray, hit, Mathf.Infinity)){
    30.             rotaterInstance=hit.transform.gameObject.GetComponent(rotator);
    31.         }
    32.         return rotaterInstance;
    33.     }
    34.  
    You can then remove the OnEnable and OnDisable in rotator.js. Make sure you make Swiping() and Pinch() public as well.

    I'm sorry for the missing information in the documentation. Must have missed it. I'll check. Thanks for your offer for using the your code.
     
    Last edited: Jul 25, 2013
  4. ncano

    ncano

    Joined:
    May 21, 2013
    Posts:
    2
    Hi, I bought Input.Touches and noticed that the "ProjectileObject" in the demo scene "SwipeDemo" sometimes passes through the outside walls and some inside obstacles i added to the scene, if you could suggest or point me to a solution for this?
     
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    If that happen, the problem is the speed of the ProjectileObject is too high for the framerate you are running the scene in. It move past the collider which should have stop it before the physics calculation take place in each frame. You can thicken the walls or limit the speed of the ProjectileObject.

    To limit the speed, just change line38 in SwipeDemo from body.AddForce(new Vector3(sw.direction.x, 0, sw.direction.y)*speed); to

    float speed=Mathf.Min(sw.speed*0.0035f, 15);
    body.AddForce(new Vector3(sw.direction.x, 0, sw.direction.y)*speed);

    or line35 in SwipeDemo.js to

    var speed:float=Mathf.Min(sw.speed*0.0035, 15);
    body.AddForce(Vector3(sw.direction.x, 0, sw.direction.y) * speed);

    You can adjust the value 15 to increase or decrease the maximum top speed.
     
  6. ncano

    ncano

    Joined:
    May 21, 2013
    Posts:
    2
    Thanks for the quick answer, I'll play with that setting and report back the results.
     
  7. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello songtan
    i try to run the demoTap scene and it come up with some warning, i can t run the scene anymore on the latest unity 4.2

    here the error
    NullReferenceException: Object reference not set to an instance of an object
    ChargeModeSwitcher.OnGUI () (at Assets/InputTouches/ExampleScripts/C#/Demo/ChargeModeSwitcher.cs:29)

    any idea?

    thanks
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm very sorry I dont have the specific names or detail right now. But as far as I can remember it's a missing assignment. Look for a component in the scene name ChargeModeSwitcher, it should be together with TapDemo. In the inspector, make sure the TapDemo component is assigned. You can just drag the gameObject contain the TapDemo component into the slot.

    Please let me know if that's the case or not.
     
  9. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    ah yes that solve the issue, thanks a lot
    a got another warning but it s not so important, here if you want to look into

    The class defined in script file named 'General' does not match the file name!

    cheers
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for letting me know, it's just the naming conflict. I'll look into it. You can fix it easily by changing the name of either the class in the script or the script name itself/
     
  11. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    does input touches support window8? i build my ios game for windows. i run it on my friend's Lenova yoda ultrabook. it worked as single touch capable. have you tested it on windows 8?
     
  12. ikaria

    ikaria

    Joined:
    Mar 31, 2012
    Posts:
    10
    Has anyone used input.touches with NGUI? Wondering if it's a good idea to use both simultaneously + if there are any recommended ways of doing so. Really like the simplicity + robustness of Input.touches. Was hoping to only use NGUI for interface elements...
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @atmuc, very very sorry for the slow respond. For some reason the notification system has stopped working for the past 2 days. I've only seen your post now. To answer your question, no I havent test it on window8. But fyi, InputTouches is all written using native unity Input class. So in theory anything that is supported by Unity should work. Unity4.2 does support window8, but does it goes as far as support the touch input on all device? I really cant say for sure.

    @ikaria, I'm not aware of anyone doing that. They should work fine together. But I suppose it depends on what you plan to use InputTouches for. I imagine you can use NGUI for interface elements and InputTouches as the mean to interact with in gameObject without too much issue.
     
  14. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It depends on what you mean by "do something"?

    I did check on the package. It's proprietry and it's not a free-ware. I cant just obtain a copy and package what I can use to InputTouches. And since it provide gesture input library of it's own, there's really no point to make InputTouches to read the primitive touch input from it and try to intepret it as various gesture.
     
  16. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    unity said it works for windows store apps. i think it is related with native api and unity did not cover it on windows desktop applications.
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    So I guess InputTouches does not work on desktop environment. Sorry to dissapoint but it's not my plan to add an external plugin. I very much like to keep it simple by using only unity native api. And honestly, I dont have the resource to support that.
     
  18. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i found this as free.

    http://interactivelab.github.io/TouchScript/

    i also examine FingerGestures if it supports Standalone Windows Desktop Applications.I also have no time to integrate multitouch to my windows apps, i should find working one :)
     
  19. _Max_

    _Max_

    Joined:
    Feb 21, 2013
    Posts:
    160
    Is there a script included that will on - Double Tap iOS screen

    Code (csharp):
    1.  
    2.  function Update () {
    3.      
    4.  if (Input.touchCount == 1) {
    5. if (Input.GetTouch(0).tapCount == 2) {
    6.          ToggleMaterial();
    7.          
    8. //Input.touchCount: Number of touches. Guaranteed not to change throughout the frame. (Read Only)
    9. //Input.GetTouch: Returns object representing status of a specific touch. (Does not allocate temporary variables).
    10. //Touch.tapCount: Number of taps
    11.  
    12.        
    13.         }
    14.         }
    15.      
    16.     function ToggleMaterial() {
    17.         currentMaterial++;
    18.         if (currentMaterial == skies.length) {
    19.             currentMaterial = 0;
    20.         }
    21.         RenderSettings.skybox = skies[currentMaterial];
    22.         skyNameGuiText.text = skies[currentMaterial].name;
    23.     }
    24.  
    Currently using the above but it is buggy as when I double tap it jumps a few materials at a time, wish for it just to goto the next?

    Any ideas?
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    With InputTouches, you can do something like this:

    Code (csharp):
    1.  
    2. void OnEnable(){
    3.     Gesture.onMultiTapE += OnTap;
    4. }
    5.  
    6. void OnDisable(){
    7.     Gesture.onMultiTapE -= OnTap
    8. }
    9.  
    10. void OnTap(TapInfo tapInfo){
    11.     if(tapInfo.tapCount==2){
    12.         ToggleMaterial();
    13.     }
    14. }
    15.  
    I guess it's pretty similar to what you have right now. But it's quite robust as far as I can tell.
     
  21. _Max_

    _Max_

    Joined:
    Feb 21, 2013
    Posts:
    160
    Thanks songtan, do you happen to have a manual or instructions for your package for noobies?
     
  22. Song_Tan

    Song_Tan

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

    Unfortunately the documentation is as simple as I can imagine. Can you let me know what you are struggling with? Getting the events to work? Or working the information getting from the specific gesture event to a specific task. If the former, there's a section "Notes on Using Events" in the documentation for those who are not familiar with event delagate. Anything beyond that I would be giving coding tutorial. For the later, please understand that the this is a very generic library providing you instance of the gesture and any information you might need to do stuff based on that. It's impossible for me to cover all aspect of how this info might be used. I assume the user to understand the nature of the gesture they want, the information associated with it. The rest is a matter of understanding how Unity work.

    If you are struggling to implement a specific thing, please feel free to ask me about it. If it's possible, I'm happy to write you a snippet of code where you can use it as a base example to start work.
     
  23. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Your package is very good! ---but alas, I wonder about Gesture.OnMultiTapE. It occurs for tap.count values of 1 and 2. But when doing so it occurs first for 1, then again for 2. Not really that smart or useful! Also would need to extend it to indefinite numbers of short-taps, so that it smartly observes a certain delay in taps and accumulates them first, then raising a single event when all short-taps have been performed. Whether the number of taps was 2 or 3 or 5 or whatever. So I wouldn't want it first to raise with tap.count=1 and then again with tap.count=2 before finally doing it with the tap.count=3 I was looking to capture, for example..

    What do you think, could Input.Touches be slightly refined to handle such fairly simple needs?

    Another thing: the Vector2 screen coordinates (in onShortTapE, onDoubleTapE etc.) seem to be always in terms of the native screen resolution, not the current screen resolution? So when I do Screen.SetResolution(Screen.width/2, Screen.height/2) then the coords work weirdly / not at all, but if I don't change the resolution they work fine... would be much more intuitive to always have them in terms of the current screen resolution, not the "original" / native one. Probably you just take what Unity gives you but this kind of "utility" / post-processing is exactly what a "higher-level touch solution" like Input.Touches would be the ideal place for ;)
     
    Last edited: Sep 6, 2013
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It can be done of course. But I'm refrained from doing that. The problem is it's fine when you are only looking for a tap with a specific tap.count only. Let's say in other application where single tap and double tap is needed. So every time a user single tap (tap.count=1), the event wont fire immediately until a delay has past that the code has determined that no second tap is taking place. The delay will gets longer with the maximum tap.count the application try to detect. So you are using triple-tap in your application, imagine you have single-tap input in your application as well. Say the maximum time spacing between each tap in a multi-tap input is 0.3s, each of your single tap would have at least 0.6s delay in their detection.

    For me, there's almost always a way to get past the repeat event (it can be as easy as using a if statement to filter out the tap event with wrong tap.count), but there's no excuse for a simple single tap input to have a delay that make it feel less responsive to the user. Having said that, I could try to add such filter. But I've been very busy with other more pressing stuff lately so it could take a while. Just dont hold your breath to it.


    I've never run into problem like this so forgive me for not aware of it. Let me have a look at it. I can probably come up with something.
     
    Last edited: Sep 6, 2013
  25. TimB

    TimB

    Joined:
    Jan 19, 2011
    Posts:
    65
    Would it be possible to change the static "5" in TapDetector.cs

    Everywhere you have:
    Vector2.Distance(lastPos, startPos)<5

    To:
    Vector2.Distance(lastPos, startPos)< multiTapPosSpacing

    Or to some other "StationaryTap" variable? I've done it in mine, but would be nice to not have to do each upgrade.

    Thanks.
     
  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Very well, a fair point. Consider it done. :)
     
  27. TimB

    TimB

    Joined:
    Jan 19, 2011
    Posts:
    65
    Thanks, I appreciate it!
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @metaleap, I've spent some time trying on the SetResolution(). It seems that the input cursor position is always in accordance to the application screen resolution, not the system full screen resolution. So I dont see why that could pose an issue. Unless you are running in unity Editor. At any rate, you can easily do the conversion using this function:

    Code (csharp):
    1.     public static Vector2 ConvertToCurrentResolution(Vector2 inPos){
    2.         Vector2 outPos=Vector2.zero;
    3.         outPos.x=(int)(inPos.x*(float)Screen.currentResolution.width/(float)Screen.width);
    4.         outPos.y=(int)(inPos.y*(float)Screen.currentResolution.height/(float)Screen.height);
    5.         return outPos;
    6.     }
    Btw, I have added an option to enable filter for dupliate tap event for multi-tap. Having tested it, I still think the delay is pretty awful... Anyway, I'm hoping to submit an update within this few days. If you are keen to try this, please email me and I'll send you an advance copy.
     
  29. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Yes would much appreciate it, thanks!

    Regarding the multi-taps I mentioned earlier, don't worry about it, I can check for delays and wait the number of taps myself where it makes sense. You're right it's app-specific. So maybe only in one level I have a door you need to knock 3 times, I would wait for up to 3 taps only when in the vicinity of the door. In fact, probably would do this slightly differently even then. I now found the "max multi-tap count" property on the Gesture prefab, that's all I need really.

    Regarding the screen resolution situation: will debug what's going on there on my devices and report back later.

    Last question: often my double-taps, when performed fairly shortly/quickly, are only recognized/reported in the Editor's Game View but not on the devices where I have to double-tap a bit slower for it to notice them and process them as double-taps. I'm using onMultiTapE here, not onDoubleTapE. How do you think I should modify the "short-tap time" and/or "multi-tap interval" options in Tap Detector so that on-device I can double-tap quite fast-and-short and still pick those taps up as multi-taps?
     
    Last edited: Sep 7, 2013
  30. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    You may ignore this "issue", that was just my code being messy.
     
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I suspect this has everything to do with the slower framerate of the apps on the device. Check the framerate when running the application on the device, if it's anything lower than 15 then that's probably it. The problem is when you have a slow framerate or when you have a lag sipke, both of your tap may land on the same frame. So it's registered as tap that happen concurrently, not one after another.
     
  32. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Yeah, again I think you're right there. I did have laggy FPS when that occurred, and now that it's faster the issue is gone.
     
  33. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    So there's DragDetector and DragDetector_AndroidFix. What's the story here? Use the latter only for Android and the former for all others? Or does the latter also work just as well with all others? Or is the former an old outdated script still lingering in your codebase but the latter is your "official way of drag detection"?
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Both should works, the only difference between those two are the retrival of the deltaPosition of the cursor when dragging is in process. For some reason the native touch.deltaPosition doesnt work for some of the Android devices. So if you are not building for Android, DragDetector.cs will do. Otherwise I would recommend you to use DragDetector_AndroidFix.cs.
     
  35. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Interesting! Why do you have 2 separate scripts -- rather than either a runtime platform check or (even better) compile-time #if directives? Not a big deal on the one hand, one the other hand whenever you fix something in 1 of the 2 drag scripts you'd have to remember to do so also in the other script..
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are absolutely right. I was trying to do a quick fix for someone. The thought of using a platform dependent compilation has never cross my mind. I'll make sure it's done in the subsequent update.
     
  37. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Dear songtan,

    This is a very interesting packages. Because I' m developing a project with LeapMotion, you plan to support this device?

    https://www.leapmotion.com/

    Thanks
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for your interest but I think not. From what I understand, what Leapmotion does is 3D gesture recognition. On the other hand, InputTouches just interpret the touch info on a screen and try to recognise it as certain type of on screen gesture. So I dont think these two are the same thing at all. I dont see how my InputTouches is going to fit in.
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    A quick note that a new update has gone live on AssetStore. It's a minor update. The only addition would be the tap multiTap event filter. Anyway, here's the full list:
    • Add option for multi-tap filter. Remove any prior tap event with lesser tap-count before the final tap event in a multiTap event.
    • A tap can now go on (being held down) for as long as needed
    • Added missing information to the documentation - pinch and rotate info
    • DragDetector_AndroidFix.cs has been merge into DragDetector.cs
     
  40. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Good stuff! Only one question left, why are there two separate Gesture.prefab files? :D
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Oh, my mistake. There's one that was intended for Android. I just forgot to remove the it. But since I've remove DragDetector_AndroidFix.cs so that one of them should have got a missing component. Just dont use that one.
     
  42. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    This will sound crazy but ... Input.Touches has a handful of foreach statements, over time such statements accumulate unnecessary garbage adding to GC overhead when the GC does run:

    http://www.reddit.com/r/Unity3D/comments/1m667q/060_fps_in_14_days_what_we_learned_trying_to/

    11x in TapDetector.cs, plus 1x each in SwipeDetector.cs, PublicClass.cs, Gesture.cs, DualFingerDetector.cs, DragDetector.cs, BasicDetector.cs, --- would replace those myself but then you keep updating this great package so maybe something for you to ponder :D stuff like this is so easy and quick to replace, so hope you'll consider it :)
     
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are absolutely right! I wasnt aware of the foreach statement issue until very recently. That's why all the foreach statement. I'll make sure it's changed in any subsequent update. Thanks for the reminder!
     
  44. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello songtan
    i face some issue when i try to switch different camera on the demotouch scene, with the main camera it work fine, but when change camera i got some error, will try to give you the error log later.
    cheers
     
  45. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    Hello,
    is there a easy way to change the sensitivity on Retina Displays?
    On my iPad 1 the Swipe works well to move a GameObject but on Retina it has much more Speed...
    Maybe next update you should support Higher DPI.
    thxx
     
  46. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Hi Muckel,

    The speed of the swipe is actually the number of pixel travel over the duration of the swipe. So it's understandable that the value is much higher on Retina Display where you have a much denser pixel distribution over the screen. You can easily remedy this by normalized the speed value to the screen resolution before you use it in any calculation. like so:

    Code (csharp):
    1.     void OnSwipe(SwipeInfo sInfo){
    2.         //k being the modifier value to adjust the magnitude of the speed
    3.         sInfo.speed=sInfo.speed/Screen.width*k;
    4.        
    5.         //calculation
    6.     }
    Hope this helps.
     
  47. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hi songtan
    so here is the error log i got when i had a new camera in the demoTap scene

    NullReferenceException
    UnityEngine.Camera.ScreenPointToRay (Vector3 position)
    TapDemo_OnCharging (.ChargedInfo cInfo) (at Assets/InputTouches/ExampleScripts/C#/TapDemo.cs:302)
    Gesture.Charging (.ChargedInfo cInfo) (at Assets/Plugins/InputTouches/Gesture.cs:279)
    TapDetector+<MouseRoutine>c__IteratorE.MoveNext () (at Assets/Plugins/InputTouches/TapDetector.cs:414)


    hope that helps
     
  48. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    Thank you!
    Works fine... but i have to use 1000 as k modifier Value... is that normal?
    thxx
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The value of k depends entirely on your application. I'm not surpirse at all even if the value is much higher than 1000. :)
     
  50. Lindrae

    Lindrae

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

    First, thanks a lot for your work, it has been really helpful for my project ! It took me only a few hours to make it do exactly what I needed to.

    I noticed some kind of a random bug on android devices, and I am surprised that no one else is reporting it. However, I believe that it does not come from my code because something close to that bug happens in your TapDemo scene.

    I made 2 videos to show you that bug, but first, in a few words, here is what happens...

    I am currently trying to make a comic reading app. The user can drag the page to move it, and I programmed the page to be "stuck" to your finger while dragging, as in your TapDemo "DragMe" example. The user can also zoom in and out by pinching the screen. It usually works like a charm.

    The bug only happens on the mobile version (the computer version does its job perfectly). The bug desynchronises the page and the finger while dragging : the page moves faster than the finger. This happens with the following conditions :
    1 - if the first interaction of the user with the app is a "Drag", this first drag is a buggy drag.
    2 - if the user makes a (rather quick) "pinch" then performs a drag, the drag is almost always buggy.

    The following video illustrates condition 2 : https://docs.google.com/file/d/0B_9E7VHmVPW2UFRLdFYyN0pBMUE/edit

    Now, in your TapDemo scene, both previous conditions trigger the bug. But the bug has a different behaviour here : the "DragMe" ball stays stuck at the finger while dragging, however at the end of the movement, it seems that the ball does not reduce its size. Thus after several bug triggering, the ball gets bigger...

    The following video shows the bug in your TapDemo scene : https://docs.google.com/file/d/0B5JNRCFhrbAZYmtpNGU0dHZYUjA/edit?usp=sharing

    Since my programming skills are not good enough to play with your code (or at least would I rather not!), I was wondering if you had any idea of what could be going on here ...!

    Thanks a lot
    -Lind

    PS : sorry for the bad quality videos...