RealDocs

UGameplayStatics::PlaySoundAtLocation

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

Description

Plays a one-shot sound at a world position with 3D attenuation. Fire-and-forget — returns no handle. Use UAudioComponent for sounds that need to be stopped or modified after playback starts.

Signature

static ENGINE_API void PlaySoundAtLocation(const UObject* WorldContextObject, USoundBase* Sound, FVector Location, FRotator Rotation, float VolumeMultiplier, float PitchMultiplier, float StartTime, USoundAttenuation* AttenuationSettings, USoundConcurrency* ConcurrencySettings, const AActor* OwningActor, const UInitialActiveSoundParams* InitialParams)

Parameters

Name Type Description Default
WorldContextObject const UObject* Any valid UObject in the world.
Sound USoundBase* The sound asset to play.
Location FVector World-space position to play the sound from.
Rotation FRotator Orientation (relevant for directional sounds). FRotator::ZeroRotator
VolumeMultiplier float Scales the sound's volume. Default 1.0. 1.0f
PitchMultiplier float Scales the sound's pitch. Default 1.0. 1.0f
StartTime float Time offset in seconds to start playback from. 0.0f
AttenuationSettings USoundAttenuation* Override attenuation settings. Null uses the sound asset's own settings. nullptr

Return Type

void

Caveats & Gotchas

  • Fire-and-forget — you cannot stop or modify the sound after calling this. If you need to pause, fade, or stop the sound, spawn a UAudioComponent with UGameplayStatics::SpawnSoundAtLocation instead.
  • Null Sound is silently ignored — no crash, but useful to check for missing asset references during development.
  • AttenuationSettings=nullptr uses the sound asset's built-in attenuation. Passing a custom USoundAttenuation overrides it entirely, not merges.

Example

Play impact and ambient sounds C++
// One-shot impact sound at hit location
void AMyProjectile::OnHit(UPrimitiveComponent*, AActor*, UPrimitiveComponent*,
	FVector NormalImpulse, const FHitResult& Hit)
{
	UGameplayStatics::PlaySoundAtLocation(
		this, ImpactSound, Hit.ImpactPoint
	);
	Destroy();
}

// With pitch randomisation for variety
float RandomPitch = FMath::RandRange(0.9f, 1.1f);
UGameplayStatics::PlaySoundAtLocation(
	this, FootstepSound, GetActorLocation(),
	FRotator::ZeroRotator, 1.0f, RandomPitch
);

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.