Understanding Root Motion Jitter at Loop/Transition Points
The behavior you're describing is actually expected when using root motion with looping animations. When an animation loops, the root bone naturally returns to its starting position in the animation data. The SkeletonMecanimRootMotion component is designed to handle this by tracking delta movement per frame rather than absolute positions.
How Root Motion Should Work
The SkeletonMecanimRootMotion component works by:
- Capturing the root bone's movement delta each frame
- Setting the root bone's position to zero (converting to in-place animation)
- Applying that delta movement to the GameObject's Transform
This means that even when the animation loops and the root bone resets to its starting position, only the frame-to-frame delta is applied to your GameObject, maintaining smooth continuous motion.
Troubleshooting the Jitter
If you're experiencing jitter, please check these common issues:
1. Verify Root Motion Setup
Ensure your bone hierarchy is structured correctly:
root
- rootmotion_bone (_ground) // This bone should move forward during the animation
-- hip // Character body as child of root motion bone
The root motion bone must be a parent of your character's main body parts, not parallel to them.
2. Check Animation Setup
- Ensure your animation actually has continuous forward movement keyed on the root bone
- The root bone should move consistently throughout the animation cycle
- Verify the animation is set to loop properly in Unity's Animator
3. Verify Component Settings
In the SkeletonMecanimRootMotion Inspector:
- Confirm the correct bone is selected as Root Motion Bone
- Enable X and/or Y axis as needed for your movement direction
- Verify Mecanim Layers includes the correct layers
4. Animation Update Timing
If using physics (Rigidbody2D or Rigidbody):
- Assign the Rigidbody to the
SkeletonMecanimRootMotion component
- Set the skeleton animation component's Advanced - Animation Update parameter to
In FixedUpdate
5. Avoid Flipping the Root Motion Bone
Do not flip the same bone you're using as the Root Motion Bone. Instead:
- Use
Skeleton.ScaleX = -1 for flipping, or
- Flip via the GameObject's Transform Scale X
Additional Considerations
For animation transitions: Mecanim should blend root motion smoothly during transitions automatically. If you're experiencing issues during transitions:
- Check your Animator transition settings (duration, offset)
- Ensure both animations have proper root motion keyed
- Consider the
Mix Modes settings in the Mecanim Translator section
Delta Compensation: If you need to stretch motion to reach specific distances (e.g., for jumps), you can use:
skeletonMecanimRootMotion.AdjustRootMotionToDistance(targetPosition - transform.position, layerIndex);
This scales the root motion to land exactly at the target position.
If the jitter persists after checking these points, please provide more details about:
- Your exact bone hierarchy setup
- Whether jitter occurs on every loop or only during transitions
- Whether you're using any custom scripts that modify the Transform or skeleton
This will help identify the specific cause of your issue.