Audio not fading out and playing beyond maximum distance. ASAP!

Hi,

I have my audio attached to a game object which is triggered via a box collider. That all works fine, however my problem is when i leave the area, i can still hear the audio playing beyond the maximum distance that i’ve set. Any way to resolve this? I need it sorted ASAP!!

Need code.

#pragmastrict

functionOnTriggerEnter(other: Collider){
if (!audio.isPlaying){
audio.Play();
}

}

Did you make sure the audio clip is setup for 3d in the import settings? A screenshot of the inspector with the audio source would also be useful.

If you use code tags in the forum, your code is a lot more readable:

Yeah they are all 3D Sounds. i have a reverb zone as well to see if this would help with the fading out but its not.

1733115--109387--Screen Shot 2014-08-13 at 12.09.37.png
1733115--109388--Screen Shot 2014-08-13 at 12.09.56.png

You should get rid of the reverb zone, as it will impact the way in which you hear the audio and as such it makes it harder to resolve the issue.

Did you check that you only have one AudioListener in the scene? Did you check that the AudioSource is not attached to the listener?
How does it behave if you move away from the AudioSource? How does the heard volume change if you move away from the source? Does it fade out at all?

Yeah i have only one listener in the scene. All the Audio Sources are attached to game objects.

whenever i trigger the sound i walk away and it still plays as normal. no volume change or no fade out.

Did check the scale of your scene?

How do you do that?

Create an empty game object, move it around, and check the position of it, such that you can be sure that what you think is one unit, is really one unit.

Yeah, one unit is one unit it appears

Could you show the whole inspector of your audio source and the one of the audio listener?

The code you provided only has to do with triggering, playing the audio. It has nothing to do with fading out audio.

I cant help you with what you have shown.

is there a way to make the audio fade out via script though?

theres the photos you required

1733244--109398--Screen Shot 2014-08-13 at 14.23.49.png
1733244--109399--Screen Shot 2014-08-13 at 14.24.09.png
1733244--109400--Screen Shot 2014-08-13 at 14.24.20.png

Read the text in the third image.

audio.volume -= someFactor;

repeat that method, over time. Via an update, coroutine etc.

if audio.volume == 0, return.

But the goal is to fade out by distance. That is already in Unity. There is no need for actual scripting. The problem is that JamieLawson has other scripts that influence the fading.

Oh.
Can he not monitor Distance() and use this value to apply the fade factor?

I would think so.

Look up Distance(). Use this value to come up with a factor to reduce or increase your volume by.

Why waste resources if Unity supports it out of the box?