Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What component do you need to add to a GameObject to play a sound effect in Unity?
You need to add an AudioSource component to the GameObject. This component plays audio clips attached to it.
Click to reveal answer
beginner
How do you play a one-time sound effect using AudioSource in a script?
Use the method AudioSource.PlayOneShot(AudioClip clip) to play a sound once without interrupting other sounds.
Click to reveal answer
intermediate
What is the difference between AudioSource.Play() and AudioSource.PlayOneShot()?
Play() plays the AudioSource's assigned clip and can be stopped or looped. PlayOneShot() plays a clip once immediately without affecting the AudioSource's main clip.
Click to reveal answer
intermediate
How can you make sure a sound effect plays at a specific position in the game world?
Attach the AudioSource component to a GameObject placed at the desired position. Unity will play the sound spatially based on the GameObject's location.
Click to reveal answer
beginner
What must you do before playing a sound effect in Unity using a script?
You must have an AudioClip loaded and assigned, and an AudioSource component ready to play it.
Click to reveal answer
Which Unity component is required to play sound effects?
AAudioListener
BAudioSource
CAudioClip
DAudioMixer
✗ Incorrect
AudioSource is the component that plays audio clips in Unity.
What method plays a sound effect once without interrupting other sounds?
APlay()
BPause()
CStop()
DPlayOneShot()
✗ Incorrect
PlayOneShot() plays a clip once immediately without stopping other sounds.
Where should you place the AudioSource component to make a sound play at a specific location?
AOn the main camera
BOn the AudioListener
COn a GameObject at that location
DOn the UI canvas
✗ Incorrect
Placing AudioSource on a GameObject at the location makes the sound spatially accurate.
What do you need to assign to an AudioSource to play a sound?
AAudioClip
BAudioListener
CAudioMixer
DAudioFilter
✗ Incorrect
AudioClip is the sound file assigned to AudioSource to be played.
Which method would you use to stop a currently playing sound on an AudioSource?
AStop()
BPause()
CPlayOneShot()
DPlay()
✗ Incorrect
Stop() immediately stops the AudioSource from playing.
Explain how to play a sound effect at a specific position in Unity.
Think about where the sound should come from in the game world.
You got /4 concepts.
Describe the difference between AudioSource.Play() and AudioSource.PlayOneShot().
Consider how each method handles the sound clip and other sounds.
You got /4 concepts.
Practice
(1/5)
1. In Unity, which method is commonly used to play a short sound effect without interrupting other sounds?
easy
A. AudioSource.Play()
B. AudioSource.PlayOneShot()
C. AudioClip.Play()
D. SoundManager.PlaySound()
Solution
Step 1: Understand AudioSource methods
AudioSource.Play() plays the assigned clip but can interrupt sounds if called repeatedly.
Step 2: Identify method for playing short effects without interruption
AudioSource.PlayOneShot() plays a clip once without stopping other sounds.
Final Answer:
AudioSource.PlayOneShot() -> Option B
Quick Check:
PlayOneShot plays short sounds without interruption [OK]
Hint: Use PlayOneShot for quick sound effects without stopping others [OK]
Common Mistakes:
Using AudioSource.Play() which can cut off sounds
Trying to call Play() on AudioClip directly
Assuming a custom SoundManager method exists by default
2. Which of the following is the correct way to declare an AudioSource variable in a Unity C# script?
easy
A. AudioSource audioSource;
B. AudioSource audio = new AudioSource();
C. var audioSource = AudioSource();
D. AudioSource audioSource = AudioClip();
Solution
Step 1: Recall correct AudioSource declaration
In Unity C#, you declare a variable by specifying the type and name, like AudioSource audioSource;.
Step 2: Identify incorrect declarations
new AudioSource() is not used directly; AudioSource() is not a constructor; assigning AudioClip to AudioSource variable is invalid.
Final Answer:
AudioSource audioSource; -> Option A
Quick Check:
Declare AudioSource with type and name only [OK]
Hint: Declare AudioSource as 'AudioSource variableName;' [OK]
Common Mistakes:
Trying to instantiate AudioSource with new keyword
Using AudioClip() as constructor for AudioSource
Using var without assignment
3. What will be the output when the following Unity C# code runs?
public class SoundTest : MonoBehaviour {
public AudioSource audioSource;
public AudioClip clip;
void Start() {
audioSource.PlayOneShot(clip);
audioSource.PlayOneShot(clip);
}
}
medium
A. Compilation error due to PlayOneShot usage.
B. The clip plays once, second call is ignored.
C. The clip plays twice overlapping without interruption.
D. Only the second clip plays, first is stopped.
Solution
Step 1: Understand PlayOneShot behavior
PlayOneShot plays the clip immediately without stopping other sounds, allowing overlap.
Step 2: Analyze two calls in Start()
Both calls play the clip one after another quickly, resulting in overlapping sounds.
Final Answer:
The clip plays twice overlapping without interruption. -> Option C
Quick Check:
PlayOneShot allows overlapping sounds [OK]
Hint: PlayOneShot plays clips overlapping if called multiple times quickly [OK]
Common Mistakes:
Thinking second PlayOneShot call cancels first
Assuming PlayOneShot causes compile error
Confusing PlayOneShot with Play() behavior
4. Identify the error in this Unity C# code snippet for playing a sound effect:
public class PlaySound : MonoBehaviour {
public AudioSource audioSource;
public AudioClip clip;
void Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
audioSource.Play(clip);
}
}
}
medium
A. AudioSource.Play() does not take parameters; should use PlayOneShot.
B. AudioClip cannot be public.
C. Input.GetKeyDown is invalid in Update method.
D. AudioSource must be assigned in Start(), not public.
Solution
Step 1: Check AudioSource.Play() usage
AudioSource.Play() does not accept parameters; it plays the assigned clip only.
Step 2: Correct method to play clip parameter
Use AudioSource.PlayOneShot(clip) to play a clip passed as argument.
Final Answer:
AudioSource.Play() does not take parameters; should use PlayOneShot. -> Option A
Quick Check:
PlayOneShot plays clip parameter; Play() does not [OK]
Hint: Use PlayOneShot to play a clip parameter, not Play() [OK]
Common Mistakes:
Passing AudioClip to Play() method
Thinking Input.GetKeyDown is invalid in Update
Believing AudioSource must be private
5. You want to play different sound effects on player actions using one AudioSource. Which approach correctly plays a jump sound and a hit sound without cutting each other off?
public AudioSource audioSource;
public AudioClip jumpSound;
public AudioClip hitSound;
void PlayJump() {
// ???
}
void PlayHit() {
// ???
}
hard
A. Use audioSource.Play(); without assigning clips.
B. Assign audioSource.clip = jumpSound; then call audioSource.Play(); in PlayJump; same for hitSound in PlayHit.
C. Create new AudioSource for each sound effect and call Play() on each.
D. Use audioSource.PlayOneShot(jumpSound); in PlayJump and audioSource.PlayOneShot(hitSound); in PlayHit.
Solution
Step 1: Understand playing multiple sounds on one AudioSource
Using PlayOneShot() allows playing multiple clips without interrupting each other.
Step 2: Analyze options
Use audioSource.PlayOneShot(jumpSound); in PlayJump and audioSource.PlayOneShot(hitSound); in PlayHit. uses PlayOneShot correctly; Assign audioSource.clip = jumpSound; then call audioSource.Play(); in PlayJump; same for hitSound in PlayHit. overwrites clip and may cut sounds; Create new AudioSource for each sound effect and call Play() on each. is inefficient; Use audioSource.Play(); without assigning clips. plays nothing.
Final Answer:
Use audioSource.PlayOneShot(jumpSound); and audioSource.PlayOneShot(hitSound); -> Option D
Quick Check:
PlayOneShot plays multiple clips on one AudioSource [OK]
Hint: PlayOneShot plays multiple clips on one AudioSource without cutting [OK]