0
0
Unityframework~20 mins

Animation parameters in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Animation Parameters 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 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");
}
ANo output, throws NullReferenceException
BNot jumping
CJumping
DNo output, throws ArgumentException
Attempts:
2 left
💡 Hint
Check what value is set and then retrieved from the Animator parameter.
🧠 Conceptual
intermediate
1: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?
AInt
BFloat
CTrigger
DBool
Attempts:
2 left
💡 Hint
Health is usually a whole number value.
🔧 Debug
advanced
2: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");
ABecause "attack" is a Trigger, not a Bool parameter, so GetBool throws an error.
BBecause SetTrigger cannot be called without a parameter value.
CBecause GetBool requires the parameter name to be "Attack" with capital A.
DBecause animator is null and causes NullReferenceException.
Attempts:
2 left
💡 Hint
Check the parameter types used with SetTrigger and GetBool.
📝 Syntax
advanced
1: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.
Aanimator.SetFloat(5.5f, "speed");
Banimator.SetFloat(speed, 5.5);
Canimator.SetFloat("speed", "5.5");
Danimator.SetFloat("speed", 5.5f);
Attempts:
2 left
💡 Hint
Parameter name must be a string and value a float.
🚀 Application
expert
3: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);
A1
BCannot determine from code
C0
D4
Attempts:
2 left
💡 Hint
Think about how Animator parameters are created and stored in Unity.