Setting Local Transforms for In Place Animation with Global Data

I have a baked vertex animation that uses a list of transforms for positioning items placed on the head and hand. Those transforms are stored as global transforms.
The animation uses this list to set empties that hold things like hair, hats, guns, and boxes.
The animation works perfectly if it is not driven by my NavAgent, but I can’t figure out how to set those transforms local to allow AI navigation.

Here’s a video showing the problem.
im31wg
“man-parent-parent” holds the NavMeshAgent
“man-parent” holds root transforms

Here is my function. !CurrentAnimation.InPlace works fine by setting the global position.

//check for in place animation
if (!CurrentAnimation.InPlace) {
    //set positions
    RootCurrentPosition = RootStartPosition + CurrentAnimation.Transforms[CurrentFrame].RootPosition[AnimStartRotation] * Scale;
    if (Enabled) {

        //root
        Root.position = RootCurrentPosition;
        Root.rotation = CurrentAnimation.Transforms[CurrentFrame].RootRotation[AnimStartRotation];

        //head
        if (HeadTransformEnabled) {
            HeadCurrentPosition = RootStartPosition + CurrentAnimation.Transforms[CurrentFrame].HeadPosition[AnimStartRotation] * Scale;
            Head.position = HeadCurrentPosition;
            Head.rotation = CurrentAnimation.Transforms[CurrentFrame].HeadRotation[AnimStartRotation];
        }
    }
} else {
 
    //set positions
    RootCurrentPosition = Root.parent.position + CurrentAnimation.Transforms[CurrentFrame].RootPosition[0] * Scale;
    if (Enabled) {

        //root
        Root.localPosition = Root.parent.InverseTransformPoint(RootCurrentPosition);
        Root.rotation = CurrentAnimation.Transforms[CurrentFrame].RootRotation[0] * Root.parent.rotation;

        //head
        if (HeadTransformEnabled) {
            HeadCurrentPosition = Root.parent.position + CurrentAnimation.Transforms[CurrentFrame].HeadPosition[0] * Scale;
            Head.localPosition = Root.InverseTransformPoint(HeadCurrentPosition);
            Head.rotation = CurrentAnimation.Transforms[CurrentFrame].HeadRotation[0] * Root.parent.rotation;
        }
    }
}

This is the function that saves the transforms. rot indexes the movements in 4 directions. For “In Place” animations I use the 0 index as there’s no reason to save the other indices.

Transforms[frame].RootPosition[rot] = Root.transform.position;
Transforms[frame].RootRotation[rot] = Root.transform.rotation;
Transforms[frame].HeadPosition[rot] = Head.transform.position;
Transforms[frame].HeadRotation[rot] = Head.transform.rotation;
Transforms[frame].HandPosition[rot] = Hand.transform.position;
Transforms[frame].HandRotation[rot] = Hand.transform.rotation;
RotationInt[rot] = (int)SetRotation(Root.transform.rotation.eulerAngles.y, 0) / 90;

Check if the animation is driving the root position and forcing it to be Y == 0.

If so it will need to be redone to not do that, since animations always win.

Its a baked vertex animation. There is no root motion that isn’t in the function I posted above.

I see a lot of lines of code setting .position on what looks to be a Transform… do you intend to be setting .localPosition instead for these objects?

As I said in my OP, the top section of the function where I set transforms works as intended and is shown as a reference.

Here is a video where the behavior is easier to see.1wn5e7