- Home /
 
iPhone multitouch
How do i make multitouch for my game? I have different moving objects with colliders in my scene, and i want it so i can press at least two at the same time. I tried searching for an answer on the web, but nothing have worked.
the Input class has all you need, things like touchCount, GetTouch and a returned touch object with information about fingerID and state and all that stuff.
it will NOT work with unity UI out of the box because that is single touch only 
I tried using it, and i got this.
using UnityEngine; using System.Collections;
public class testInput : $$anonymous$$onoBehaviour {
 private RaycastHit2D hit;
 
 
                   void Update () { Touch myTouch = Input.GetTouch(0);
     Touch[] myTouches = Input.touches;
     for(int i = 0; i < Input.touchCount; i++)
     {
           hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.touches[i].position), Vector2.zero);
         
          if (Input.touches[i].phase == TouchPhase.Began) {
               if(hit.collider.tag == "enemy")  {
                   Destroy(gameObject);
               }
              
          }
              
          }
  
     }
 }
    
 
 The problem is, that it destroys all object with the tag "enemy", and not the object the raycast hits.
 
 
  
 
                  that's true, your executing
 Destroy(gameObject)
 
                    ins$$anonymous$$d of
 Destroy(hit.collider.gameObject)
 
                   Your answer
 
             Follow this Question
Related Questions
Input.GetTouch SOMETIMES not registering on iOS 0 Answers
input.touch effect ever object script is attached to 1 Answer
Multiple touch iPhone Buttons 0 Answers
iPhone Multitouch Problem 1 Answer