Do objects fall forever?

I am not sure how to phrase the question correctly and have not yet been able to find an answer.

This might be silly question, but…

If I have a 3D object with a Rigid-body that uses gravity and that object rolls off the game level, will that object fall forever?

Would it be a good idea to have a script that destroys the object when the Y position is lower than a certain point? I guess at some point, the object’s Y position will max out the floating point size, will it not?

Why does it bother you so much?

Physics or not physics, you will need to manage your objects anyway.

You can either destroy it or recycle it depends on your case. You could check the position.y, or use the Monobehaviour’s callback OnBecameInvisible(), or sometimes check the position.x.

Personally I don’t like to use MonoBehaviour a lot. If you are looking for something more advanced, you should check out the Entitas on github. It’s a Entity-Component-System architecture, which is Data-Oriented, and they have demos that might help you out.

Thanks for the reply. Managing the objects are not a problem. Just wanted to know if i deliberately have to worry about objects falling through empty space forever.

In the case where you may have lots of rigid-body objects (interractable rubble or whatever) lying around and one of them goes off-level at some point and falls through empty space while the player is still playing the level for the next 30 minutes. Its easy enough to manage, just wondered if Unity perhaps auto-deletes objects (or stops gravity) after a certain depth.

Why would Unity stop anything? You are the only authority on what’s happening in your scene. There is camera culling distance, but all components attached to the object would still be active and updating. If you seek optimization I would suggest Object.Destroy.

To answer the original question…

No, it will technically not fall forever.

Eventually (after 8,333,389,282,805,376,000 seconds, or 264 trillion years), a rigidbody with 0 drag would reach negative infinity. The physics engine will have a fit long before then though.

4 Likes

Thank you, exactly what I wanted to know. Apologies if question was not clear.

Perfect thanks. its the “worst case scenario” I was thinking about. Cleaning up is always a priority.

It will fall as far as the floating point number range that defines it’s position can provide.