Playing a sound#
Use a Play Instruction to choose an audio resource, configure playback, and place the sound in the scene. All five Play Instructions share these fields, with different defaults for each channel.
Starting#
| Field | Controls |
|---|---|
| Audio | The Audio Resource to play. |
| Loop | None plays once, Loop plays until stopped. |
| Transition | Seconds to fade in. 0 starts at full volume. |
Audio is a Signal, so it can resolve a direct clip, variable, Random Audio Resource, or component value. A footstep Event can therefore select from six clips without branching.
Because the field takes an Audio Resource rather than an Audio Clip, Unity's own Audio Random Container works here too, with its weighting and pitch randomization intact.
Audio settings#
| Field | Controls |
|---|---|
| Time | Which clock this sound follows — Game Time, Real Time or From Source. |
| Priority | Which sounds Unity virtualizes when it reaches its voice limit. 0 is the most important, 256 the least, 128 the default. |
| Volume | This sound's own level, before the channel and Master are applied. |
| Pitch | Playback speed and pitch together. 1 uses the recording's original speed and pitch. |
| Stereo Pan | -1 full left, 0 center, 1 full right. Only meaningful on a 2D sound. |
| Spatial Blend | 0 is 2D and unaffected by the listener's position. 1 is 3D and positioned in the world. |
| Reverb Zone Mix | How much of the sound is sent to any Reverb Zones it passes through. |
How Time affects playback#
Time affects both the fade and the sound's pitch. The Audio Manager multiplies pitch by the selected clock's time scale, so this field also controls the sound's response to slow motion.
| Clock | During slow motion | During a pause |
|---|---|---|
| Game Time | Drops in pitch with the game clock. | Becomes silent at a time scale of 0. |
| Real Time | Unaffected. | Keeps playing. |
Sound effects and voice default to Game Time, while music and UI default to Real Time. A gunshot then stretches during bullet time, while the score and pause-menu sounds continue normally.
From Source follows the selected game object's clock. A sound belonging to an enemy in a stasis field then slows with that enemy rather than with the game. See Time & tweens.
A paused game silences its Game Time audio
A time scale of 0 multiplies the pitch by 0, which produces silence rather than a pause. The sound continues running and holding its source, then resumes mid-clip when time starts again. Anything that must be heard while the game is frozen belongs on Real Time.
Stereo settings#
Unity applies these fields when Spatial Blend is above 0. They don't affect a 2D sound.
| Field | Controls |
|---|---|
| Volume Rolloff | Logarithmic falls off the way sound does in air. Linear falls off evenly and reaches exactly zero at the max distance. |
| Min Distance | Inside this radius the sound is at full volume. Default 1. |
| Max Distance | Beyond this the sound stops getting quieter — with Logarithmic it stays faint rather than silent. Default 500. |
| Doppler Level | How much a moving source shifts pitch. Default 0. |
| Spread | How wide the source is across the speakers. 0 is a point. |
Use Min Distance to set the radius within which the sound stays at full volume. Increasing it from 1 to 15 extends that area without increasing the volume near the source. Raising Volume instead also makes the sound louder up close.
Logarithmic rolloff never reaches zero
Under Logarithmic rolloff, a distant sound remains quiet rather than silent, and each quiet sound still uses a voice. Use Linear when a sound should reach silence at its maximum distance.
Location#
Location controls where the sound is emitted:
| Mode | Plays at |
|---|---|
| None | The Audio Manager's own position, which is the world origin. Use for 2D sounds. |
| Target | The Has Target game object, followed every frame. |
| Position | A fixed point in the world, taken once when the sound starts. |
| Transform | A game object's transform, followed every frame. |
Position and Transform are the difference between a sound that plays where something happened and a sound that travels with it. An impact stays where it landed; an engine follows the car.
By default, Ambient and Voice start on Target, Sound Effect on Position, and the two 2D channels on None.
Sound effects start at the world origin by default
Play Sound Effect starts as a 3D sound with Location set to Position and that position left at (0, 0, 0). Until you set a position, it emits from the world origin, so the listener may be too far away to hear it.
Set the position, or change Location to Transform and select an object to follow. Check this field when a sound is playing but you can't hear it.
Has Target#
Has Target associates the sound with a game object without parenting the Audio Source. Stop Audio on Game Object and Is Playing on Game Object can then find the sound, and Location can follow the target.
This lets an Event stop a character's voice without tracking the resource used by the current line.
A destroyed target doesn't stop its sound
The sound isn't attached to the object, so destroying the object leaves the sound playing. With Location set to Target, the transform it followed is gone. The 3D sound relocates to the world origin and continues from there.
A looping ambient sound can therefore continue at (0, 0, 0). Stop the sound before you destroy its target: Stop Audio on Game Object with a short fade, then destroy.
Where to go next#
- Stopping a sound — select and fade sounds that are already playing.
- Channels — see how channel and Master volumes affect final loudness.
- Time & tweens — understand the clocks selected by Time.
- Signals — configure the Signal fields used by Play Instructions.