Module 7 Challenge
Tutorial
·
intermediate
·
+0XP
·
30 mins
·
(29)
Unity Technologies

This module focuses on enhancing gameplay with sound effects. Learners will explore the use of Unity’s Audio Source component, scripting audio playback, and synchronizing sound effects with gameplay events for an immersive experience.
By the end of this module, learners will be able to:
- Add and configure an Audio Source component to play sound effects.
- Trigger sound effects during gameplay using C# scripting.
- Synchronize sound effects with animations and physics events.
1. Challenge
Challenge
Estimated Time: 30 minutes
In this challenge, modify the sound of the BigExplosion prefab.
Challenge Steps
- Experiment with the pitch value of the AudioSource component on the explosion prefab and the Ragdoll prefab.
- Set the Stereo Blend property to 1 on the BigExplosion prefab’s AudioSource and the Ragdoll as well to see how distance affects the audio playback.
2. Bonus Challenge
Bonus Challenge
- Update the Ragdoll class to include two new public float variables called pitchMin and pitchMax. Set the default value of pitchMin above 0 but below the pitchMax value and set the pitchMax default between 1 and 3.
- Add the following line of code above the audioSource.Play() method:
- audioSource.pitch = Random.Range(pitchMin, pitchMax);
- Experiment with the pitchMin and pitchMax values to see how pitch affects the audio effects.