- Home /
Should rigidbodies be destroyed as they fall out of stage?
In order to test my computer and Unity3d profiler, I set a scene with a plane and 1800 cubes. Each cube has rigidbody and collider attached.
There is one thing I do not understand. As my "game" progresses, cubes fall out of stage, and their geometry is destroyed. In the Rendering row, you can see that number of draw calls, triangles and vertices decreases over time as expected. Something I am surprised of is that number of active rigidbodies stays the same all the time.
Isn't rigidbody supposed to be destroyed as it falls off the stage?
Answer by dorpeleg · Jul 26, 2013 at 10:50 PM
The geometry is not destroyed, it's just not rendered because your objects are out of the screen.
Rigidbodys are not graphical, they are psychical.
So psychics is still calculated even if objects are off screen.
Thank you for your answer! That explains a lot, but am supposed to destroy rigidbodies myself, if I have it somewhere offscreen? Or is there some "AutoDestroy" checkbox for rigidbodies in Unity somewhere?
As far as I know, there is no built-in way to do it.
If you want rigidbodys to be destroyed when off screen, you will have to script it
If you're really worried about performance, you should not be using Instantiate and Destroy, rather you should make the objects active/inactive and store them in a pool. Check the AngryBots demo, and how the bullets and missiles are managed. http://www.google.com/search?btnG=1&pws=0&q=unity+pool+objects+
Your answer
Follow this Question
Related Questions
Active rigidbodies and number of Contacts 1 Answer
Profiling mysterious "Phase Core: Trigger Interaction Work" 1 Answer
Moving Colliders giving me Physics.simulate spikes in Profiler 2 Answers
Add 2d rigidbodies to moving objects to increase performance or not? 1 Answer
Physic processing takes a lot of time for one rigidbody 1 Answer