RealDocs

UGameplayStatics::CreateSound2D

function Engine Blueprint Since 4.11
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallableBlueprintCosmetic

Description

Creates a non-spatialized, non-attenuated UAudioComponent without immediately starting playback, useful when you need to configure the component before playing. Unlike SpawnSound2D, this does not call Play() automatically.

Caveats & Gotchas

  • The returned component is not playing — you must call Play() manually. Forgetting this is a common bug when migrating from SpawnSound2D.
  • Because the component has no spatialization, it ignores attenuation and position; calling SetWorldLocation on it has no audible effect.
  • bPersistAcrossLevelTransition only works when the component is attached to a persistent actor or is managed by a subsystem — fire-and-forget uses will still be garbage collected on level unload.

Signature

static ENGINE_API UAudioComponent* CreateSound2D(const UObject* WorldContextObject, USoundBase* Sound, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f, USoundConcurrency* ConcurrencySettings = nullptr, bool bPersistAcrossLevelTransition = false, bool bAutoDestroy = true)

Parameters

Name Type Description Default
WorldContextObject const UObject* Object used to obtain the world context.
Sound USoundBase* The sound asset to create the component for.
VolumeMultiplier float Linear scalar applied to the volume. 1.f
PitchMultiplier float Linear scalar applied to the pitch. 1.f
StartTime float Offset in seconds into the sound to begin playback. 0.f
ConcurrencySettings USoundConcurrency* Optional concurrency settings override. nullptr
bPersistAcrossLevelTransition bool Whether the sound continues playing when the level it was created in unloads. false
bAutoDestroy bool When true the audio component is automatically destroyed after the sound finishes. true

Return Type

UAudioComponent*

Example

Create, configure, then play C++
UAudioComponent* MusicComp = UGameplayStatics::CreateSound2D(this, MusicAsset, 1.f, 1.f, 0.f, nullptr, true);
if (MusicComp)
{
	MusicComp->SetFloatParameter(FName("Intensity"), 0.8f);
	MusicComp->Play();
}

Version History

Introduced in: 4.11

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.