Skip to content

Audio System

Jack Burkhardt edited this page Aug 25, 2022 · 1 revision

We've added a way to play audio clips on demand for certain audio effects, etc as well as background audio.

All audio clips should be placed in the Resources/Audio/Clips folder. The name of the file will be how it is referred to in code (i.e. exit.mp3 will be referred to as exit). Clips in the same category should have the category name prefixed to the file name followed by an underscore (i.e. keyboard_key-in3.mp3 is in the category keyboard).

The background music should be placed in the Resources/Audio/Background folder. The name of the file will be how it is referred to in code (i.e. "background.mp3" will be referred to as "background").

Playing clips in code

You can play a specific clip by calling AudioManager.PlayClip or AudioManager.PlayBackgroundClip with the clip name. You can play a random clip in a category by calling AudioManager.PlayRandom with the category name. Feel free to add additional functionality to this as needed.

The PlayRandom functionality is there for certain mechanics like the keyboard where it makes sense that each key press plays a slightly different sound within a category of keyboard click sounds. If every key press played the same sound it would seem very unnatural.

Playing clips in Yarn scripts

Check out the <<play_clip>>, <<play_random_clip>>, and <<play_background_clip>> Yarn commands.

Clone this wiki locally