Playing the game’s own sounds
This page uses Vector3 from Unity. The glossary says what each one is.
This is the full list of the game’s own sounds you can use: the item pickup sounds and the random sound libraries. Sounds lets you list their names and play them. A play call returns true when a sound started and false when it did not. Text in brackets at the end of a note is extra detail for experienced modders, and you can skip it on a first read.
Sounds the game's pickup and library sounds
Use PickupNames or LibraryNames to list the game’s sounds, then PlayPickup, PlayLibrary or PlayLibraryAt to play one.
public static class Sounds
{
public static List<string> PickupNames();
public static List<string> LibraryNames();
public static bool PlayPickup(string name);
public static bool PlayLibrary(string name);
public static bool PlayLibraryAt(string name, Vector3 position);
}
| Method | Returns | What it does |
|---|---|---|
PickupNames() | List<string> | The names of the item pickup sounds you can play. |
LibraryNames() | List<string> | The names of the random sound sets you can play. |
PlayPickup(name) | bool | Plays one pickup sound. Returns false when it could not start. |
PlayLibrary(name) | bool | Plays one sound from a random set, with no position. |
PlayLibraryAt(name, position) | bool | Plays one sound from a random set at a place in the world. |
Things to know
PickupNames()lists the item pickup sounds, andPlayPickup(name)plays one of them. Names includeCan,CashandKeys. The sound has no position, so the player hears it the same everywhere. (The names are thePickupSoundNamevalues, and the sound is played through the game’sItemSounds.)LibraryNames()lists the game’s random sound sets, andPlayLibrary(name)plays one random sound from a set.PlayLibraryAtplays it at a place in the world, so it gets quieter as the player walks away. (The sets are theRandomAudiofields ofRandomAudioLibrary(foley,harvest,arrestSounds,stealSounds,prankSounds,scarySounds,crazyNeighborSoundsandfoleySounds). They play throughMiscAudioPlayer.)
Limits
- A pickup name that is not on the list throws an error, so take the name from
PickupNames(). A library name that is not on the list also throws an error. - A play call returns
falsewhen the game’s sound player does not exist yet, for example on the main menu. The call does not throw for that.