Break the bridge under heavy weight

Hi,

I am playing around with the bridge (SampleCode).

I want the bridge to break when the weight is to heavy. Is that possible?
It would be great if it was possible to define the weight of an object, and call an event when pressure is over the objects limit.

An example:

Crates dumping down on each other. One crate can handle the pressure of 2 other crates.
When the third crate is dumping down, the first crate (in the bottom) is destroyed.

Thanks,

Nicdal. [import]uid: 8712 topic_id: 2049 reply_id: 302049[/import]

Just a thought, I’ve not tried this, but thinking about the bridge sample- could you maintain a list of all objects involved in collisions and on a timer check the sum of their collective densities. Then, once a threshold is passed, break the bridge.

The big problem would be working out which objects are touching in one place- my thought would be to keep a register of which objects have collided. Considering that if all objects are firing collision start events whenever one of them lands on top of the others; if the timer is fast enough, it could check which objects have fired a collision start but not fired a collision end event. ie: The list of objects would be added to when collision start is fired, removed from when collision end is fired. Run through the list once every 5 milliseconds, for example(!), and check the items in the list, add their densities… etc.etc.

Working out where to break the bridge, er, um. Work out the lowest object in the above maintained list and break the link in the bridge just beneath it? [import]uid: 8271 topic_id: 2049 reply_id: 6034[/import]

I think you are on the right track.

I will try look at it later… But it would be nice if this calculation was maintained by the psysics-engine automatic.
[import]uid: 8712 topic_id: 2049 reply_id: 6038[/import]

Er, just thinking about it. If the bridge sags under increased weight, modify the sample app to only add rocks when you tap the screen. When the bridge sags to the point where you think it should break, check the terminal window - where you will have been outputting the lowest y value of all the bridge connections.

Once you have that value, place an invisible sensor at that height and when only a plank on the bridge collides with the sensor, break the bridge by removing that plank.

Ie: Get the bridge to the point where it should break, note the lowest plank’s height, place a sensor there and break the bridge when the bridge touches the sensor.

Does that help?

Er, I guess it won’t help if the bridge doesn’t stretch when there is increased weight. [import]uid: 8271 topic_id: 2049 reply_id: 6154[/import]

horacebury: Thanks for your reply. Yes, this would properly work with the bridge example. But I am looking for a method to use in every situation where you want a max pressure on an object. [import]uid: 8712 topic_id: 2049 reply_id: 6156[/import]

Tell me about it - I feel your pain… [import]uid: 8271 topic_id: 2049 reply_id: 6161[/import]

Have you tried using joint:getReactionForce() as a way to approximate joint “strain”?

http://developer.anscamobile.com/content/game-edition-physics-joints#Common_features_of_all_joints

(Note: docs have been corrected to show that this function returns TWO values, not one.) [import]uid: 3007 topic_id: 2049 reply_id: 6404[/import]

Hi evank,

Thanks for contributing to this thread.

Looking on the “strain” is a great idea.

But it seems that the “weight” of an object is defined on the size of an object. If I have 2 balls (like in the bridge example). The one with the biggest radius is also the most heavy.

But what if I have a beach ball and a bowling ball. The beach ball have the biggest radius, but the bowling ball is definitely the most heavy.
[import]uid: 8712 topic_id: 2049 reply_id: 6597[/import]