- Home /
Using Distance from AudioSource
Hello, I'm having a problem with the audio in my project, basically it consumes too much of the CPU even only one AudioSource should be playing. I set the min and max distances for all the sources and they are fading correctly when approaching or moving away, the problem is that even only one of the sources is between the range where they should play, all of them are active (I can't hear them because they are faded out by distance but they are consuming resources anyway). In the profiler I see that every AudioSource has a Distance parameter that indicates how far is from the AudioListener, but I can't find how to access/use it. Is there an automatic way of disabling/stopping AudioSources when far away from the Listener? I know that I can create an offset with a Vector2, but if the source is already getting this distance it makes no sense adding an update to every single AudioSource in order to calculate again how far it is from the listener, right? All help will be appreciated, thanks!
![alt text][2]