OnMouseDown() not detecting click every frame

My script, as you can see, Destroys gameObject on the first click on it. If there’ s more gameObjects and i click on them faster, some of them need 1 click to destroy (that is what i want) and some of them need several clicks to destroy (is it because of the detection of my click is not called every frame? Or i don’t really know) Script is atrached to gameObject.


A quick search resulted in the following similar issues:

OnMouseDown() Doesn't work - Questions & Answers - Unity Discussions (check the second highest voted answer as well!)

So it seems the problem can be caused by various reasons:

  • incorrect setup (e.g. no collider on the object)

  • camera view issues (too close to the camera or not seen by the main camera)

  • another collider is blocking the view

Apart from these, how fast does your application run? At 60 FPS it is not very likely that you are clicking faster than a frame, even if I assume that OnMouseDown() is synced to the physics update. Which means the problem has an issue in the logic.