- Home /
How to Create Separate Volumes
I want to create separate volumes for music and SFX. But from what I could find there's only the global volume called AudioSource.volume. So how exactly do you create separate volumes if there's only one global volume? Do you call the volumes you want to separate by tag maybe? I apologize if I'm being a bit unclear as I'm not familiar with how AudioSources work.
Answer by Bunny83 · Oct 06, 2015 at 01:59 AM
The master volume is actually on the AudioListener which is usually attached to your camera since you usually want to hear what you see.
Each AudioSource (as you already mentioned) also has a volume. With that you can control the volume of each audio source seperately that you have in your scene.
Note: AudioListener.volume
is a static property since there should only be one listener at a time. This is the global master volume. AudioSource.volume is an instance property (not static), so each AudioSource component has it's own volume and you need a reference to your desired AudioSource to access the volume.
So if I wanted to create group of audiosources I could just tag them and call them by the tag. However the gameobjects that the audiosources are attached to already have tags. Any ideas what I should do then? I could create and parent an empty gameobject specifically for the audiosource but then I have to go through the empty gameobject in order to access the audiosource.