UGameplayStatics::PlaySound2D
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: static
Description
Plays a non-spatialized (2D) sound that is not affected by the listener's position or orientation. Intended for UI sounds, music stings, and notifications.
Signature
static ENGINE_API void PlaySound2D(const UObject* WorldContextObject, USoundBase* Sound, float VolumeMultiplier, float PitchMultiplier, float StartTime, USoundConcurrency* ConcurrencySettings, const AActor* OwningActor, bool bIsUISound) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Any valid UObject in the world. | — |
| Sound | USoundBase* | The sound asset to play. | — |
| VolumeMultiplier | float | Volume scale. Default 1.0. | 1.0f |
| PitchMultiplier | float | Pitch scale. Default 1.0. | 1.0f |
| bIsUISound | bool | If true, plays even when the game is paused. Default true. | true |
Return Type
void Caveats & Gotchas
- • bIsUISound=true (default) means this plays even when the game is paused — correct for menus and UI feedback, but wrong for gameplay sounds. Set to false for gameplay-triggered 2D sounds.
- • No 3D attenuation — the sound is the same volume regardless of where the listener is. Use PlaySoundAtLocation for world-space sounds.
- • Fire-and-forget like PlaySoundAtLocation — no handle returned. Use SpawnSound2D for stoppable 2D sounds.
Example
UI click and achievement sounds C++
// UI button click — plays while paused
UGameplayStatics::PlaySound2D(this, ButtonClickSound);
// Achievement sting — gameplay context, shouldn't play while paused
UGameplayStatics::PlaySound2D(
this, AchievementSound,
1.0f, 1.0f, 0.0f,
nullptr, nullptr,
false // bIsUISound=false
); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?