0
0
Unityframework~20 mins

Root motion in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Root Motion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this root motion code snippet?

Consider the following Unity C# code inside an Animator's OnAnimatorMove() method. What will be the final position of the GameObject after this frame?

Unity
void OnAnimatorMove() {
    Vector3 rootMotion = animator.deltaPosition;
    rootMotion.y = 0;
    transform.position += rootMotion * 2f;
}
AThe GameObject moves twice the animator's deltaPosition on the XZ plane.
BThe GameObject moves by the animator's deltaPosition including Y axis.
CThe GameObject does not move because rootMotion.y is set to zero.
DThe GameObject moves by half the animator's deltaPosition on the XZ plane.
Attempts:
2 left
💡 Hint

Remember that animator.deltaPosition gives the root motion movement for this frame, and modifying the Y component affects vertical movement.

🧠 Conceptual
intermediate
1:30remaining
Which statement about root motion in Unity is correct?

Choose the correct statement about how root motion works in Unity animations.

ARoot motion is automatically applied even if <code>Animator.applyRootMotion</code> is false.
BRoot motion only affects the rotation of the GameObject, not its position.
CRoot motion applies the movement of the animated root bone directly to the GameObject's transform.
DRoot motion can only be used with Mecanim's legacy animation system.
Attempts:
2 left
💡 Hint

Think about what root motion means in terms of animation and GameObject movement.

🔧 Debug
advanced
2:30remaining
Why does this root motion code cause the GameObject to jitter?

Examine the following code snippet inside OnAnimatorMove(). The GameObject jitters when moving. What is the cause?

Unity
void OnAnimatorMove() {
    transform.position += animator.deltaPosition;
    transform.rotation = animator.rootRotation;
}
AThe rootRotation is not normalized, causing jitter in rotation.
BThe code adds deltaPosition manually but does not set <code>animator.applyRootMotion</code> to false, causing double movement.
CThe code should multiply deltaPosition by Time.deltaTime to smooth movement.
DThe code should use <code>transform.Translate()</code> instead of modifying position directly.
Attempts:
2 left
💡 Hint

Check the applyRootMotion setting and how root motion is applied automatically.

📝 Syntax
advanced
2:00remaining
Which option correctly overrides OnAnimatorMove to apply root motion only on the XZ plane?

Choose the code snippet that correctly overrides OnAnimatorMove() to apply root motion only on the horizontal plane (X and Z), ignoring vertical movement.

A
void OnAnimatorMove() {
    Vector3 motion = animator.deltaPosition;
    motion.y = 0;
    transform.position += motion;
    transform.rotation = animator.rootRotation;
}
B
void OnAnimatorMove() {
    Vector3 motion = animator.deltaPosition;
    transform.position += motion;
    transform.rotation = animator.rootRotation;
}
C
void OnAnimatorMove() {
    Vector3 motion = animator.deltaPosition;
    motion.y = 0;
    transform.Translate(motion);
    transform.rotation = animator.rootRotation;
}
D
void OnAnimatorMove() {
    Vector3 motion = animator.deltaPosition;
    motion.y = 0;
    transform.position = motion;
    transform.rotation = animator.rootRotation;
}
Attempts:
2 left
💡 Hint

Remember that transform.position += motion adds movement, while transform.position = motion sets absolute position.

🚀 Application
expert
3:00remaining
How to synchronize root motion with physics Rigidbody 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?

ASet <code>rigidbody.position += animator.deltaPosition</code> and <code>rigidbody.rotation = animator.rootRotation</code> directly in <code>Update()</code>.
BApply root motion by setting <code>transform.position</code> and <code>transform.rotation</code> directly, ignoring Rigidbody.
CDisable root motion and move the Rigidbody manually using forces based on animation speed.
DIn <code>OnAnimatorMove()</code>, call <code>rigidbody.MovePosition(rigidbody.position + animator.deltaPosition)</code> and <code>rigidbody.MoveRotation(animator.rootRotation)</code>.
Attempts:
2 left
💡 Hint

Think about how to move Rigidbody objects properly to keep physics stable.