Hello, I’m testing out spatial sound (Not the built in one, it’s too quiet for my liking), and I’ve encountered an issue that I don’t know how to resolve
Here, I have a draggable ear, and draggable megaphones that are playing music. The closer the ear is to the megaphone, the louder the music gets. There’s also a volume slider to adjust the global volume (A better practice would be to store the value in a global variable, but for testing, it just reads the value of the slider):
If you’re wondering, the slider only has 1 as a max value, so the final volume is multiplied by a decimal to adjust the volume
However, this only sort of works. The spatial sound only works with the FIRST instance of the megaphone (The right one in this case). Every other instance is completely ignored by the code…
How can I make the spatial sound work with EVERY instance of the megaphone, and not just the first one? Here’s the code:
Sound1 is the name of the megaphone btw. Thanks
Are you using an extension or the built-in sound volume? As is, it’s not ignoring the other sound1 locations it’s setting the volume based on each object but it’s happening almost instantaneous because it’s all in 1 event and 1 frame. It’s leaving the volume using the last object to be checked.
I was curious. If you’re just going for sound in mono then something like this might work. It sets the volume based on the closest instance. But this only works with 1 sound. You might need to use a separate channel/sound for each point and set the volumes separately.
Otherwise, you might need to use spatial, an extension or separate sounds and channels.
Something like this:
Alright, I changed the code:
Unfortunately, this doesn’t work, now the sound just plays at full volume at all times
Also, I tried the extension too, but it also only prioritizes one single instance (The left one this time)
Did I do something wrong here? Or is there a different way?
EDIT: I made a mistake with the variables, I called one of them “closest” instead of “closest sound.” That’s my bad, I’ll leave another edit later if I need anything else
EDIT 2: Alright, it does in fact work, but now it creates a new problem. The volume slider now does nothing, and the volume increases far too quickly, which is more noticeable if 200 is replaced with a larger value. Is it possible to combine the closestSound variable into the spatial sound formula I already have?
You can use the distance however you wish. In your example, you can replace the ear.distance(…) with variable(). I just used a randomish number.
Oh yeah, that actually works, thanks a lot!
Here’s the code in case this info can help anyone else (With comments to guide):