I have a scene with various noises and effects that need their volume to be universally turned down when I enter a space to fake a sense of insulation.
i.e. A man walking on a beach with ocean and bird sounds walks into a villa where the sounds will be insulated by the walls.
Can this be done simply? Am I being simple in assuming that a mesh/element can’t have an insulation factor assigned to it?
Cheers for any help.
Nobody?
What about something like an activator that when the character moves into/through it the character enters a new, identical scene where there are no sounds? Can this be done?
I’d prefer if I could have an invisible plane at the door threshold where if the main camera passes through it the external sounds are muted, and the internal are turned up?
You could use a trigger, and when they enter the trigger execute a script that accesses all the sounds that are currently playing and turns down their volume.
You could use tags to identify all the gameObjects with sounds that are tagged as “outside” and the others be tagged as “inside”, etc.
Maybe you could employ audioSource = gameObject.FindWithTag(“Outside”);
or something similar, and then do audioSource.audio.volume = 0.1; when you enter the trigger.
Just an idea…
OK so that sort of works,
I can get a sound which is attached to the “First Person Controller” GameObject and tagged as an “outsideSound” to mute when entering the trigger but how do I get all the other sounds in the scene to also mute?
Sort of figured it out.
I have to have the tagged sound assets in the FPS Controller game object which are ‘world’ sounds so don’t diminish in level anywhere on the scene.
function OnTriggerEnter () {
audioSource = GameObject.FindWithTag("outsideSound");
audioSource.audio.volume = audioSource.audio.volume * 0.5;
}
function OnTriggerExit () {
audioSource = GameObject.FindWithTag("outsideSound");
audioSource.audio.volume = audioSource.audio.volume * 2;
}
Just a side note, but have you tried out the audio effects and filters in Unity Pro?
They are extremely useful and you can make interesting gameplay if used in creative ways…
It’s simpler if you just mute the volume of the audio listener, rather than all the audio sources.
–Eric