{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Spawn Sound Attached in Unreal Engine 5 C++UE Docs

Spawn Sound Attached maps to UGameplayStatics::SpawnSoundAttached() in C++, which creates a UAudioComponent that plays a sound and follows the component it is attached to.

Blueprint node & C++ equivalent

C++
UGameplayStatics::SpawnSoundAttached(MySound, MyComponent);

What does Spawn Sound Attached do?

It plays a sound that is parented to a scene component, so the audio moves with that component as it travels through the world. This is the right choice for moving sources such as a sound that should stay locked to a weapon, vehicle, or character bone.

The C++ equivalent

Include Kismet/GameplayStatics.h and call UGameplayStatics::SpawnSoundAttached(MySound, MyComponent), where MySound is a USoundBase* and MyComponent is the USceneComponent to attach to. The function returns a UAudioComponent* you can keep to control the sound later.

The full signature accepts additional parameters such as an attach socket name, relative location and rotation, and an attachment rule, but the two-argument form covers the common case of playing a sound at the component's location.

When to use it

Use Spawn Sound Attached for spatialized audio that must follow a moving object. For a fire-and-forget sound at a fixed world position, UGameplayStatics::SpawnSoundAtLocation() is simpler since it does not need a component to attach to.

Frequently asked questions

What is the C++ equivalent of Spawn Sound Attached in UE5?+

Call UGameplayStatics::SpawnSoundAttached(MySound, MyComponent) after including Kismet/GameplayStatics.h.

What does SpawnSoundAttached return?+

It returns a UAudioComponent* representing the playing sound, which you can store to stop, fade, or adjust the audio afterward.

When should I use SpawnSoundAttached versus SpawnSoundAtLocation?+

Use SpawnSoundAttached when the audio must follow a moving component, and SpawnSoundAtLocation for a sound played once at a fixed world position.

Related Utilities nodes

View all Utilities nodes →