In my level design the camera is set to listener mode but when i drag it further away from the audio sources it doesn’t fade away. None of my audio sources have listener or reverb bypasses. Do i need a full completed version of this game to work properly or is something wrong. Plz help.
,I’m designing a level for my game but when I move the camera away from the music source the music doesn’t fade away. None of the audio files have listener or reverb bypass settings on but my camera is activated as a listener. WDID? (what do i do?)
Good day.
In Unity there are 2 basic elements for aduio. AudioSource and AudioSlistener. As you can imagine, one is the emmiter and the other is the receiver.
AS far as i know, as the receiver goes away from the sources, it fade out, but if you dont suceed, you can always change the audiosource.volume. Make some mathematics to get a number from 0 to 1 depending on the distance. LEts say the maxiumum distance to listen an audio is 500:
float MaxDistance = 500;
float RealDistance = Vector3.distance (AuduioSource.transform.position, AudioListener.transform.position);
float DistanceFactor = 1 - (RealDistance/MaxDistance);
if (DistanceFactor >0)
{
AudioSource.volume = DistanceFactor;
}
else
{
AudioSource.volume = 0;
}
So now, it will fade in/out relative to distance.
Bye!