- Home /
 
 
               Question by 
               rsofia · Mar 06, 2020 at 05:09 PM · 
                inputtouchtouchscreenmultitouchgetbuttondown  
              
 
              How do I handle multitouch as Input.GetButtonDown()?
I am currently checking for multiple touches. I want to check if the touch was either on the left or right side of the screen. The problem is the game crashes when I try and touch multiple times. Apparently there is something wrong with the way Im handling the touches. Also, I want the touch to act in one frame, just as Input.GetButtonDown, but I don't think it works...
Update{ int touchCount = Input.touchCount; if (touchCount > 0) {
         for (int i = 0; i < touchCount; i++)
         {
             Touch touch = Input.GetTouch(i);
             Vector2 touchPos = touch.position;
             if (touch.phase == TouchPhase.Began)
             {
                 if (halfScreen.Contains(touchPos))
                 {
                     moveJoystick.transform.parent.position = touchPos;
                     moveJoystick.StartInteraction(0, touchPos);
                 }
                 else
                 {
                     if (!attackRect.Contains(touchPos))
                     {
                         jumpJoystick.transform.parent.position = touchPos;
                         jumpJoystick.StartInteraction(0, touchPos);
                     }
                 }
             }
         }
     }
 
               }
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Windows Multitouch Fail 1 Answer
Unity Getting Input from Horizontal axis while using buttons 1 Answer
Does Win7 multitouch work in Unity 3.4+ or not? 0 Answers
Multitouch loses touch even when finger still on screen. 0 Answers
Touch Input madness 2 Answers