1
\$\begingroup\$

I've implemented a destructible terrain system like Worms before (where weapons create holes in the terrain), but for the game I'm designing I want something more like Armadillo Run: https://www.youtube.com/watch?v=4JoPlcyxxb4 where everything is made from individual parts connected by physics joints.

I've figured out how to make a chain of planks using Unity's joints that can fall, swing off each other, bend if unsupported, and break at the joints. But I can't think of how to make planks break instead of the joints. There's an example of what I want at 2:25 in the video, where the plank on the right breaks (not the joints, but the actual plank itself). Obviously I'd just have to destroy the plank object, but how do I decide when to do that?

I'm using the Unity engine (2D physics), but I'd be perfectly happy to implement something myself if someone can direct me to some research on the subject or anything else to help me get started.

\$\endgroup\$
1
\$\begingroup\$

If you apply too much force to a plank, then the connecting joint is going to break.

So that should be your indicator that the plank needs to be destroyed. At first, I'd just destroy the plank when the joint of the plank breaks. I think that's pretty much what's happening in the video you linked to.

You could further refine the process by doing something like this:

Keep a list of all your joints and store their current reaction force (GetReactionForce) with each update.

Whenever a joint breaks, you'll usually have two game-objects involved (the one with the joint and the one that's connected to the joint). Find all the joints attached to each GameObject and average the force applied to all joints. Then destroy the GameObject that has the highest average force on its joints.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.