- Home /
"Gluing" pieces together for a breakable object with springs
Hi I'm trying to find the best way to glue together the fragments of a preshattered object. So far I've managed to make it work with fixed joints which is somewhat disappointing because the object is far to wobbly. I've read to in some engines people use springs instead. This would at least allow me control how wobbly the object will be. However Unity only allows you to attach one spring joint per game object, which renders it useless for this purpose.
Warwick Allison posted an answear to the problem here, which I haven't tested yet, because it requires you to make a lot of extra rigidbodies which I would like to avoid. http://answers.unity3d.com/questions/120332/how-to-use-multiple-spring-joints-on-the-same-obje.html
So my question is: Is there a way to attach multiple rigidbodies to a single gameobject, without using additional rigedbodies. Perhaps a custom spring joint script? Why is this not possible in the first place? Is there perhaps a different better approach?
Answer by Ludeme Games · Oct 04, 2012 at 10:20 AM
I think most breakable objects are typically implemented by having a single rigid body object which is just the shell. When the object is collided with it 'breaks' by destroying itself and instantiating the shattered pieces in it's place, applying forces to each.
Thanks. That approach is surely easy and cheap, but it is not what I am trying to a achieve. I hope to simulate more realistic destruction by allowing an object to only break partially. It's supposed to potentially be used for destruction of for instance buildings. It wouldn't make sense that an entire building would collapse if you affected it in a way that would normally only chip the concrete.
With some tweaking the above method could work. Split your building up into areas, Split those areas up if you wanted. Depending on the force of the hit and where you would instantiate the pieces. If enough of the building or its supports are destroyed then it collapses.
Its going to take a bit of coding to make it look right.
I guess what you are suggesting is a kind of hierarchical partitioning of the object, but those individual parts that the object would be split into would still be completely shattered when affected and that's just not what I am trying to achieve.
Not completely shattered it would depend on the amount of force applied to that area, if it was great enough it would shatter and possibly "leak" to near by parts of the building. Those parts would only crumble slightly.