PS: Im using the Destroy method.
That’s most likely because all the balls have the script attached to it, that deletes the game object whenever a click occurs.
To make sure you only delete the ball you clicked on, you need to use some more tricks, mainly this one:
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
print("Destroyed ball at " + Input.mousePosition);
Create a separate method with that (that is NOT on every ball), and use the snippet of code in its
Update method. That should work fine if the only objects in your scene are the balls you want to delete when clicked on.
Well if your are using unity 2D, then it would be definitely work for your, and make sure you have attach 2d physics collide with your prefab.
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if(hit.collider != null)