RealDocs

UGameplayStatics::SpawnSoundAtLocation

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

Description

Spawns a spatialized audio component at a fixed world location and begins playback immediately. The sound does not follow any actor — use SpawnSoundAttached for that.

Caveats & Gotchas

  • Replication is not handled by this function; call it on both server and client yourself, or use a replicated trigger and call it on every machine.
  • Passing nullptr for AttenuationSettings causes the sound to use its asset-defined attenuation, which may mean it is audible from anywhere if the asset has no falloff configured.
  • Returns nullptr if the sound fails concurrency checks or the audio engine is in a disabled state; always null-check before calling methods on the returned component.

Signature

static ENGINE_API UAudioComponent* SpawnSoundAtLocation(const UObject* WorldContextObject, USoundBase* Sound, FVector Location, FRotator Rotation = FRotator::ZeroRotator, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f, class USoundAttenuation* AttenuationSettings = nullptr, USoundConcurrency* ConcurrencySettings = nullptr, bool bAutoDestroy = true)

Parameters

Name Type Description Default
WorldContextObject const UObject* Object used to obtain the world context.
Sound USoundBase* The sound asset to play.
Location FVector World-space position to play the sound at.
Rotation FRotator Orientation of the sound source (relevant for directional attenuation). FRotator::ZeroRotator
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
AttenuationSettings class USoundAttenuation* Optional attenuation override asset. nullptr
ConcurrencySettings USoundConcurrency* Optional concurrency settings override. nullptr
bAutoDestroy bool Automatically destroy the audio component when the sound finishes. true

Return Type

UAudioComponent*

Example

Play explosion sound at hit location C++
void AMyProjectile::OnHit(const FHitResult& Hit)
{
	UGameplayStatics::SpawnSoundAtLocation(
		this, ExplosionSound, Hit.ImpactPoint,
		FRotator::ZeroRotator, 1.f, 1.f, 0.f, AttenuationOverride);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.