How do I set a distance for audioSource ???


How do I set a distance for audioSource ???

thx >>>

You don’t need any script to do that: in the AudioSource, select Rolloff Mode = Linear Rolloff, Max Distance = 5, Min Distance = 4.5 (or other value a little lower than the Max Distance) - this will make the sound disappear when the distance to the audio source is 5 or greater.

For thoose who can’t get a clue why distance to listener looks calculated so strange in 2D - check you Z for camera and for AudioSource!

If you are using Unity 5, find 3D Sound Settings at the bottom of the Audio Source component, expand it, and then find Max Distance and set it to whatever value you want.

But for some reason, i hear the sound everywhere, at the same rate. I think i made something wrong, i’m newbie to Unity.