- Home /
Make Audio Listener hear certain audio
Hi guys,
In my level I have an inventory. When It is open I would like the timescale to be 0, but when the inventory is closed it will be back to 1.
Problem with this is this causes some audio issues, so i've paused the cameras audio listener too along with the time.timescale being 0 when the inventory is open.
This all works fine, however, it all seems rather empty in terms of sound. so I thought add some ambient music when the inventory is open. How would I do this, if the audiolistener is paused? So I thought, Have a second object with an audio listener that gets enabled only when the inventory is open, that is set to only hear the ambient sound. is this possible?
Thanks
Answer by Magso · Jan 04, 2019 at 11:45 PM
Put everything you don't want to hear in an array then use a for loop to mute and unmute them, like
void OnMouseDown ()
{
for (int i = 0; i < itemsToMute.Length; i++)
{
itemsToMute[i].GetComponent<AudioSource>().mute = true;
}
}
Answer by nomadic · Jan 04, 2019 at 11:58 PM
A good way to handle this would be the AudioMixer: https://docs.unity3d.com/Manual/AudioMixer.html
Make a group for gameplay sound and separate one for ambient and fade them in/out accordingly.
Your answer
Follow this Question
Related Questions
Smooth damp the lowpass frequency in coroutine: value only changing in 1 frame 1 Answer
Can I add more than one Audio listener in one scene? 1 Answer
I get this error when selecting an audio from the project folder. 0 Answers
Prevent audio listener from duplicating 1 Answer
I can mute in Unity Player but in exported VR Android version I cant 0 Answers