|
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: They would need to follow the physics as if they were a single object, mass caclulations included. Thank you in advance. ~Bumbaz
(comments are locked)
|
|
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. That's very helpful, thanks. But what if I have gameobjects with different masses? In the method you described, the center of mass is only one. Is it possible to assign different weights to different parts of this one gameobject? I am so bad at words. Haha ~Bumbaz
Apr 27 '11 at 09:43 PM
Bumbaz 1
@Bumbaz: No, that wouldn't work with the method I described. I'm not sure there's an easy way to do that.
Apr 27 '11 at 09:52 PM
Eric5h5
what if you only parented them to the new gameobject but retained their original rigidbodies? Wouldn't that also retain their weight distribution?
Apr 27 '11 at 10:11 PM
Chris D
(comments are locked)
|
|
Maybe you need to look at a fixed joint: http://docs.unity3d.com/Documentation/Components/class-FixedJoint.html 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.
(comments are locked)
|

