Search Unity

Unity multi touch not working properly

Discussion in 'Scripting' started by kira911911, Aug 7, 2015.

  1. kira911911

    kira911911

    Joined:
    May 29, 2015
    Posts:
    7
    Hi all!
    I'm trying to implement a simple multi touch app just to learn, but i'm having hard times on it.
    I have a single button on the left side of the screen and an "analog stick" on the right side. But when I push the button while dragging the analog stick, the coordinates of the touch gets messed up. Could someone help me please! I already spent three days trying to fix this!
     
  2. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    It's probably averaging the values or swapping the touch indices- you need to iterate through the current touch indices when more than one is occurring at a time and make it so that it doesn't matter whether a touch is index 0 or 1 or 13. I don't actually use what you're talking about, so I don't have code in front of me, but that should get you started. Let me know if you need additional help and I'll go looking for something.

    EDIT: https://unity3d.com/learn/tutorials/modules/beginner/platform-specific/multitouch-input
    Code (csharp):
    1. Touch[] myTouches = Input.touches;
    2. for(int i = 0; i < Input.touchCount; i++)
    3. {
    4.  
    5. }
     
  3. kira911911

    kira911911

    Joined:
    May 29, 2015
    Posts:
    7
    I kind of tried this already, but maybe I didn't get it right. I'm trying it again. I'll let you know if it doesn't work, thank you!
     
unityunity