Hello I have a fire object that has a sound attached to it that can only be heard at a certain distance. Right now I want to put two fires in the audio radius of each other, when I enter the area (2D game) that the radii overlap the sound interfere with each other and it sounds awful.
Is there a way to fix this? I don’t think I can do a isPlaying check because the sounds are always playing just heard at a certain distance. Thanks.
1 Like
Patrick, there are a couple solutions I can think of:
Don’t play the fire sound from the fire object, play it from the player object / camera. Spatializing the sound properly probably won’t be practical, but having the player look for the nearest fire object and trigger the sound accordingly could work.
As a sound designer, the other solution I go to is to just add variation. If just two iterations of this sound are enough to interfere and start making the mix sound bad, maybe you should add some variations of the sound to be played randomly. You can also randomize the pitch.
I wrote this code in this window and haven’t tested it, so there are probably minor errors:
AudioClip[ ] myclips = new AudioClip[3];
float audioPitch = 1f;
float randomPitchModifier = 0f;
void mySoundFunction()
{
randomPitchModifier = Random.Range(0.0f, 0.2f);
audio.Pitch = (audioPitch + randomPitchModifier);
audio.Clip = myclips[Random.Range(0, myclips.Length];
audio.Play();
}