Checking if a structure has collapsed

Hi,

If you are looking for an end game condition, where a tower of blocks has been knocked down, what would the best general approach to determine if the structure has collapsed sufficiently for an end of game?

Do you check that each object has physically moved a certain distance from its start point, or a certain angle difference from the start point that would indicate a collapse?

Any thoughts appreciated.

Regards

i
It really depends on your game as to how you should define 'has been knocked down' 😀
How about:
- the highest point in the remaining pile goes below a certain height
- if pieces are tall and start mostly vertically placed (like pillars), check to see how many of them have fallen sideways
- certain key pieces either go below a certain height, touch the ground, or fall sideways
This is a tricky one. The problem with using some sort of height threshold is that you may end up with a pile of rubble that is higher than the threshold. One thing you could do is actually destroy shapes when they are contacted with a certain force from other shapes.

So imaging that your "building" falls in on itself. The building blocks on the bottom will be impacted by those above. If this impact caused these bottom blocks to be destroyed, the higher ones would naturally come to rest lower, and therefore more likely to be under a height threshold. This could also look pretty cool if some of the structure was actually destroyed during the collapse (and more realistic)

I would use a combination of shape position and velocity to determine the final state. Once all shapes are either destroyed or below a certain height, AND have a velocity lower than a certain threshold, you assume the structure is destroyed.
Hi

Thanks, I was going to hold some information on each block depending on its original position - what would be an acceptable assumption for it (as a single piece) to be collapsed. i.e. a horizontal piece high in the structure is looking for a reduction in Y. A vertical piece lower down may be looking for a rotation from its original position of >35 degrees. Then each piece can be checked in the tick to see if we have at least 80% of the conditions met?

Regards

i

Original thread: https://box2d.org/forum/viewtopic.php?t=5792