Stop almost all rigidbody computations when out of sight?

Hi,

in my case, the majority of rigidbody computations is not necessary when the rigidbody is not seen by the camera or at a far distance from the player.

That applies to forces generated in code, but also standard things like a block lying on a block, dangling joints, etc. Is there an easy way to turn them off when they are not seen by the camera? Alternatively, when they are at a certain distance from the player (and in that case, too, not seen by the camera)?

hrmmm…

well if the gameobject has a Renderer attached to it (it has the ability to be visible), you can receive the OnBecameVisible and OnBecameInvisible messages:

When receiving them stop the rigidbody by setting it’s isKinematic property appropriately.

Good idea, simple solution, like it. In the link, the example code actually enables (enabled = true;) or disables the object. Would that be an even more efficient choice than setting isKinematic?

EDIT: I wonder how important this is in terms of efficiency. Obviously some rigidbodies should not be turned off by this simple trick but are only required if e.g. the player enters a room. Maybe in terms of efficiency this isn’t worth the trouble when you have like 10-20 rigidbodies in the scene?