RealDocs

UGameplayStatics::SpawnDialogueAttached

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

Description

Spawns a UAudioComponent for a UDialogueWave attached to a scene component so the dialogue source follows the component through the world. Playback starts immediately.

Caveats & Gotchas

  • bStopWhenAttachedToDestroyed defaults to false, meaning dialogue can continue as a dangling audio component after the NPC is destroyed; set it to true for NPC bark lines.
  • Dialogue context resolution is done at spawn; if the speaker or target voice actors are invalid, no audio plays and no warning is emitted in shipping builds.
  • No replication is performed — must be called on each relevant machine in a multiplayer session.

Signature

static ENGINE_API UAudioComponent* SpawnDialogueAttached(UDialogueWave* Dialogue, const FDialogueContext& Context, USceneComponent* AttachToComponent, FName AttachPointName = NAME_None, FVector Location = FVector(ForceInit), FRotator Rotation = FRotator::ZeroRotator, EAttachLocation::Type LocationType = EAttachLocation::KeepRelativeOffset, bool bStopWhenAttachedToDestroyed = false, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f, USoundAttenuation* AttenuationSettings = nullptr, bool bAutoDestroy = true)

Parameters

Name Type Description Default
Dialogue UDialogueWave* The dialogue wave asset to spawn.
Context const FDialogueContext& Speaker and target context to resolve the audio variation.
AttachToComponent USceneComponent* Component to attach the audio component to.
AttachPointName FName Optional socket or bone name to attach at. NAME_None
Location FVector Location offset relative to the attach point. FVector(ForceInit)
Rotation FRotator Rotation offset relative to the attach point. FRotator::ZeroRotator
LocationType EAttachLocation::Type Specifies whether Location is relative or world-space. EAttachLocation::KeepRelativeOffset
bStopWhenAttachedToDestroyed bool Stop playback when the parent component is destroyed. false
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 dialogue to begin playback. 0.f
AttenuationSettings USoundAttenuation* Optional attenuation override asset. nullptr
bAutoDestroy bool Automatically destroy the component when playback ends. true

Return Type

UAudioComponent*

Example

Attach enemy bark to NPC head socket C++
FDialogueContext Ctx;
Ctx.Speaker = EnemyVoice;
Ctx.Targets.Add(PlayerVoice);
UGameplayStatics::SpawnDialogueAttached(
	BarkWave, Ctx,
	GetMesh(), FName("head"),
	FVector::ZeroVector, FRotator::ZeroRotator,
	EAttachLocation::SnapToTargetIncludingScale,
	true);

Version History

Introduced in: 4.9

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.