Who Just Killed Me? Audio Implementation

I am not, nor have I ever been a sound engineer. In fact, as a child, they had my hearing tested because I had no desire to listen to music. However, it is the sorry lot of a UX programmer to do whatever no one else has time for. Hence I ended up doing the sound implementation for Scorch. 

Fortunately, I was not expected to make the sounds. I might have just hidden under my desk and refused to come out. We were extremely lucky to have a Berklee School of Music student Collin Lewis attached to the project. He did an amazing job creating SFX, music, and ambience. 

Sound plays a huge role in Scorch. Our game plays with light so what you can see is always limited. Sounds fill in the gap and help players understand the world around them. It brings the experience back from disorienting to just scary. 

A big problem we had initially was enemies sneaking up and killing players. We tried different ideas for indicators, but a simple solution proved to be the best. When we added footstep sounds to enemies and people stopped complaining that they were being killed unfairly. 

At first, I tried to add footstep sounds by playing them based on a bool in the player’s movement component. Unfortunately, this not only turned into a coupling nightmare but also resulted in sounds that were out of sync with the model’s movements. The answer was to use animation events to play the sounds. This allowed me to time the footsteps correctly with the animation without adding a bunch of ugly “magic numbers” to the code. 

3D audio for all enemy sounds was essential for helping players understand where the next guy trying to kill them was located. I used a logarithmic roll-off for most enemy sounds which mimics reality. When playing with headphones, it is easy to tell if an enemy is to the right or left and how far away he is based on where his footsteps or gunshots are coming from. 

Ambient audio was the next hurdle. In our game ambience consists of rain sounds in open areas, wave noises on the docks, and machine sounds in the factory. Though these noises aren’t always noticeable to the player on a conscious level, they add to the immersion and help players orient themselves. 

I will admit I overthought ambient audio. I was thinking about it as spatialized sound coming from multiple points but quickly realized that was over complicated. The right solution would have been to use something like FMOD but since it was too late to install it, I needed to build my own system. I ended up with the ugly solution of large trigger colliders covering areas of the map with code to fade in and out of the different clips. The sound is 2D. It works but tends to break frequently as people move things around. 

The last type of sound I’d like to talk about is UI. When you hover over a button it makes a subtle click and switches to a hover state. That lets the user know that the game is responsive and the button is active. Everything that is interactable on the screen needs to be understandable and responsive. 

All our buttons are prefabs, (thank you past self for spending a week on that!) so I was able to slap an event trigger and a sound player script on the prefab. Event triggers allow you to add more types of events than a basic button. They also retain their events from the prefab to the world space while button events sometimes break. Button sound functionality is self-contained so it has no dependencies. 

Audio levels in our game are set on an options menu and retained by a game manager. However, since I am pathologically anti-coupling, the objects that use audio do not ask for the volume. Instead, they listen for an audio-level event that is fired by the game manager when a sound changes or a new scene is loaded. The only problem with this was that objects must be active to get events. I solved this problem by having all elements initially active but transparent for a few frames so they can receive set up messages. Once set up, they can deactivate themselves. 

UX programmers rarely do anything new, innovative, or flashy. However, we do make a hundred small changes that each make the game 1% better and that adds up. No individual sound makes a huge difference to player experience, but without them, the game would be less understandable. However good the AI, without audio, the enemies just wouldn’t feel as alive and threatening.