Combine multiple rigidbodies?

Hello there. I was wondering, what is the best way to approach this problem? I want to combine two or more different rigidbodies into one at runtime, or if that is not possible without a complex use of the Mesh class, to make them act as one? Picture shows what I mean, since I am not good with words:alt text

They would need to follow the physics as if they were a single object, mass caclulations included. Thank you in advance.


If you remove the rigidbodies from the cubes (but keep the colliders intact), and make them children of an empty gameobject that has a rigidbody, then they will be effectively merged. You'd want to add the mass from the two cubes before deleting the rigidbodies and apply that to the mass of the parent.

Maybe you need to look at a fixed joint:

This is used to “connect” two distinct rigidbodies together. Each maintains its own mass, but pushing on one rigidbody pulls on the connected one, so they act sort of like a single physics object.

There are other types of joints as well: hinge joints, spring joints, etc.