Unity Root Motion System Help

Hey @Deltakosh , @sebavan , @bghgary or anyone else that can help.

Please watch this video i made detailing the issue i am having with root motion.

Basically i am recording the HIPS (Root Skeleton Bone) X and Z positional updates (Delta Position) from the animation clip and at runtime using the deltaPosition per frame update to update the position of the parent transform itself. Unity style root motion.

But i am brain farting and not using the correct vector math to apply the delta positional update that was meant for the hips and use that to drive the main character transform node.

Thanks for the Video @MackeyK24 but I still feel over my head regarding implementation :frowning: Maybe @Drigax could have some ideas as well ?

I know you can’t repro this in the playground, but it’s going to be hard to do anything without a repro. :frowning:

Yeah, even a simple repro where you have a single animation translating the skeleton hips may help us get a better understanding.

Off the top of my head @MackeyK24 you may want to try something like this pseudo:

hipsToRoot = hips.localTransform^-1 //assuming hips is a direct child of your root transform, else invert the transformation of the hips bone relative to the root.
animationDeltaToRootTransform = Matrix.Compose(null, null, animationDelta.translation) * hipsToRoot //translate the animation targeting the hips to the space of the root transform.
root.transform = animationDeltaToRootTransform * root.transform

or something like that…

1 Like

Yo @Drigax … What is hips.localTransform^-1 mean ?

I think that’s the Inverted LocalMatrix. Im looking at the file you sent me and should have something for you today @MackeyK24

2 Likes

@MackeyK24 yeah, what @Pryme8 said. It’s math notation for the matrix inverse.

It ended up being a 3 liner.

All we had to do was translate the root motions velocity angle by the parents rotation matrix then subtract that from the parent nodes position.

this.m_transform.rotationQuaternion.toRotationMatrix(this._tempM)     
const deltaPosition = BABYLON.Vector3.TransformCoordinates(this.m_animator.getDeltaPosition(), this._tempM)                    
this.linearVelocity.set(deltaPosition.x, deltaPosition.y, deltaPosition.z)
4 Likes