- Home /
Is it possible to prevent parent rigidbody physics from effecting children rigidbodies?
Basically, I'm asking if it's possible to move a parent object with the rigidbody component without effecting it's child's rigidbody physics. While keeping the child's physics properties.
I have it setup where I have the Parent Rigidbody game object, contain a child rigidbody object and a series of springs connected to that child rigidbody.
So if i move that parent game object using Rigidbody.MovePosition(). The child object would be springing around accordingly based on how the parent is moved.
But I actually don't want the parent's movement to be effecting the child's physics.
That can actually be accomplished if i move the parent game object using transform.position. This would actually move the parent game object without causing the child objects to spring around. HOWEVER....a new problem arises. High speed collisions with my objects would no longer be reliable, because im using transform.position, instead of rigidbody.MovePosition.
Since my game requires solid and reliable high speed collision detection, I had the Parent game object have a rigidbody component with collision detection set on continuous, including all child and other objects.
So I'm in a bit of a conundrum here... Method One: I get proper high-speed collisions, but unwanted physics movements of my child objects. Method Two: I get bad high-speed collisions, but correct physics movements of my child objects.
I was hoping there was just some simple line of code I could right to just 'Disable transferring physics' to child objects. but....there isn't.
I would have thought that it should be fairly common for some objects to have seperate physics reactions in children.
Any tips would be great, thanks!
Take a look at this video to see what I mean...(Forgive my placeholder graphics).
https://www.dropbox.com/s/066rhgjn3uh3os3/ParentRigidbody.mov?dl=0
What's going on here is that when I move the red circle around the two boxes are supposed to move and rotate in a specific way.
In the first half of the video, it moves but with a lot of bounce and spring, because it has a child object which has the box attach to some springs. Here I'm using rigidbody.moveposition.
In the second half of the video, it moves nice and swiftly following the red circle like it's supposed to. And the box actually still has it's springy physics if another rigidbody object were to collide or bounce on it....The only downside to this is that, because I'm using transform.position instead of rigidbody.moveposition. My collisions aren't reliable, high speed objects fall through them, etc....
Why exactly does the child object need to be parented to the parent object in the first place? The springs should move the child object around regardless of its parenting. Or, if it's absolutely essential that the object be parented, you could just disable the springs before moving the parent object, move it, and then re-enable the springs.
Answer by Bunny83 · Apr 28, 2015 at 07:44 PM
You should never parent a rigidbody to any object that itself is moving. Rigidbodies are simulated in worldspace. If you parent a rigidbody to another moving object the childs physics will get messed up.
Also a parent-child relation ship always includes that the childs are affected by everything that happens to the parent. If you don't want this, don't parent them together.