I'm toying with breakable bridges in my platformer engine (using JBox2d), but I've got some problems with them. I create the bridge quite like in the bridge testbed demo. After world.simulate(), I loop over the bridge joints and monitor the
joint.getReactionForce. If its length is greater than some value X, I remove the joint, thus breaking the bridge.
Attachment:
bridgetests.jpg [ 61.15 KiB | Viewed 856 times ]
This seems to work reasonably well, however there's one problem. I noticed that the joint reaction forces grow larger and larger, even when there's nothing on the bridge. At some point the growth stops (actually the bodies might go to sleep, haven't checked that yet). When the player then steps on the bridge, it breaks very easily. Somehow the joint forces build up and cause the brige break more easily the longer it has existed. The effect is even worse when the player rests on the bridge. Although everything is visually very stable, the bodies don't go asleep and the force keeps building up, finally breaking the bridge.
What could cause this kind of behaviour, and how could I stop the bridges getting weaker (i.e. the forces getting bigger) over time? IMHO the bridge shouldn't break by itself when the player rests over it, only after he jumps on to the bridge from altitude etc.
My bridge planks are 1.0 units of width, 0.22 of height with density of 2.0 units, if that matters.