Multitouch

Hello. I guess its a noob question but i cant get it right.
I have a game on android and basicaly it uses touch. But for now if i touch something in one place and hold the finger there. Another fingers just dont work anymore. If i tap and dont hold fingers in one place its ok.

How can i do something. Well for example how can i move 2 objects with 2 different fingers at one time? if somebody can show me an example would appreciate it a lot.

You will have to keep track of the different touch ID’s and move your objects accordingly. If you try this script out, you will see that finger touches are assigned a unique ID:

public class UserGesture : MonoBehaviour
    , IPointerDownHandler
    , IPointerUpHandler
    , IDragHandler
{
    public void OnPointerDown(PointerEventData data)
    {
        Debug.Log("Detected touch with ID: " + data.pointerId);
    }

    public void OnPointerUp(PointerEventData data)
    {
        Debug.Log("Released touch with ID: " + data.pointerId);
    }

    public void OnDrag(PointerEventData data)
    {
        Debug.Log("Dragging touch with ID: " + data.pointerId);
    }
}
2 Likes