Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Unity multi touch not working properly

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

  1. kira911911

    kira911911

    Joined:
    May 29, 2015
    Posts:
    10
    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:
    10
    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!