0
0
Unityframework~20 mins

Animator controller for 2D in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Animator Controller Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1: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");
    }
}
ACharacter is idle
BNo output
CNullReferenceException error
DCharacter is running
Attempts:
2 left
💡 Hint
Check what GetBool returns when the parameter is true.
🧠 Conceptual
intermediate
1: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?
ATransition condition: <code>JumpPressed == true</code>
BTransition condition: <code>JumpPressed != true</code>
CTransition condition: <code>JumpPressed > 0</code>
DTransition condition: <code>JumpPressed == false</code>
Attempts:
2 left
💡 Hint
Think about when you want the jump animation to start.
🔧 Debug
advanced
2: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);
}
AAnimator parameter 'Speed' is not defined as float
BInput.GetAxisRaw returns -1, 0, or 1, so Speed can be negative
CAnimator component is not assigned to the variable
DInput.GetAxisRaw returns 0 or 1, so Speed never exceeds 0.1
Attempts:
2 left
💡 Hint
Check the range of values returned by Input.GetAxisRaw.
📝 Syntax
advanced
1: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?
Aanimator.SetTrigger("JumpTrigger");
Banimator.SetBool("JumpTrigger", true);
Canimator.SetFloat("JumpTrigger", 1);
Danimator.Trigger("JumpTrigger");
Attempts:
2 left
💡 Hint
Triggers are set with a special method, not like bool or float.
🚀 Application
expert
2: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?
A6
B5
C8
D7
Attempts:
2 left
💡 Hint
Count all states including those inside sub-state machines.