Consider the following Unity C# code inside an Animator's OnAnimatorMove() method. What will be the final position of the GameObject after this frame?
void OnAnimatorMove() {
Vector3 rootMotion = animator.deltaPosition;
rootMotion.y = 0;
transform.position += rootMotion * 2f;
}Remember that animator.deltaPosition gives the root motion movement for this frame, and modifying the Y component affects vertical movement.
The code takes the animator's deltaPosition, zeroes out the Y component to ignore vertical movement, then multiplies the XZ movement by 2 before adding it to the transform's position. So the GameObject moves twice the horizontal root motion.
Choose the correct statement about how root motion works in Unity animations.
Think about what root motion means in terms of animation and GameObject movement.
Root motion means the movement of the root bone in an animation is applied to the GameObject's transform, moving it in the scene. This happens only if applyRootMotion is true.
Examine the following code snippet inside OnAnimatorMove(). The GameObject jitters when moving. What is the cause?
void OnAnimatorMove() {
transform.position += animator.deltaPosition;
transform.rotation = animator.rootRotation;
}Check the applyRootMotion setting and how root motion is applied automatically.
If applyRootMotion is true, Unity applies root motion automatically. Manually adding deltaPosition causes the GameObject to move twice, resulting in jitter.
Choose the code snippet that correctly overrides OnAnimatorMove() to apply root motion only on the horizontal plane (X and Z), ignoring vertical movement.
Remember that transform.position += motion adds movement, while transform.position = motion sets absolute position.
Option A correctly zeroes out the Y component and adds the horizontal root motion to the current position. Option A incorrectly sets position absolutely, causing snapping. Option A uses Translate(motion), which applies the motion in local space (default Space.Self) instead of world space, making it incorrect for root motion deltaPosition. Option A does not ignore vertical movement.
You want to use root motion to move a character with a Rigidbody component for physics interactions. Which approach correctly applies root motion to the Rigidbody without breaking physics simulation?
Think about how to move Rigidbody objects properly to keep physics stable.
Using rigidbody.MovePosition and MoveRotation inside OnAnimatorMove() applies root motion while respecting physics. Directly setting position or rotation breaks physics and causes jitter.