How to detect if stack of physics objects is stable

Godot Version

4.3

Question

I have a scene consisting of many different boxes on a flat platform. The platform is a StaticBody3D and the boxes are all RigidBody3Ds with BoxShape3Ds as their collision shapes, although not all boxes are the same size or have the same dimensions. During play there’s going to be an explosion which will fling a few boxes around, and I want the game to wait until all the boxes have come to rest before moving on. I’m not sure if it’s even possible to 100% guarantee that a stack of boxes is completely stable and will remain stable forever, but I don’t need a perfect solution.

I plan to freeze the physics of the boxes once the explosion is completely finished to save processing power and to make sure that nothing randomly topples over when it’s not supposed to. I just want to ensure that when the game does freeze everything the stack is not moving and isn’t about to fall.

Does anybody know a good way to check if the stack is stable?

Rigidbodies will be set to “sleeping” when they are still for a while. The Physics engine saves time with this, so you may not have to worry about freezing them as “sleeping” is probably already taking place.

1 Like

Ah you’re right, I forgot about sleeping. Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.