Lets say you have a river in your game and you want the water sound to play when you get close to it. How can you do this, as a 3d audio originates from a point, and I need a line or something?
I guess I could use collisions to trigger the sound, but that won’t be true 3d audio, just fading the sound in and out.
You could just make multiple sound emitters along the water. If you are able to actually move into/over the water that is the only way it will properly emit in all directions since you are “in” the sound emitter.
As long as you call .play() on all of the duplicate sounds at the same time they will stay in sync and sound to the listener like a single sound source.
Won’t multiple sound emitters play the same sound multiple times? I mean isnt that too expensive?
It seems it would be simpler to just get the distance between the player and the closest drop of water, and play the sound accordingly. I bet it wouldn’t sound much worse (i didn’t try).
If you figure out the closest position you could just feed that position to the sound emitter, no need to calculate the length or manually set the volume.
As for multiple emitters, sound APIs are usually pretty well optimized. It would be pretty quick to try out and see if there is any impact on performance.