- Home /
How to use multi touch
I'm new to unity. In my game i have 2 players. What I'm trying to do is, if I touch right side of the screen then my right player will jump and if I touch left side of the screen then my left player will jump. But when I touch both sides at the same time they should both jump. But I can't figure it out how to detect multiple touch at a time. I'm using this code if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { Vector3 touchPosition = Input.GetTouch(0).position; if (touchPosition.x <= (Screen.width) / 2) { Jump(); } } Please help me :(
I've found my solution :D Here is the code if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { Touch t = Input.GetTouch(i); Vector3 touchPosition = Input.GetTouch(i).position; if (t.phase == TouchPhase.Began && touchPosition.x <= (Screen.width) / 2) { Jump(); }
}
}
Your answer

Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Two player touch screen 1 Answer
Multitouch on GameObjects with separate scrips 0 Answers
Multiple Touch Drag iOS 0 Answers
Unusual multitouch behavior (Android) 3 Answers