How to move a Rigidbody child along with a Rigidbody parent

I’m having a big issue where I want my child with a rigidbody to move along with the motions of the rigidbody parent it’s connected to, however it doesn’t follow the root motion of the parent rigidbody like a child would do if the parents transform is updated. My expected result would be where I can freely move the parent rigidbody using physics and the child moves relative to the parent but also having it’s own physics at the same time (so no kinematic locking or anything)

I have come up with a couple solutions that unfortunately don’t work (or work well). The first one is updating the child object to the change of transform of the parent which sounds like an easy solution but this conflicts with the rigidbody a lot so it doesn’t like it at all. Another solution where I actually got results was where I set the use of the rigidbody function called MovePosition to a stabilized anchor transform while setting the mass, drag and angular drag of the child rigidbody to 0 (only works when 0). But this as you can imagine causes a number of issues, like objects having no mass and drag and strangely doesn’t work in a build but only sometimes in editor. The last solution is joints but there doesn’t seem to be any joints in Unity which allow you to have a rigidbody that’s connected to another rigidbody without locking the child rigidbody in place.

So ultimately, does anyone have any valid solutions? Surely this is a problem many other people have encountered, and after looking online it seems like no one else has actually found a solution that actually works properly.

I would like to repeat this again, I want the parent rigidbody to move freely with the child object moving ALONG with the parent rigidbody but also having it’s own physics like gravity and movement being uninterrupted

1 Answer

1

To resolve this is to create at that point a joint by code in one of the bodies and attaching the connected rigidbody to the other one. Both rigidbodies should be in the same hierarchy level and not one under another as this leads to problems with the engine.

I'm sorry but wouldn't a joint mean that the object is locked in place?

having this same problem, could you clarify what you mean by this and how this would work?