Mecanim character and attached rigidbody acting out of synch.

I have a character animated by mecanim, using root motion for movement. I’m trying to attach a ponytail to the character’s head, but it seems to be out of synch with the mecanim movement. I made the ponytail as 5 rigidbody boxes, connected to each other with configurable joints. The position motions are set to Locked, so that the joints only allow rotation. The ponytail setup itself works well.

In order to attach it to the mecanim character, I added a kinematic rigidbody to the character’s head, and set the animator to animate physics. I then used another configurable joint to attach the start of the ponytail to the character’s head.

The ponytail now kind of follows the character. The problem is that when I run around, the ponytail lags behind. Basically floating 10 cm behind the head if the character is walking, and the distance increasing to maybe 30-40cm if the character is running.

Just as a test, I also made a separate “attachment Head” which was a kinematic rigidbody that I forced to follow the mecanim head by using rigidBody.SetPosition(headTransform.position) and the same function for rotation inside FixedUpdate(). This object was also unable to synch up with the mecanim object, floating behind it.

Finally, I just tried to force the transform.position and rotation of a separate object to be the same as the mecanim head, each LateUpdate(). This worked, but it kind of just offsets the problem since a physical object is unable to follow that object anyway.

What is the correct way to attach a physical object to a mecanim character?

I think I got it working, here’s how in case someone else runs into this problem.

After some more testing it seems that the root-motion applied by mecanim is not “read” by rigidbodies attached with joints. The motion coming from the animation itself affects the attached rigidbodies, but the actual translation of the whole character just causes the attached rigidbody to jitter and lag behind.

I parented the rigidbodies of my ponytail to the mecanim root so that they are moved around in the world together with the character. This way they stopped freaking out from the character movement, but still reacted to the motion from the animations. In order to get the ponytail to react to the actual movement of the character agan, I used a script suggested by this tutorial:
Unity Skeletal Ragdoll / Jiggle Bones Tutorial

Basically I added a physical impulse to each rigidbody, based on how the mecanim root moved each frame. Now the ponytail seems to react to both animation and movement, and it’s very handy to have a script that can limit how much impulse the ponytail gets from the movement.