I have an open world game. I want my player to run into an area and have an audio source loop until the player leaves the area. I attached my audio source to an object in the area where I want the sound. I have it set to 3D and when the player moves close to the object the sound gets messed up and gets louder. This is the only way I can see to successfully play the audio clip while in an area. If I switch to 2D the player hears it everywhere around the map.
How can this be fixed?
There are too many variables to determine the best way of doing this. It depends on your game. Rarely do you want looping audio to just suddenly stop and play on the dime.
There are literally 100 ways of doing this. Generally it requires a script to be written to have complete control over the audio: looping, volume, spread unless you can use the below example.
In the audio source, you can create your own volume curve to control the volume based on the distance.
This plays the audio at a constant volume when the listener is close enough. The volume will fade in and out near the threshold. The audio source is always playing and looping.
If this doesn’t work, you have no choice to control this through a script.
j
Yeah this is what I want. It currently fades as the player moves into the area and fades out when the player moves away. It’s just that when the play moves close to the object and turn around quickly the sounds gets distorted.
It sounds like you have the Doppler effect enabled. Disable the Doppler effect on the audio source.
You also might have to force the audio source to mono. In the import settings you check “Force to mono”. I dont know if this is causing your issue.