Search documentation

Search documentation pages and sections

Get it

Sound from Group

Playback methods for individual sounds inside a collection, registered in the Audio Manager.

What is a Sound from Group?

A SoundFromGroup is a reference to one specific sound inside an AudioCollection. It gives you direct access to a single clip while keeping the parent group organized in the Audio Manager. If you are unsure what an AudioCollection is, see the Audio Collection page.

Use it when you know exactly which sound within a collection you need — a named footstep variant, a specific UI click inside a larger pack, or a particular voice line. Each reference controls only that one clip and does not affect other sounds in the collection.

Creating a Sound from Group

You need a SoundFromGroup reference before calling any playback method. There are two ways to get one:

Inspector assignment

Declare a field on your script and assign the sound from the Unity Inspector. See Inspector Assignment for the full walkthrough.

C#
public SoundFromGroup groupSound;

Get function

Look up the sound by collection and sound name at runtime with GetSoundFromGroup. This is useful when names come from data or the same script handles multiple entities. See Get Functions for details on all lookup methods.

C#
SoundFromGroup footsteps = AudioSystem.GetSoundFromGroup("PlayerSounds", "Footsteps");

API Reference

Once you have a reference, use the methods below to control playback.

Play

C#
groupSound.Play()

Starts playback using the default volume and pitch you set for this sound in the Audio Manager window. Restarts from the beginning if the sound is already playing.

Play (volume, pitch)

C#
groupSound.Play(float volume, float pitch)

Starts playback with explicit volume and pitch values. volume is typically between 0f (silent) and 1f (full). pitch uses 1f as the normal playback speed — lower values sound deeper and slower, higher values sound sharper and faster.

Example

C#
groupSound.Play(0.8f, 1.2f);

PlayRandomPitch

C#
groupSound.PlayRandomPitch(float minPitch, float maxPitch)

Plays the sound once with a pitch randomly chosen between minPitch and maxPitch on each call. This adds natural variation so repeated sounds — footsteps, gunfire, UI taps — feel less mechanical without needing separate clips.

Example

C#
groupSound.PlayRandomPitch(0.9f, 1.1f);

Stop

C#
groupSound.Stop()

Stops playback immediately and clears any active fade or pause. For a smooth ending, use FadeOut() instead.

FadeIn

C#
groupSound.FadeIn(float duration, float targetVolume)

Raises volume from the current level to targetVolume over duration seconds.

Example

C#
groupSound.FadeIn(1.5f, 0.8f);

FadeOut

C#
groupSound.FadeOut(float duration)

Lowers volume to silence over duration seconds, then stops playback. Unlike Stop(), the sound winds down instead of cutting off abruptly.

Example

C#
groupSound.FadeOut(0.5f);

Pause

C#
groupSound.Pause()

Holds playback at the current position. The clip stays paused until you call Resume() or Stop().

Resume

C#
groupSound.Resume()

Continues from where Pause() left off. Has no effect if the sound was not paused — use Play() to restart from the beginning.

Common Use Cases

For practical examples — named collection entries, targeted effects, and more — see the Common Use Cases page.