0
0
Unityframework~10 mins

Why animation brings games to life in Unity - Test Your Understanding

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

Complete the code to start the animation when the game begins.

Unity
void Start() {
    GetComponent<Animator>().[1]("Run");
}
Drag options to blanks, or click blank then click option'
APlay
BStop
CPause
DReset
Attempts:
3 left
💡 Hint
Common Mistakes
Using Stop or Pause instead of Play
Forgetting to get the Animator component
2fill in blank
medium

Complete the code to smoothly transition to the 'Jump' animation.

Unity
Animator anim = GetComponent<Animator>();
anim.[1]("Jump", 0, 0f);
Drag options to blanks, or click blank then click option'
ACrossFade
BPlay
CResetTrigger
DStop
Attempts:
3 left
💡 Hint
Common Mistakes
Using Play which switches instantly
Using Stop which halts animations
3fill in blank
hard

Fix the error in the code to trigger the 'Attack' animation using a trigger parameter.

Unity
Animator anim = GetComponent<Animator>();
anim.[1]("AttackTrigger");
Drag options to blanks, or click blank then click option'
ASetBool
BSetTrigger
CSetFloat
DResetTrigger
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetBool or SetFloat which are for other parameter types
Using ResetTrigger which clears a trigger
4fill in blank
hard

Fill both blanks to create a dictionary of animation states and their durations.

Unity
Dictionary<string, float> animationDurations = new Dictionary<string, float>() {
    {"Run", [1],
    {"Jump", [2]
};
Drag options to blanks, or click blank then click option'
A1.2f
B2.5f
C0.8f
D3.0f
Attempts:
3 left
💡 Hint
Common Mistakes
Using integers without 'f' suffix
Mixing up durations for animations
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps animation names to their lengths if length is greater than 1 second.

Unity
var longAnimations = new Dictionary<string, float>() {
    {"Run", [1],
    {"Jump", [2],
    {"Attack", [3]
}.Where(kv => kv.Value > 1).ToDictionary(kv => kv.Key, kv => kv.Value);
Drag options to blanks, or click blank then click option'
A1.2f
B0.8f
C2.0f
D0.5f
Attempts:
3 left
💡 Hint
Common Mistakes
Using durations less than or equal to 1 for all animations
Not using float suffix 'f'