Challenge - 5 Problems
Animation Parameters Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Animator parameter check?
Consider the following Unity C# code snippet that checks an Animator parameter. What will be printed in the console?
Unity
Animator animator = GetComponent<Animator>(); animator.SetBool("isJumping", true); if (animator.GetBool("isJumping")) { Debug.Log("Jumping"); } else { Debug.Log("Not jumping"); }
Attempts:
2 left
💡 Hint
Check what value is set and then retrieved from the Animator parameter.
✗ Incorrect
The code sets the boolean parameter "isJumping" to true, then checks it. Since it is true, it prints "Jumping".
🧠 Conceptual
intermediate1:30remaining
Which Animator parameter type is best for storing a player's health value?
In Unity's Animator, you want to store the player's health to influence animations. Which parameter type should you use?
Attempts:
2 left
💡 Hint
Health is usually a whole number value.
✗ Incorrect
An Int parameter is best for whole number values like health. Float is for decimals, Bool for true/false, Trigger for one-time events.
🔧 Debug
advanced2:30remaining
Why does this Animator parameter code cause an error?
Examine the code below. Why does it cause a runtime error?
Unity
Animator animator = GetComponent<Animator>(); animator.SetTrigger("attack"); bool isAttacking = animator.GetBool("attack");
Attempts:
2 left
💡 Hint
Check the parameter types used with SetTrigger and GetBool.
✗ Incorrect
The code sets a Trigger parameter "attack" but tries to get it as a Bool. This causes an error because parameter types must match.
📝 Syntax
advanced1:30remaining
Which option correctly sets a float Animator parameter named "speed" to 5.5?
Choose the correct Unity C# code to set the float parameter "speed" to 5.5.
Attempts:
2 left
💡 Hint
Parameter name must be a string and value a float.
✗ Incorrect
SetFloat requires the parameter name as a string and the value as a float. Option D matches this.
🚀 Application
expert3:00remaining
How many parameters are in the Animator after this code runs?
Given an Animator with no parameters initially, what is the count of parameters after running this code snippet?
Unity
Animator animator = GetComponent<Animator>(); animator.SetBool("isRunning", true); animator.SetFloat("speed", 3.0f); animator.SetTrigger("jump"); animator.SetInteger("lives", 5);
Attempts:
2 left
💡 Hint
Think about how Animator parameters are created and stored in Unity.
✗ Incorrect
Animator parameters must be created in the Animator Controller before runtime. Setting parameters by code does not add new parameters automatically.