- Home /
Audio fade in and out?
Is there a way of making audios volume increase and decrease based on a players position in regards to the audio in unity2D?
For example, I have static from a television in one room of the level, however when the player has moved to the next room the static will be quieter and when the player comes back into the television room, the volume increase.
Answer by rmassanet · Jul 19, 2016 at 07:17 AM
There's a property in the AudioSource component that lets you configure exactly that behaviour. Set the Spatial Blend property to 2D. Then expand the 3D Sound Settings and configure the decay curve. This curve represents the audio volume as a function of distance to the source.
I was playing around with this, and it doesn't seem like any of the different curve configurations I've used are making it fade at all, is there a specific curve or rollover type that would do this?
Where is your AudioListener attached? By default it is attached to the $$anonymous$$ain Camera. The fade effect is affected by the position of the AudioListener relative to the AudioSource. So, if your camera does not move with the player, then you probably need to remove the AudioListener component from the camera and attach it to the player. You should only have one AudioListener per scene.
Okay, I just changed it and now my Audio listener is on the player ins$$anonymous$$d, but it's still not changing how the sound is recognized.
In the first image, is how far essentially I want the sound to travel, so basically only staying in the room. And the second image is the current settings, (which aren't working). Thank you for helping.
Your answer
![](https://koobas.hobune.stream/wayback/20220612085102im_/https://answers.unity.com/themes/thub/images/avi.jpg)