- Home /
OnMouseDown() function
Hi, I' ve been doing a project where i have had moving objects. I wanted to Destroy them when i on it... Everything was going so well but when I started the game i must have clicked on the objects several times to Destroy them... Please help me to make it not laggy as it is.
OnMouseDown() { Destroy(gameObject); }
The script is atrached to gameObject.
Your description is quite confusing. Your script destroys them but it takes multiple clicks to do so? Is it causing your computer to lag? or do you mean you want to destroy them on the first click ins$$anonymous$$d? Is this script you have attached to the gameObjects you want to destroy? You should post more code and information about your project.
$$anonymous$$y script, as you can see, Destroys gameObject on the first click on it. But as i said 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 as i said...
Your answer
![](https://koobas.hobune.stream/wayback/20220612152018im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
OnMouseDown() not detecting click every frame 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Looping and closing walls 1 Answer
How do I move the camera to another object in the scene on mouse down? 1 Answer