2D multi touch

Hello all,

I’m trying to make a 2D game but i have a problem. Let’s put it like this:

  1. I have one script that says:

void OnMouseDown(){



  1. On another script i have:

void OnMouseDown(){



But if i try to press both the objects (that the scripts are attached to) it will only do one script.

So can i have an example of how can i make it that the Two gameObjects (the sphere and the cube) can disappear when i click the objects at the same time.

Thanks and can you try to make it in C#

On mobile unity will map the first touch object to the mouse events for convenience, however it will only map one, multiple touches will not all trigger these events.

In order to support multiple touches you will need to do a bit of the leg work yourself by checking the Input.touches array (one element for each touch) you could then use this data to perform a raycast for each touchpoint, if the raycast hits your objects, you can then send messages to it to hide/show/

There is some useful comments in the answer on this question that should get you started on what to do. How to Raycast on Touch? - Questions & Answers - Unity Discussions