- Home /
Is there a way to destroy an object besides Object.Destroy?
Objects in my game keep randomly destroying themselves when I don't want them to. I've commented out the only instance of Object.Destroy in all my game scripts, and it still happens.
So far I've been unable to find any conditions that make an object more likely to destroy itself.
So, does anything besides Object.Destroy destroy an object, something I'm missing when looking for the cause of this bug?
Further information:
Unity version 4.0.1f2.
All objects destroyed are instantiated.
The game involved gravitational physics. It's possible, but unlikely, that I've made an error in calculations and set an object's position to NaN or infinity.
The game involves up to 1000 Shuriken particles, and gravity physics on those particles.
Particles are almost always present when an object destroys itself, though this could be a coincidence.
For particles, Depending on energy, it will get destroyed by itself..
If you have set teh object's position to infinity or something, It should still show up in the Hierarcy panel..Are you sure it is destroyed??
It's game objects that are getting destroyed, not just particles.
I'm absolutely sure it's destroyed. It disappears from the hierarchy panel, and scripts attempting to access the object come up with an error.
Also check they aren't beco$$anonymous$$g children, perhaps. Sometimes they can be hard to spot in the hierarchy if the parented gameobject already has a child. In some circumstances childing an object will affect it's scale so it will also be hard to find visually.
You can try using Debug.Log in OnDestroy() function and than deduce from stack trace where from the object got destroyed. Not sure if this will work.
Or insert Debug.Break() and check where your object is.
Answer by Jamora · Sep 02, 2013 at 10:02 AM
This question had a similar problem. You wouldn't happen to have any auto destroy flags on? Trail renderers have one, maybe your particle system does too...
Your answer
![](https://koobas.hobune.stream/wayback/20220613113415im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to destroy live particle in Shuriken 1 Answer
How to destroy / hide a single particle? 2 Answers
Collision with a coin 0 Answers
How do I enable an object when it is destroyed? 2 Answers
Turn On & Off Shuriken particle system? 2 Answers