Greetings all,
I’m curious if anybody has tackled (solved?) the issue of detecting if multiple physics bodies have come to a basic resting point. This would be, for example, in a game like (*sigh*) Angry Birds…no… Ghosts vs. Monsters! where the “structure” is collapsing, and the user must wait until all objects have essentially finished falling/colliding/interacting before they can launch the next ghost.
The most obvious solution seems to be a Runtime listener checking if the bodies are “awake” or not ("body.isAwake"). My initial testing indicates that this works properly; it basically detects if the objects are sufficiently “at rest” as expected. Heck, why not let Box2D do the tedious work? But I wonder if this approach might cause other problems. Perhaps Box2D is TOO sensitive and won’t put an object to sleep until it’s literally not moving at all. Then you might have an object sliding down a gradual slope at a visually undetectable speed, and the user is sitting there wondering why they can’t launch the next ghost. I suppose setting the friction on all objects to a suitable level would ensure that they do, in fact, come to a resting point and don’t slide around indefinitely.
Another approach I considered was a Runtime listener that constantly loops over the objects involved (say, 20 pieces of a tower, added to a table when the tower begins to crumble). I could loop over each object in the table and check their motion using "body:getLinearVelocity()" and "body.angularVelocity". If either velocity was above a certain threshold (very small) then the simulation would continue checking until otherwise. I just worry that this approach would cause considerable overhead processing (especially with the looping), thus causing potential slow-down if there were several (20+) objects involved.
Any other thoughts or suggestions? Specific advice from anybody who has experimented with this?
Thanks in advance!
Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 18713 reply_id: 318713[/import]

[import]uid: 13097 topic_id: 18713 reply_id: 72224[/import]