0
0
Unityframework~10 mins

Playing sound effects 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 a sound effect 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() stops the sound.
Using Pause() pauses but does not start the sound.
Mute is not a method, it is a property.
2fill in blank
medium

Complete the code to assign an AudioClip to the AudioSource before playing.

Unity
AudioSource audio = GetComponent<AudioSource>();
audio.clip = [1];
audio.Play();
Drag options to blanks, or click blank then click option'
AsoundEffect
BaudioSource
CGetComponent<AudioClip>()
DPlay
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the AudioSource instead of the AudioClip.
Calling a method instead of assigning a variable.
Using Play instead of an AudioClip variable.
3fill in blank
hard

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

Unity
AudioSource audio = GetComponent<AudioSource>();
audio.[1](soundEffect);
Drag options to blanks, or click blank then click option'
APlayDelayed
BPlay
CPlayClipAtPoint
DPlayOneShot
Attempts:
3 left
💡 Hint
Common Mistakes
Using Play() interrupts the current sound.
PlayClipAtPoint is a static method, not called on AudioSource.
PlayDelayed delays the sound, not immediate play.
4fill in blank
hard

Fill both blanks to check if the AudioSource is playing before starting a new sound.

Unity
AudioSource audio = GetComponent<AudioSource>();
if (!audio.[1]) {
    audio.[2]();
}
Drag options to blanks, or click blank then click option'
AisPlaying
BPlay
CStop
DPause
Attempts:
3 left
💡 Hint
Common Mistakes
Using Stop or Pause in the if condition instead of isPlaying.
Calling Stop() instead of Play() inside the if block.
5fill in blank
hard

Fill all three blanks to play a sound at a specific position in the world.

Unity
AudioSource.PlayClipAtPoint([1], [2], [3]);
Drag options to blanks, or click blank then click option'
AsoundEffect
Btransform.position
C1.0f
DaudioSource
Attempts:
3 left
💡 Hint
Common Mistakes
Passing AudioSource instead of AudioClip.
Passing wrong type for position or volume.
Omitting volume parameter.