Audio Controller for Sound Effects


I picked up two sound effect libraries recently and decided to try to implement those in-game. I have minimal experience with sound effects. In the past, I've used a single controller for the couple of sound effects needed in a prototype or jam game.  This wouldn't scale for this game even in its current state. I added a class to utils for playing random clips and extended this base component where I needed it.

For actions most actions this was pretty easy. The most challenging part was footsteps. I used animation events on the various walking and running animations to implement footsteps. This wasn't difficult to get working, however, when blending between walking and running (or forward/backward movement and strafing) the audio clips would play for each active animation. This meant I could have up to four animations emitting animation events.

To solve this I added some new getter functions that could identify whether the player was walking or running and whether the player was strafing. When an animation event fires I check whether the movement that caused the animation event is the strongest type of movement (is the player running more than they're walking? Or, is the player strafing more than they're moving forward/backward?).

The next thing I need to sort out with sound effects (and audio in general) is a generalized way to apply audio settings. For example, if the player puts SFX volume at 50%, I need to ensure that audio sources used for SFX honor that volume setting. This is something I will return to later, at the moment I'm happy with the audio implementation and I would like to get back to building out the debug level and features needed for the tutorial level.

Files

vaults-and-vampires-webgl.zip Play in browser
Version 2024-02-17-63b9236 Feb 17, 2024

Leave a comment

Log in with itch.io to leave a comment.