0
0
Unityframework~10 mins

Audio Source component 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 play an audio clip using AudioSource.

Unity
AudioSource audio = GetComponent<AudioSource>();
audio.[1]();
Drag options to blanks, or click blank then click option'
APlay
BStop
CPause
DMute
Attempts:
3 left
💡 Hint
Common Mistakes
Using Stop() instead of Play() will stop the sound.
Pause() pauses the sound but does not start it.
Mute is a property, not a method.
2fill in blank
medium

Complete the code to set the volume of the AudioSource to half.

Unity
AudioSource audio = GetComponent<AudioSource>();
audio.volume = [1];
Drag options to blanks, or click blank then click option'
A1.0f
B0.5f
C0
D2.0f
Attempts:
3 left
💡 Hint
Common Mistakes
Setting volume to 2.0f is invalid and will be clamped.
Setting volume to 0 will mute the sound.
Using 1.0f plays at full volume, not half.
3fill in blank
hard

Fix the error in the code to play a one-shot sound effect.

Unity
AudioSource audio = GetComponent<AudioSource>();
audio.[1](clip);
Drag options to blanks, or click blank then click option'
APlay
BPlayDelayed
CPlayOneShot
DPlayClipAtPoint
Attempts:
3 left
💡 Hint
Common Mistakes
Using Play() will interrupt the current clip.
PlayClipAtPoint is a static method, not called on AudioSource.
PlayDelayed plays after a delay, not immediately.
4fill in blank
hard

Fill both blanks to create a looped audio playback with half volume.

Unity
AudioSource audio = GetComponent<AudioSource>();
audio.loop = [1];
audio.volume = [2];
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
C0.5f
D1.0f
Attempts:
3 left
💡 Hint
Common Mistakes
Setting loop to false disables repeating.
Volume 1.0f is full volume, not half.
Using integers instead of floats for volume causes errors.
5fill in blank
hard

Fill all three blanks to play a clip at a specific position with volume and pitch set.

Unity
AudioSource audio = gameObject.AddComponent<AudioSource>();
audio.clip = [1];
audio.volume = [2];
audio.pitch = [3];
audio.Play();
Drag options to blanks, or click blank then click option'
AmyClip
B0.8f
C1.2f
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Setting clip to null causes no sound.
Volume above 1.0f is invalid.
Pitch below 0.5 or above 2.0 sounds unnatural.