Audio heard outside of Max Distance

Hello!

I’m trying to figure out why audio is being heard outside of the max distance. As I play and get closer/further from the source, I see the vertical “Listener” line going closer and further away. When it’s out of the graph, I can still hear audio.

There is only one listener in the scene, and the stereo effect is active. My settings are below, and this is the code I’m using to start audio clips. Its entirely possible (likely maybe) that my code is the issue, as when I slider the volume down to 0 in the inspector, I can still hear the audio playing.

Any thoughts?

function PlayAudio(name : String){
    var id        : int     = AudioClipID(name);
    var volume    : float    = audioClips[id].volume;
    var audioClip        = audioClips[id].audioClips[Random.Range(0,audioClips[id].audioClips.Length)];
    if (audioClips[id].volumeBySpeed)
        volume            = Mathf.Clamp(volume * Mathf.Abs(animator.GetFloat("locomotion")), audioClips[id].minVolume, audioClips[id].volume);
    audioSource.PlayClipAtPoint(audioClip, transform.position);
}

Make a new Audio Source and set its sound to play to whatever you want and turn up spatial blend to max, then edit the rolloff and than it is done!

2 Likes

Try adjusting the Spatial Blend and see if it helps.

2 Likes

Thanks guys,

I fixed it, and I meant to write how here… but I can’t remember now!

It could have been the setting in the audio clips…but I don’t think that was it, maybe it needs to be a 3d sound? I thought maybe it was that “playclipatpoint” doesn’t work with the auto-volume, but I’m still using the same code, so that can’t be it.

Sorry, I forgot to write what works!!