Before we begin:
This system was designed by @sidnad10. He reached out to me with this presentation:
He asked me if I could try creating it, and I quickly accepted.
For those who don’t want to read the presentation, the tl;dr:
In real life, your ears dampen the higher frequencies of sounds behind you, around 7k Hz. Headphones only simulate left and right, so we need to do a bit of extra work for real 3D sound emulation.
I spent a couple hours creating a simple-to-use module that accomplishes this effect by playing with the HighGain of an EqualizerSoundEffect.
By using the equalizer, we can automate the dampening based on direction of sound. This way, it can be differentiated, and therefore emulate what happens with real sound.
Using a touch of angular math, we determine the relative position to the Camera, and adjust the HighGain accordingly.
It may be subtle, but for games in which locating objects via sound is vital (like a tactical shooter), it can be game changing.
Usage is super simple, with just a single function.
local SoundSystem3D = require(script.SoundSystem3D) local Sound = SoundSystem3D:Create(ID, Target, Looped)
:Create() returns an Attachment with a Sound in it. (I use Attachments because they are more efficient than Parts or so I’ve read )
ID can be:
- A string of numbers
- A string of the whole Id (“rbxassetid://” included)
Target can be:
- CFrame (will create a sound that stays at that CFrame)
- Vector3 (will create a sound that stays at that Vector3)
- Instance with a Position property (will create a sound that follows the Instance)
Looped can be:
- A boolean (defaults to false)
Note: If Looped is false, it will automatically delete the Attachment once the Sound has played
Because this must be run from the client, you should use RemoteEvents to tell the client when and where to play sounds.
If you have any issues, comments, or anything at all, please reply below!
Enjoying my work? I love to create and share with the community, for free.
I make loads of free and open source scripts and modules for you all to use in your projects!
You can find a lot of them listed for you in my portfolio. Enjoy!