Dialogue Sequencer
Categories:
The Dialogue Sequencer is the runtime engine that executes dialogue sequences node-by-node. It receives a DialogueSequence from the Dialogue Manager, traverses the node graph, evaluates conditions, fires effects and performances, and routes text and selection events to the UI layer through the DialogueUIBridgeComponent.
The two components on this page work together:
| Component | Role |
|---|---|
| DialogueSequencerComponent | Traverses the node graph. Processes each DialogueNodeData in order, manages runtime tokens, and signals sequence completion. |
| DialogueUIBridgeComponent | Decouples the sequencer from presentation. Routes dialogue text and selection events to whichever DialogueUIComponent or DialogueUISelectionComponent is currently registered. |
For usage guides and setup examples, see The Basics: GS_Cinematics.
Contents
DialogueSequencerComponent
The sequencer is the core playback controller. When a sequence starts, the sequencer reads the startNodeId, resolves the first node, and begins processing. Each node type has its own processing logic:
- TextNodeData – Sends text, speaker, and portrait data to the UI bridge for display.
- SelectionNodeData – Sends options to the UI bridge. Waits for a player selection before continuing.
- RandomNodeData – Picks a random outgoing connection (pure random or weighted) and continues.
- EffectsNodeData – Executes all attached
DialogueEffectinstances, then continues. - PerformanceNodeData – Starts a
DialoguePerformance. Waits for the performance to signal completion before continuing.
At each node, outgoing connections are evaluated. Conditions on connections are tested in priority order; the first connection whose conditions all pass is followed. When no outgoing connections remain, the sequence ends.
Request Bus: DialogueSequencerRequestBus
Singleton bus – Single address, single handler.
| Method | Parameters | Returns | Description |
|---|---|---|---|
StartDialogueBySequence | const DialogueSequence& sequence | void | Begins playback of the given sequence from its startNodeId. |
OnPerformanceComplete | – | void | Called by a running DialoguePerformance when it finishes. The sequencer advances to the next node. |
Notification Bus: DialogueSequencerNotificationBus
Multiple handler bus – any number of components can subscribe.
| Event | Parameters | Description |
|---|---|---|
OnDialogueTextBegin | const DialogueTextPayload& payload | Fired when the sequencer begins processing a text node. Contains speaker name, text, portrait, and display settings. |
OnDialogueSequenceComplete | – | Fired when the sequencer reaches the end of a sequence (no further outgoing connections). |
Runtime Token Management
The sequencer maintains a set of runtime tokens that track state within a single sequence execution. Tokens are used internally to prevent infinite loops, track visited nodes, and manage branching state. They are cleared when a sequence completes or is interrupted.
DialogueUIBridgeComponent
The UI Bridge sits between the sequencer and the presentation layer. It holds a reference to the currently registered DialogueUIComponent and DialogueUISelectionComponent. When the sequencer needs to display text or a selection menu, it calls the bridge, which forwards the request to the active UI. This allows you to swap between screen-space, world-space, or custom UI implementations at runtime without changing the sequencer or the dialogue data.
Request Bus: DialogueUIBridgeRequestBus
Singleton bus.
| Method | Parameters | Returns | Description |
|---|---|---|---|
RunDialogue | const DialogueTextPayload& payload | void | Forwards a dialogue text event to the registered DialogueUIComponent. |
RunSelection | const DialogueSelectionPayload& payload | void | Forwards a selection event to the registered DialogueUISelectionComponent. |
RegisterDialogueUI | AZ::EntityId uiEntity | void | Registers the entity whose DialogueUIComponent and/or DialogueUISelectionComponent will receive events. |
CloseDialogue | – | void | Tells the registered UI to close and clean up. |
Notification Bus: DialogueUIBridgeNotificationBus
Multiple handler bus.
| Event | Parameters | Description |
|---|---|---|
OnDialogueComplete | – | Fired when the registered UI finishes displaying a dialogue line (after typewriter completes or the player advances). The sequencer listens for this to advance to the next node. |
OnSelectionComplete | int selectedIndex | Fired when the player selects an option. The sequencer uses the index to follow the corresponding connection. |
Execution Flow
A typical dialogue playback follows this path:
- Start –
DialogueManagerRequestBus::StartDialogueSequenceByName("MySequence")looks up the sequence in the active database and callsDialogueSequencerRequestBus::StartDialogueBySequence(sequence). - Node Processing – The sequencer reads the start node and begins processing. For each node:
- Text – The sequencer calls
DialogueUIBridgeRequestBus::RunDialogue(payload). The bridge forwards to the registered UI. The UI displays text (via TypewriterComponent), then firesOnDialogueComplete. The sequencer advances. - Selection – The sequencer calls
DialogueUIBridgeRequestBus::RunSelection(payload). The bridge forwards to the selection UI. The player picks an option, the UI firesOnSelectionComplete(index). The sequencer follows the indexed connection. - Effects – The sequencer executes each
DialogueEffecton the node, then advances immediately. - Performance – The sequencer starts the
DialoguePerformance. When the performance callsOnPerformanceComplete, the sequencer advances. - Random – The sequencer picks a connection and advances immediately.
- Text – The sequencer calls
- End – When no outgoing connections remain, the sequencer fires
OnDialogueSequenceCompleteand callsDialogueUIBridgeRequestBus::CloseDialogue().
C++ Usage
Starting a Sequence
#include <GS_Cinematics/GS_CinematicsBus.h>
// Start by name through the Dialogue Manager
GS_Cinematics::DialogueManagerRequestBus::Broadcast(
&GS_Cinematics::DialogueManagerRequestBus::Events::StartDialogueSequenceByName,
AZStd::string("PerryConfrontation")
);
Listening for Sequence Completion
#include <GS_Cinematics/GS_CinematicsBus.h>
class MyListener
: public AZ::Component
, protected GS_Cinematics::DialogueSequencerNotificationBus::Handler
{
protected:
void Activate() override
{
GS_Cinematics::DialogueSequencerNotificationBus::Handler::BusConnect();
}
void Deactivate() override
{
GS_Cinematics::DialogueSequencerNotificationBus::Handler::BusDisconnect();
}
void OnDialogueSequenceComplete() override
{
// Sequence finished — resume gameplay, unlock camera, etc.
}
};
See Also
For conceptual overviews and usage guides:
- Dialogue System Overview – Architecture and manager APIs
For component references:
- Dialogue UI – Display components and typewriter
- Performances – MoveTo, PathTo, RepositionPerformer
- Dialogue Actors – Performer markers
For related resources:
- Dialogue Data Structure – Node types, conditions, effects
Get GS_Cinematics
GS_Cinematics — Explore this gem on the product page and add it to your project.