Audio Component controls: Play, Stop, Fade, Volume, and Sound¶
At a glance
Lives in: Blueprint API / Audio / Components - Target:
AudioComponent - Returns: these control nodes usually return no
success value; the useful reference is the Audio Component itself - Fails
by: no audible sound, stopping the wrong component, or losing the
component through Auto Destroy / owner destruction - Official docs:
Audio Components,
Spawn Sound Attached,
and Audio Engine Overview
The one-minute version¶
- An Audio Component is a live object that can play a sound and be controlled after playback starts.
- Use it when you need
Play,Stop,Fade In,Fade Out,Set Sound, orSet Volume Multiplieron a sound instance. - Fire-and-forget nodes are fine for one-shot sounds you will never stop or fade.
- If a spawn node returns an Audio Component and
Auto Destroyis true, the reference may become invalid after playback ends. Stopstops that component's current sound.Fade Outlowers volume over time and then stops it.- Audio Components do not replicate themselves as gameplay state. Replicate the state/event, then start/stop local audio where it should be heard.
What it actually does¶
An Audio Component is a Scene Component with a Sound property and playback
state:
flowchart LR
Actor[Owning actor] --> AC[Audio Component]
AC --> Sound[Sound Wave / Cue / MetaSound Source]
AC --> Mix[Audio engine]
The common controls are:
pseudocode of component behavior - not engine source
AudioComponent.Play(StartTime):
start this component's assigned Sound, seeking to StartTime if possible
AudioComponent.Stop():
stop this component's active sound
AudioComponent.FadeIn(Duration, TargetVolume, StartTime):
start playback and ramp volume toward TargetVolume
AudioComponent.FadeOut(Duration, TargetVolume):
ramp volume, then stop playback
AudioComponent.SetSound(NewSound):
assign a different SoundBase to this component
AudioComponent.SetVolumeMultiplier(NewVolume):
change this component instance's volume multiplier
The component is the handle. If you do not store the component reference, you cannot reliably stop or fade that exact sound later.
When it fails (and what failure does)¶
Common causes:
- The component reference is
Noneor already destroyed. Auto Destroy, actor destruction, and EndPlay can invalidate stored references. - No sound is assigned.
Playhas nothing useful to start. - The sound is not looping but you expect it to continue. One-shots end naturally; the component may become inactive or auto-destroy.
- You spawned fire-and-forget audio.
Play Sound at Locationdoes not give you a handle to stop later. - Auto Destroy removed your control handle. Good for temporary sounds, bad for a loop you plan to fade out later.
- Owner destruction stopped it. Many components stop when their owner is destroyed unless configured otherwise.
- Multiplayer ran the control on the wrong machine. Local audio should be started/stopped where the listener should hear it.
Most Audio Component control nodes have no failure pin. Use Is Valid, print
the component name, and check Auto Destroy / owner lifetime before blaming the
asset.
The pattern everyone actually uses¶
For looping ambience owned by an actor:
BP_FireActor components
-> AudioComponent FireLoop, Auto Activate = false
-> BeginPlay: FireLoop Fade In(1.0, Target Volume = 1.0)
-> Fire extinguished: FireLoop Fade Out(0.5, Target Volume = 0.0)
For a spawned attached loop:
Start engine loop
-> Spawn Sound Attached(EngineLoop, Mesh, SocketName,
Auto Destroy = false)
-> promote Return Value to EngineAudio
Stop engine loop
-> Is Valid EngineAudio
-> Fade Out(0.4, 0.0)
-> clear EngineAudio after stop/finished callback if you own one
For swapping a sound on the same component:
Weapon state changed
-> AudioComponent Stop
-> Set Sound(NewLoopSound)
-> Fade In(0.1, 1.0)
The C++ twin, for the curious (our own example code):
void AGeneratorActor::SetGeneratorActive(bool bActive)
{
if (!IsValid(LoopAudio))
{
return;
}
if (bActive)
{
LoopAudio->FadeIn(0.25f, 1.0f);
}
else
{
LoopAudio->FadeOut(0.5f, 0.0f);
}
}
Auto Destroy and references¶
Auto Destroy is useful for temporary spawned sounds because it cleans up the
Audio Component after playback. It is a trap for sounds you plan to control
later.
Use this split:
- one-shot impact, no later control: fire-and-forget or Auto Destroy true,
- looping machine/ambience: component placed in the actor or Auto Destroy false,
- pooled repeated sound: component pool or actor-owned components, not a new untracked component every time.
Lookalikes - which one do I want?¶
| Node / property | Changes | Use when |
|---|---|---|
| Play | Starts this component's sound | Component already exists and should start/restart. |
| Stop | Stops this component immediately | The sound should end now. |
| Fade In | Starts and ramps up volume | Loop/ambience should appear smoothly. |
| Fade Out | Ramps down then stops | Loop/ambience should leave smoothly. |
| Set Sound | Assigns a different SoundBase | One component should reuse a new sound asset. |
| Set Volume Multiplier | Changes this instance's volume multiplier | Gameplay/UI wants local loudness control. |
| Play Sound at Location | Fire-and-forget world one-shot | You do not need a component handle. |
| Spawn Sound Attached | Returns an attached component | You need a moving or controllable sound instance. |
| Sound Attenuation | Shapes distance/spatial behavior | The problem is how the sound is heard in the world. |
Rule of thumb: If you will need to stop, fade, swap, or keep a reference, make it an Audio Component.
Going deeper¶
- Play Sound 2D / Play Sound at Location / Spawn Sound Attached
- choosing the playback node.
- Sound Attenuation and spatialized audio
- making world sounds fall off and pan correctly.
- Sound Cue vs MetaSound vs Sound Wave boundary
- choosing the source asset.
- Actor, Scene, and Primitive Components
- why Audio Component is a component on an actor.
- Set Actor Hidden In Game / Set Visibility
- invisible is not stopped or destroyed.
- Official docs: UAudioComponent, Spawn Sound Attached, and Audio Engine Overview.
- Engine source (requires engine access - we do not reproduce it here):
UAudioComponent::Play,UAudioComponent::Stop,UAudioComponent::FadeIn,UAudioComponent::FadeOut,UAudioComponent::SetSound, andUAudioComponent::SetVolumeMultiplierinEngine/Source/Runtime/Engine/Private/Components/AudioComponent.cpp; declarations inEngine/Source/Runtime/Engine/Classes/Components/AudioComponent.h.