Root motion not applying
Hi,
I am using animations I downloaded from https://www.mixamo.com/#/ in my project. I duplicate the animation clip to remove the read-only status, then use that clip to trigger character animations.
For this project I am mostly using code to handle movement, but I want to use root motion for one specific animation and I'm having trouble getting it to work properly. Currently I can get the animation to play in a single spot (baked root position), or I can get the animation to only move the Mesh(!baked), but at the end of the animation the parent transform is still located at the original spot, so the character Mesh warps back to the beginning area.
My current thought process is to leave the animation !baked, and grab the transform position of the character at the end of the animation with an event, but I can't seem to find an API call that contains the clips root motion transform values. i.g. My character begins at world vector (0,0,0) , the animation moves backwards 2 units in Z, but I'm unable to find access to that variable anywhere in the animator or the animation clip. Current code in the animation event looks like this:
public void SetPosition() //called by anim event
{
AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); // no rootmotion values
AnimatorClipInfo[] clips = anim.GetCurrentAnimatorClipInfo(0); // no rootmotion values
transform.position = anim.deltaPosition; // returns (0,0,0) but character mesh is at (0,0,2)
Debug.Log(clips[0].clip.name);
}
I'm worried about hard coding a vector value for the transform because its not a reusable solution. Is it possible to grab the animation curve values at a keyframe? I've read through unity's documentation, and searched the forms, but I cant find a good solution.
Your answer
![](https://koobas.hobune.stream/wayback/20220612192609im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Player teleports when animation finishes 0 Answers
Root Motion not having gravity (while Animate Physics turned on). 1 Answer
Root motion on animation clips created at runtime 0 Answers
How To preserve Forward momentum of an anim throughout another anim? 0 Answers
Rootmotion orientation won't change 0 Answers