UGameplayStatics::SpawnDialogue2D
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallableBlueprintCosmetic
Description
Creates and plays a 2D (non-spatialized) UAudioComponent for a UDialogueWave, returning the component for runtime control such as stopping or fading. Prefer this over PlayDialogue2D when you need to interrupt or modify playback.
Caveats & Gotchas
- • The component starts playing immediately on spawn; there is no separate Activate step unlike CreateSound2D.
- • If bAutoDestroy is false and you lose the returned reference, the component will persist in the world indefinitely — ensure you store and destroy it manually.
- • Context resolution happens at spawn time; changing the context object after spawning has no effect on the playing audio.
Signature
static ENGINE_API UAudioComponent* SpawnDialogue2D(const UObject* WorldContextObject, UDialogueWave* Dialogue, const struct FDialogueContext& Context, float VolumeMultiplier = 1.f, float PitchMultiplier = 1.f, float StartTime = 0.f, bool bAutoDestroy = true) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to obtain the world context. | — |
| Dialogue | UDialogueWave* | The dialogue wave asset to spawn. | — |
| Context | const struct FDialogueContext& | Speaker and target context used to resolve the audio variation. | — |
| 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 |
| bAutoDestroy | bool | Automatically destroy the audio component when playback ends. | true |
Return Type
UAudioComponent* Example
Spawn dialogue and stop on skip C++
FDialogueContext Ctx;
Ctx.Speaker = NPCSpeakerVoice;
Ctx.Targets.Add(PlayerVoice);
ActiveDialogueComp = UGameplayStatics::SpawnDialogue2D(this, GreetingWave, Ctx, 1.f, 1.f, 0.f, false);
// Later, on skip button press:
if (ActiveDialogueComp)
{
ActiveDialogueComp->Stop();
ActiveDialogueComp->DestroyComponent();
ActiveDialogueComp = nullptr;
} Tags
Version History
Introduced in: 4.9
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?