I’ve finally narrowed this down after a few days of trying.
Here’s the setup on Unity 2019.4.4f1:
Parent Object with PlayableDirector
- Child Object with Animator and OnAnimatorMove script that sets the parent’s transform.position
Playable director has one animation track that’s bound to the animator on the child. Dirt simple.
Avatar has a human scale of 1 and all bones/transform have 1,1,1 scale.
Expected amount of movement for this animation is about 1-2 units back on the z. Actual amount moved is instead 147 units back.
Here’s a video of the playable vs the animgraph of the same animation:
Script that sets the parent’s transform based on the root motion:
[ExecuteAlways]
[RequireComponent(typeof(Animator))]
public class ForwardRootMotionToDebug : MonoBehaviour
{
public Animator Anim;
// Animator callback
public void OnAnimatorMove()
{)
transform.parent.position += Anim.deltaPosition;
}
}
My character’s setup in my actual game is fairly unique and I cannot move the animator to the root. Is there any workaround for this?
EDIT: Doesn’t seem to matter where the playabledirector is. Can be on the child, external, parent, etc. Always the same result.
EDIT 2: Dividing the deltaPosition by Time.delta gives somewhat more “normal” magnitudes, but the root motion is still completely out of sync with the animation.
EDIT 3: Using FixedUpdate and pulling the animator.RootPosition results in the same bad magnitudes.