- Home /
Audio Source Volume not Fading Over Distance
Hello everyone, I'm encountering a problem where I can still here a sound being played at full volume even though I am well outside of the audio source's maximum range (see in the pic my player is in the top left, and the sound source is in the bottom right). I have tried making the range of the audio source and changed its roll-off, nothing changes, the should it plays is audible at 100% volume no matter where the player is.
If anyone has an idea as to why this is happening, I would love to know.
Other Notes:
I only have 1 audio listen in the scene (attached to the camera on the player) -> the error message in the console exists because for 1 frame when the level loads additive, there are 2 camera in the scene.
The audio clip is forced to mono (changing this option seems to make no difference)
https://docs.unity3d.com/Documentation/Components/class-AudioSource.html Increase the 3d Pan Level
I see, however, this causes a new problem: see$$anonymous$$gly the only way to get audio to completely fade is to set 3D Pan to 1.0, however at 1.0 the audio gets way too specific (turning left or right completely shuts off audio from one side or the other). You can reduce pan, but then the audio never entirely fades out.
-Is there a way to deal with this? I'm using spread angle @ 180 degrees and it seems to work, but I'm wondering if there are any potential problems or draw backs to doing this.
Answer by AfroDieter · Sep 28, 2015 at 06:28 AM
Kind of a late reply but for whatevery reason this has to do with the "Spatial Blend" slider. Just set it to 1 and you will have it as you intended.
Hi.
I just came across this post.
setting the Spatial Blend to 1 did stop my 2nd source from being heard everywhere, but now I cannot hear it at all, even when I am right next to it.
It did work for me. $$anonymous$$aybe you also need to change "Volume Rolloff" to "Linear Rolloff"? The standard "Logarithmic Rolloff" is insanely punishing if you look at the graph.
Answer by Dabwam · Dec 14, 2016 at 08:32 PM
@TheRedGuy90 Not sure if you still have this problem, but I thought I'd post it anyways. Try setting the maximum distance to 30 or something and the minimum distance to 1, this worked for me along with setting the spatial blend to 1.
I actually am still having trouble; I'll try this out. Thank you.
Answer by Superbhaley · Apr 02, 2017 at 09:54 AM
Well this is not what you'd call an answer but I had too had also set the Spatial Blender to 1, the minimum distance to 1, and the maximum distance to 30 and I still have the Audio Fade problem so some1 please help me out as soon as possible I really need it.
Answer by mitaywalle · Sep 13, 2017 at 10:22 PM
You can use SpatialBlend (2D => 3D) this way, closer - mean more 2D, far - more 3D.
This gives you effect '2D AudioSource affect by min and max Distance'
using UnityEngine;
public class spatialFader : MonoBehaviour
{
private Transform Listener;
private AudioSource source;
private float sqrMinDist;
private float sqrMaxDist;
void Start()
{
Listener = FindObjectOfType<AudioListener>();
source = GetComponent<AudioSource>();
if (!source) return;
sqrMinDist = source.minDistance * source.minDistance;
sqrMaxDist = source.maxDistance * source.maxDistance;
}
void Update()
{
if (!source || Listener) return;
var t = (transform.position - Listener.position);
t = (t*t - sqrMinDist) / (sqrMaxDist - sqrMinDist);
source.spatialBlend = Mathf.Lerp(10f,22000f,t);
}
}
Your answer
Follow this Question
Related Questions
WebGL audiosource max distance not working 1 Answer
webgl volume just doesnt work 0 Answers
Hearing audio outside max distance 12 Answers