0
0
Unityframework~10 mins

Animator controller 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 get the Animator component from the GameObject.

Unity
Animator animator = gameObject.GetComponent<[1]>();
Drag options to blanks, or click blank then click option'
AAnimator
BAnimation
CRenderer
DCollider
Attempts:
3 left
💡 Hint
Common Mistakes
Using Animation instead of Animator
Trying to get Renderer or Collider which are unrelated
2fill in blank
medium

Complete the code to play the animation state named "Run".

Unity
animator.[1]("Run");
Drag options to blanks, or click blank then click option'
ASetTrigger
BPlay
CStart
DTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetTrigger instead of Play
Using Start which is not a method of Animator
3fill in blank
hard

Fix the error in setting a trigger parameter named "Jump".

Unity
animator.[1]("Jump");
Drag options to blanks, or click blank then click option'
APlay
BStartTrigger
CSetTrigger
DTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using Play instead of SetTrigger
Using a non-existent method like Trigger or StartTrigger
4fill in blank
hard

Fill both blanks to check if the Animator is currently playing the "Idle" state in layer 0.

Unity
bool isIdle = animator.GetCurrentAnimatorStateInfo([1]).IsName([2]);
Drag options to blanks, or click blank then click option'
A0
B"Idle"
C"Run"
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using layer 1 instead of 0
Checking for "Run" instead of "Idle"
5fill in blank
hard

Fill all three blanks to smoothly transition to the "Jump" animation using a trigger and a float parameter for speed.

Unity
animator.[1]("JumpTrigger");
animator.SetFloat("Speed", [2]);
animator.[3]("Jump");
Drag options to blanks, or click blank then click option'
ASetTrigger
B1.0f
CPlay
DResetTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using ResetTrigger instead of SetTrigger
Using an integer instead of float for speed
Using Start instead of Play