One of the challenges you face as a game developer is creating new and unique ways to expose the narrative to the player. One of the most overlooked ways to do this is through ambient character audio. It’s easy to remember the dialog audio, but we can actually add a lot by letting the player hear how the character experiences the world. What can you reveal about your character’s personality by adding little quips as they try to open locked doors, walking into a smelly ally, or succeed (or fail miserably) at some task? You can show a lot! You can reveal how connected the character is with the world. Are they generally positive? Hopeful? Pessimistic? Annoyed by humorless robots? Enthralled by adorable animals? Are they self-defeatist?
What’s more, though, is what can the character tell the player? Not to give up? That something is particularly interesting? That you need to get a new key-card? That cold areas are bad for your hydraulics actuators? That they’re on the right track? That they made a good decision and have learned from some failure?
A good CharacterAudioManger can drive all of those things. This is what I made for Clara in Vegas Prime Retrograde.
How Our CharacterAudioManager Works
Let’s step through the Vegas Prime Retrograde CharacterAudioManager.cs code and talk about what it’s doing!
We’re defining the basic audio types that we anticpate needing. We also define the struct that matches audio types to audioclip objects so that we actually have something to play back. Also, as a good citizen of the game industry, we added a text field that we can use for closed-captioning. We have an empty object that we can fill with default settings so that we always have something available.
The meat of this feature is the CharacterAudioItem array. We wanted to make sure and have multiple different audio clips for each key. Our main character Clara won’t say the exact same thing every time.
And finally, we initialize it.
We need some utility functions to help us out. We want the ability to get a single audio item, but we first need to pull a List of items based on the same key. For example, if we want to play a “door locked” audio when the player tries to open a locked door, we pull all of the possible things Clara can say out loud to the player and then pick a random one. She might say “Nope. Locked.” or maybe “Hmmm… it’s locked.” By using these tools, we can make that really easy.
We also needed a utility function to know if a specific audio item is playable, especially if it isn’t “interruptable.” If it’s dialog we don’t want interrupted, and it is currently playing, then we don’t want to trigger it. Let it just play out. If it is currently interruptable, then go for it. Play it.
This is the actual entry point for most uses, playing an item from a key. You know you want to use the “door locked” key, so you use this function to request the CharacterAudioManager playback for that key. It does its best to oblige.
Using The CharacterAudioManager
To make use of this manager, you can simply call the PlayItemFromKey() function. An example of this are our areas of interest. When Clara walks into certain areas, we trigger specific audio. Clara will tell the player what she is experiencing and feeling at that moment, adding depth and context. In the case of our Stasis Bay, which is a cryogenic facility, clara shudders and mentions how cold it is when she walks enters it for the first time. This adds to the ambience and gives context to the visual storytelling as her breath fogs up. Here’s the code for using the CharacterAudioManager with location triggers. it shows just how simple it is to pull this kind of storytelling together.
Where To Go From Here
I think you could get a lot of mileage out of adding playback-related UnityActions. Maybe something to send closed-captioning to the UI in a more elegant way? I’m curious how you would extend it! Feel free to download this and make it your own.