Challenge - 5 Problems
Animator Controller Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output of this Animator parameter check?
Consider a 2D Unity Animator with a boolean parameter named isRunning. The following C# code runs inside
Update(). What will be printed if isRunning is true?Unity
Animator animator;
void Start() {
animator = GetComponent<Animator>();
}
void Update() {
if (animator.GetBool("isRunning")) {
Debug.Log("Character is running");
} else {
Debug.Log("Character is idle");
}
}Attempts:
2 left
💡 Hint
Check what
GetBool returns when the parameter is true.✗ Incorrect
The
GetBool method returns the current value of the boolean parameter. Since isRunning is true, the first branch runs and prints 'Character is running'.🧠 Conceptual
intermediate1:30remaining
Which Animator transition condition triggers a jump animation?
You have a 2D character with an Animator. The jump animation should start when the parameter
JumpPressed becomes true. Which transition condition correctly triggers the jump animation?Attempts:
2 left
💡 Hint
Think about when you want the jump animation to start.
✗ Incorrect
The jump animation should start when
JumpPressed is true, so the transition condition must check for JumpPressed == true.🔧 Debug
advanced2:00remaining
Why does the Animator not switch to the 'Run' animation?
You have this code to set the Animator parameter
Speed based on player input. The 'Run' animation should play when Speed > 0.1, but it never does. What is the problem?Unity
Animator animator;
void Start() {
animator = GetComponent<Animator>();
}
void Update() {
float horizontalInput = Input.GetAxisRaw("Horizontal");
animator.SetFloat("Speed", horizontalInput);
}Attempts:
2 left
💡 Hint
Check the range of values returned by Input.GetAxisRaw.
✗ Incorrect
Input.GetAxisRaw returns -1, 0, or 1. If the transition condition checks for Speed > 0.1, negative Speed values prevent the transition. The code should use Mathf.Abs(horizontalInput) to get positive Speed.
📝 Syntax
advanced1:30remaining
Which code snippet correctly sets a trigger parameter in Animator?
You want to start a 'Jump' animation by setting a trigger parameter named
JumpTrigger. Which code snippet is correct?Attempts:
2 left
💡 Hint
Triggers are set with a special method, not like bool or float.
✗ Incorrect
The method to set a trigger parameter is
SetTrigger. Options B and C set wrong parameter types. Option A uses a non-existent method.🚀 Application
expert2:00remaining
How many states are in this Animator Controller?
An Animator Controller has these states: Idle, Walk, Run, Jump, Fall. There is also a sub-state machine named 'Combat' with states: Attack, Block, Dodge. How many total states does the Animator Controller have?
Attempts:
2 left
💡 Hint
Count all states including those inside sub-state machines.
✗ Incorrect
The main states are 5: Idle, Walk, Run, Jump, Fall. The sub-state machine 'Combat' has 3 states: Attack, Block, Dodge. Total states = 5 + 3 = 8.