Box2d check if physics is all settled


I don’t think there is a built in way to see if the physics world is settled? As in everything is no longer moving / is grey in debug draw. I think a way to do it would be to have all objects require a module and set a value to true if it is moving since the last frame / colliding with anything. And then give a few frames of buffer to see if anything sets the value to true before saying the world is at rest.

1 Like


All Box2D bodies have a “sleep” state, which is activated after they haven’t been moving or been in active contact with other bodies for a certain time (two connected stationary bodies would both be deemed sleeping).

As far as I know this is not yet included in Defold’s implementation of Box2D. If included it could fire a message and allow for an is_sleeping() function.




I’ve bumped into a related sleep issue; joints don’t work on dynamic sleeping bodies. I’ve opened an issue to add support for the Box2D sleep state: