0
0
Unityframework~10 mins

Animation parameters in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set an Animator parameter named "speed" to a float value.

Unity
Animator animator = GetComponent<Animator>();
animator.SetFloat("speed", [1]);
Drag options to blanks, or click blank then click option'
A5.0f
Btrue
C1
D"fast"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a boolean or string instead of a float.
Forgetting the 'f' suffix for float literals.
2fill in blank
medium

Complete the code to check if the Animator parameter "isJumping" is true.

Unity
Animator animator = GetComponent<Animator>();
if (animator.GetBool("isJumping") == [1]) {
    // Jump logic here
}
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
C1
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing to 1 instead of true.
Using false instead of true.
3fill in blank
hard

Fix the error in the code to set the Animator trigger parameter "attack".

Unity
Animator animator = GetComponent<Animator>();
animator.[1]("attack");
Drag options to blanks, or click blank then click option'
ASetBool
BGetTrigger
CSetFloat
DSetTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetBool or SetFloat instead of SetTrigger.
Trying to get a trigger value with GetTrigger (which doesn't exist).
4fill in blank
hard

Fill both blanks to create a dictionary of animation parameters with their types.

Unity
var animationParams = new Dictionary<string, [1]>() {
    {"speed", [2].Float},
    {"isRunning", AnimatorControllerParameterType.Bool}
};
Drag options to blanks, or click blank then click option'
AAnimatorControllerParameterType
Bint
Cfloat
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using primitive types like int or float instead of the enum.
Mixing types in the dictionary values.
5fill in blank
hard

Fill all three blanks to set multiple Animator parameters correctly.

Unity
Animator animator = GetComponent<Animator>();
animator.[1]("jumpHeight", 2.5f);
animator.[2]("isGrounded", [3]);
Drag options to blanks, or click blank then click option'
ASetFloat
BSetBool
Ctrue
DSetTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetTrigger for non-trigger parameters.
Passing incorrect value types to methods.