Audio Collections — Common Use Cases
Practical examples for playing, varying, and managing grouped sounds.
Overview
AudioCollection works best when you have multiple related clips organized together — footstep sets, UI packs, ambient libraries, or voice banks. You address sounds by name or let the collection pick one at random.
Sound names must match exactly what appears in the Audio Manager window. For method signatures and parameter details, see the API Reference.
Footstep Variants
Store all footstep clips in one collection and play a named entry with random pitch on each step. This keeps surface variants organized in the Audio Manager while the gameplay code stays a single line.
Example
If you need a dedicated reference to one footstep clip instead of passing a name each time, use SoundFromGroup — see the Sound from Group common use cases.
UI Sound Pack
Group every menu sound — confirm, cancel, error, hover — into one collection. Call Play with the sound name that matches the action. Override volume or pitch for individual events when needed.
Example
Ambient Variety
Forest birds, cave drips, city traffic — ambient one-shots feel more natural when they are not always the same clip. PlayRandomAudiopicks any entry from the collection using each clip's default settings, so you get variety without choosing a name in code.
Example
Character Voice Lines
Keep all lines for a character in one collection and trigger them by name from dialogue or quest scripts. Each line stays editable in the Audio Manager without touching gameplay code.
Example
Stopping a Specific Sound
Collections can have multiple sounds playing at once. When switching music states, stop only the track that is currently active — other sounds in the same collection keep playing.
Example