0
0
Unityframework~10 mins

2D animation basics 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 declare a variable for the Animator component.

Unity
Animator [1];
Drag options to blanks, or click blank then click option'
AanimComp
Banimation
Canim
Danimator
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not descriptive or too long.
2fill in blank
medium

Complete the code to get the Animator component from the GameObject.

Unity
animator = GetComponent<[1]>();
Drag options to blanks, or click blank then click option'
ASpriteRenderer
BAnimation
CAnimator
DRigidbody2D
Attempts:
3 left
💡 Hint
Common Mistakes
Using Animation instead of Animator.
3fill in blank
hard

Fix the error in the code to play the 'Jump' animation using the Animator.

Unity
animator.[1]("Jump");
Drag options to blanks, or click blank then click option'
APlay
Bplay
CStart
DTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'play' which causes a compile error.
4fill in blank
hard

Fill both blanks to check if the Animator is currently playing the 'Run' animation.

Unity
AnimatorStateInfo [1] = animator.GetCurrentAnimatorStateInfo(0);
if ([1].IsName([2])) {
    // Running animation is playing
}
Drag options to blanks, or click blank then click option'
AGetCurrentAnimatorStateInfo
BstateInfo
C"Run"
D"run"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect case for animation name.
Trying to call GetCurrentAnimatorStateInfo twice.
5fill in blank
hard

Fill all three blanks to set a boolean parameter 'isJumping' to true in the Animator.

Unity
animator.[1]("[2]", [3]);
Drag options to blanks, or click blank then click option'
ASetBool
BisJumping
Ctrue
DSetTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetTrigger instead of SetBool.
Passing parameter name without quotes.