Consider a Unity Animator Controller with a boolean parameter named isRunning. The Animator has two states: Idle and Run. The transition from Idle to Run happens when isRunning is true, and from Run to Idle when false.
What will be the output of the following code snippet controlling the Animator?
Animator animator = GetComponent<Animator>(); animator.SetBool("isRunning", true); bool currentState = animator.GetBool("isRunning"); Debug.Log(currentState);
Think about what SetBool and GetBool do in the Animator component.
The SetBool method sets the boolean parameter isRunning to true. Then GetBool returns the current value of that parameter, which is true. So the output logged is True.
In Unity Animator Controller, which of the following is NOT a valid condition type you can use to control transitions?
Think about the types of parameters Animator supports for transitions.
Animator Controller supports float, int, bool, and trigger parameters for transitions. It does not support string parameters for conditions.
What error will occur when running this code snippet in Unity if the Animator Controller does not have a parameter named jumping?
Animator animator = GetComponent<Animator>();
animator.SetBool("jumping", true);Consider what happens if you try to set a parameter that is not defined in the Animator Controller.
Unity throws an ArgumentException if you try to set a parameter that does not exist in the Animator Controller.
Given an Animator Controller with a trigger parameter named attack, what will be the output of this code snippet?
Animator animator = GetComponent<Animator>(); animator.SetTrigger("attack"); bool isSet = animator.GetBool("attack"); Debug.Log(isSet);
Think about the difference between trigger and bool parameters and how GetBool works.
The parameter attack is a trigger, not a bool. Calling GetBool("attack") causes an ArgumentException because the parameter type does not match.
You have an Animator Controller with 3 layers. The Base Layer has 4 states, the UpperBody Layer has 3 states, and the LowerBody Layer has 5 states. How many total states are in the Animator Controller?
Count all states across all layers.
Total states = 4 (Base Layer) + 3 (UpperBody) + 5 (LowerBody) = 12 states.