Change audiosource maxdistance by scripting with no effect

I play a video on my object renderer and I play its audio clip on my object audioSource.

When I change the audiosource maxDistance by scripting there is no impact.
When I change the same value on the inspector the audio behaviour is good.

Is it a bug or did I forget something ?

Have you tried to change the minDistance too?

After several tests, the problem does not occur on an audio clip from an audio file, only from a video file.

Ideas?

Yes. It’s the same for minDistance. But volume works!

Oh, you should try to get the audioClip from the video and set variables to it, if you don’t do that already.

Changing maxDistance on audiosource (from audio clip from audio file) works but changing maxDistance on audiosource (from audio clip from video file) does not work.
And only by scripting.
I don’t really understand your proposition. Audioclip does not have maxDistance field.

Yeah my mistake.
If the volume is working and the distance is working only in the editor I don’t really understand why you can’t do it by scripting.

I’m doing some tests.

I did some tests, and it seems that the values are updated, because you can see the changes on the audio source in real time.
But it doesn’t seem to be effective, until you change a bit the value in the editor.

Weird…

Nevermind, it seems working, for me at least.
I’ve put a Movie Texture on my scene, a script on it (MovieTextureTests), and an AudioSource.

using UnityEngine;
using System.Collections;

public class MovieTextureTests : MonoBehaviour {
	
	public float minDistance = 10, maxDistance = 500;
	private MovieTexture movieTexture;
	// Use this for initialization
	void Start () {
		movieTexture = renderer.material.mainTexture as MovieTexture;
		movieTexture.Play();
		audio.clip = movieTexture.audioClip;
		audio.Play();
	}
	
	// Update is called once per frame
	void Update () {
		audio.minDistance = minDistance;
		audio.maxDistance = maxDistance;
	}
}

Changing these values (minDistance and maxDistance) will affect the properties of the AudioSource in real time.

Thanks for your test and your time.
Indeed, the AudioSource values ​​are changed in real time.
But you can always hear the sound whatever the distance from the listener is.
It’s not the case when you change AudioSource values directly in the inspector.

Just after the loading, if you change minDistance or maxDistance on your MovieTextureTests component the AudioSource corresponding values change too. But there is no impact on sound.
After that, if you set an AudioSource value in the Inspector, immediatly you can hear the impact on the sound.
And after that, if you change minDistance or maxDistance on your MovieTextureTests component the AudioSource corresponding values change again and there is impact on sound.

It is as if the inspector had put the AudioSource in the correct mode!

I have the exact same behaviour in my environment, did you find a fix for this? I have other audio sources that work fine, but the one that is part of a video doesn’t work properly. It is always the same volume no matter how close or far I am from it once it has started, and no matter what I set the volume, max distance and min distance values to, whether in the inspector or in the script. But they do work correctly once I edit one of them, or anything to do with the audio file in the inspector. Also, minimising and maximising Unity starts the audio behaving correctly, as does pausing/unpausing. It also occurs in the build version and again can be fixed by minimising/maximising. I’ve tried numerous things to fix it so far with no luck. It seems like a bug, but if someone thinks I may be doing something wrong somewhere I would like to know. Otherwise maybe I can find a way to take the game out and in of focus without fulling minimising/maximising whenever the video starts… Thanks in advance!

It sounds to me like it’s being treated as a 2D sound.

I still have the same problem. Without any fix, I filed a bug to Unity team on the subject. I expect an answer.