Learn to work with audio listeners for hearing music and sound effects.
- [Instructor] In this section of the course, I'm going to be looking at audio mixers and audio groups, and looking at how we can use those to balance the volume of different audio sources inside a level. To get started illustrating the potential problem that might arise, I'm going to be using this simple scene that you can see inside the viewport here. It relies on the metal mayhem music pack that is provided for free by Unity Technologies from the Unity Asset Store, you can go ahead and download that for free. But it's included here inside the course companion files. Inside this scene, we have two sound items. On the left hand side we have a footstep sound effect, and then we have a music track. If I select these different objects inside the hierarchy panel, you can see that each of these sounds is specified as having a spatial blend of 2D, meaning that the sound doesn't depend on the position of the player character, it is not spatially located in the scene, and so we can hear that at a uniform volume absolutely anywhere. In addition to this, it's set to Play On Awake, which means that it's going to play automatically when the level begins. And secondly, we also have the Loop enabled here, and that loop is enabled for both of these sound items, and that simply means that when the track is finished playing, it will loop around and play again from the beginning infinitely. If I now press play on the toolbar, we're effectively going to hear an audio mess. We're going to have the music track playing, and the footsteps playing repeatedly, and it's not going to be easy to differentiate each one. Let's take a listen to that. (rock music with footsteps) Now the primary problem here is that we heard the footsteps playing, and if you listened carefully, you may have been able to distinguish the footsteps. Now, to balance these two sound items, to balance these two audio sources, one obvious way might be for example to select the music track and to move to the Volume slider. And I'm going to reduce that down to maybe 0.3, like so. Remember, this is a multiplier, so it's going to take the default volume inside the music track file and multiply that by 0.3. I'm going to press play on the toolbar. (quiet rock music with footsteps) In this instance, we can begin to hear the footsteps more prominently, by reducing the music track volume. So we're starting to create a balance between these two elements. Now, in the case of this example, we have only two audio sources, the music track and the footsteps. But in more complex scenes, it's likely we're going to have quite a lot of different elements. And balancing these different elements is going to become very time-consuming, and pretty tricky if all we're doing is visiting each audio source and reducing the volume parameter. I'm going to restore that back to 1. Instead, we can use a different feature inside Unity called the Audio Mixer to give us more high-level control over individual audio sources, but over groups of audio sources. In the next movie, we're going to see how we can create an audio mixer to get more control over audio in our scenes.
Find out more about Unity Certified Associate exam at https://certification.unity.com/products/certified-associate.
- Importing audio files
- Configuring audio listeners and sources
- Creating mixers
- Coding with AudioSources
- Adding sound effects for characters and events
- Building a particle system
- Configuring particle collisions