I was playing around with the new updated sound effect behavior and after taking a rough version from my current project, I created an example using the SoundEffect+, which is a bundle that acts like the sound effect behavior, but includes directional audio compared to the players location.
Audio automatically adjusts based on the distance between the player and the sound source. Pan will adjust left and right audio based on the players location compared to the sounds source.
Pressing “1” on the keyboard will pop up a statistics display which shows the distance between the player and the sound source, the current volume, volume set, etc.
Inputs
Play: Input trigger to play the audio selected.
Pause: Will pause the audio selected.
Stop: Stops the audio.
Volume+: Sets a maximum volume the sound will hit. Great if you need background or quieter noises.
Radius: Sets a distance around the sound source where the audio can be heard. The farthest point will start at 0 volume and increase towards the source.
Pan+: Sets a distance where the pan will start to take effect. The pan will adjust the audio from left to right speaker depending on the location of the player to the source. When in this proximity, the pan will start to adjust.
This bundle does require two global behaviors that checks the player’s X and Y location. I would have used extraction behaviors within the bundle, but they don’t work too well if used on different levels unless a new object is made or a second set of extraction behaviors are added, but I feel this adds less functions that needs to be changed within the bundle when imported into your game.
If you go into the example editor, you can copy and import the code into your own game.
It won’t count as pasting it, but copying the code automatically saves the text so when you open up the import tab by clicking into a blank editor, you can just paste it in.
I’ve been a part of flowlab for about 6 years or so. After making games and practicing a lot, you start to get better at making games. I won’t say my stuff is the best, since there are others who have spent more hours improving their knowledge than I have and made much better games. Basically, comes from a lot of practice and dedication. I won’t say it’ll take 6 years to reach that, since I’ve seen a lot of progress in just less than a year.
Good example with pan and distance, I should look into what would help to have omni-directional sound so it would be possible to hear up and down differences (front and back).
I just have the volume slowly fade the farther you are. Not as good with the pan since that only effects the X axis, it seems to be the only thing I can think of for the Y axis.
I did some studying, getting spacial audio is very difficult without pitch/bass control with stereo speakers. And even then, many examples doesn’t really get front and back audio all that well.
I have made some minor corrections for the Pan input. So that way it will automatically be set to a distance of 200 pixels from the sound source. The example was fine, but I wanted to make the bundle work on its own using the default values without having to need any inputs. I tried using this on another project and it was setting the pan to either infinity or -infinity and that wasn’t working too well, but it should be corrected now.