Dialogue Runner
The Dialogue Runner (Yarn Dialogue Runner) is the component that runs your dialogue. You give it a Yarn Project, and it steps through your Yarn Scripts one line at a time. It hands each line and set of options to your Dialogue Presenters, calls your Commands, and keeps track of your variables.
The Dialogue Runner doesn’t show anything on screen. The Presenters do that.
Adding a Dialogue Runner
The Dialogue Runner is a component, so it goes on an Actor. You can add it to an Actor in your Level, or to an Actor Blueprint.
- Select the Actor, click Add in the Components panel, and search for Yarn Dialogue Runner.
- Select the new
YarnDialogueRunnercomponent. In the Details panel, under Yarn Spinner, set Yarn Project to the Yarn Project asset you imported from your.yarnproject. - If you want the dialogue to start on its own, turn on Auto Start, under Behaviour, and type the name of the node to start from in Start Node. It defaults to
Start, and you can only edit it while Auto Start is on.

Most games need one Dialogue Runner. It runs one conversation at a time, so if you need two conversations running at once, such as background chatter while the player talks to someone, use a second Dialogue Runner.
Adding Presenters
The Dialogue Runner can’t show anything until it has Presenters. Most games start with two: a Line Presenter for lines, and an Options Presenter for options. Add them, and a Line Advancer, to the same Actor as the Dialogue Runner:
The Dialogue Runner only talks to Presenters in its Dialogue Presenters list. It doesn’t look through its Actor’s components for them, so a Presenter that isn’t in the list is never used.
To add a Presenter to the list, select the YarnDialogueRunner component, and click + next to Dialogue Presenters, under Yarn Spinner in the Details panel. Each entry picks a component: choose the Actor it’s on, then the component. The Presenters can be on the Dialogue Runner’s own Actor or on any other Actor in the Level.

The Dialogue Runner reads this list when the game starts, during its own Begin Play.
From C++, add the Presenters to the Dialogue Runner’s DialoguePresenters array before the Dialogue Runner’s Begin Play, or call SetDialogueRunner() on each one you add later:
DialogueRunner->DialoguePresenters.Add(LinePresenter);
DialogueRunner->DialoguePresenters.Add(OptionsPresenter);
DialogueRunner->DialoguePresenters.Add(LineAdvancer);Line Presenter and Options Presenter explain how to connect each Presenter to your widgets, change how text appears, and style the option buttons.
The Dialogue Runner’s settings
The Dialogue Runner’s settings are under Yarn Spinner in the Details panel.
| Setting | What it does |
|---|---|
| Yarn Project | The Yarn Project asset to run. |
| Variable Storage | Where your Yarn variables are kept. Leave it empty and the Dialogue Runner adds a Yarn In Memory Variable Storage when the game starts. See Variables and Storage. |
| Dialogue Presenters | The Dialogue Presenters that show your dialogue. |
| Line Provider | Looks up the text for each line, including translations. Leave it empty and the Dialogue Runner makes a Yarn Builtin Line Provider when the game starts. See Line and Asset Providers. |
| Asset Provider | Finds the assets that go with each line, such as voice-over clips. Leave it empty to use the default. See Line and Asset Providers. |
| Command Handler Objects | Under Commands. Objects with functions that run your Commands. See Commands. |
| Auto Start | Under Behaviour. Starts dialogue from Start Node as soon as the game starts. Off by default. |
| Start Node | Under Behaviour. The node that Auto Start and Start Dialogue from Start start from. Defaults to Start. |
| Run Selected Option as Line | Under Behaviour. See Options. |
| Allow Option Fallthrough | Under Behaviour. See Options. |
| Continue on Unhandled Command | Under Behaviour. Whether the dialogue carries on after a Command that nothing handled. On by default. See Events. |
| Saliency Strategy | Under Behaviour. How the Dialogue Runner chooses between the nodes in a node group, and the lines in a line group. Defaults to Random Best Least Recently Viewed. See Saliency and Storylets. |
| Verbose Logging | Under Debug. Prints details of what the Dialogue Runner is doing to the Output Log, every time it enters a node and more, for tracking down problems. Off by default. |
The Events are described below.
Starting and stopping dialogue
Turn on Auto Start and the dialogue starts on its own when the game starts, from the node set in Start Node.
Otherwise, start it yourself, for example when the player talks to a character.
In Blueprints:
- Open the Blueprint of the Actor with the Dialogue Runner, and drag the
YarnDialogueRunnercomponent from the Components panel into the Event Graph. - Drag off its pin and add a Start Dialogue node.
- Type the name of the node to start from in Node Name, such as
Lighthouse. - Connect the node’s exec pin to whatever starts the conversation, such as an input event.
In C++, the Dialogue Runner is a component on your Actor:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Rosa.generated.h"
class UYarnDialogueRunner;
UCLASS()
class ARosa : public AActor
{
GENERATED_BODY()
public:
ARosa();
UFUNCTION(BlueprintCallable)
void TalkToRosa();
protected:
virtual void BeginPlay() override;
UFUNCTION()
void HandleDialogueStart();
UFUNCTION()
void HandleDialogueComplete();
UPROPERTY(VisibleAnywhere)
TObjectPtr<UYarnDialogueRunner> DialogueRunner;
};Rosa.generated.h for you when you build. Unreal Header Tool reads the macros in this file, such as UCLASS() and UFUNCTION(), and generates the code that lets the editor and Blueprints see the class. The file goes in your project’s Intermediate folder, so don’t edit it or add it to source control. Its name must match the header’s name, and it must be the last #include.UCLASS() and GENERATED_BODY() make ARosa a class Unreal knows about. When you build, GENERATED_BODY() is replaced with the code from Rosa.generated.h.BlueprintCallable lets you call TalkToRosa from a Blueprint too.AddDynamic() must be marked UFUNCTION().UPROPERTY() lets Unreal track the component, and VisibleAnywhere shows it in the Details panel.#include "Rosa.h"
#include "YarnDialogueRunner.h"
ARosa::ARosa()
{
DialogueRunner = CreateDefaultSubobject<UYarnDialogueRunner>(TEXT("YarnDialogueRunner"));
}
void ARosa::TalkToRosa()
{
DialogueRunner->StartDialogue(TEXT("Lighthouse"));
}StartDialogue() with the name of the node to start from, for example when the player walks up to Rosa and presses a button."YarnSpinner" to the PublicDependencyModuleNames in your game module’s .Build.cs file.These are the Dialogue Runner’s Blueprint nodes for starting and stopping dialogue. In C++, they’re StartDialogue(), StartDialogueFromStart(), StartDialogueFromReference(), StopDialogue() and IsDialogueRunning().
- Start Dialogue starts from the node you name in Node Name. If there’s no node with that name, it logs an error and doesn’t start.
- Start Dialogue from Start starts from Start Node, whether or not Auto Start is on.
- Start Dialogue from Reference takes a Yarn Node Reference, which you set in the Details panel by choosing a Yarn Project and then picking one of its nodes from a dropdown. If the node is in a different Yarn Project from the one the Dialogue Runner has, the Dialogue Runner switches to that project first.
- Stop Dialogue ends the dialogue immediately. The Presenters are told the dialogue is over, and On Dialogue Complete is called.
- Is Dialogue Running is true while dialogue is running. Use it to stop the player walking off mid-conversation.
Events
The Dialogue Runner calls these events as the dialogue runs. In the Blueprint editor, select the YarnDialogueRunner component and click + next to an event in the Events section of the Details panel to add it to your Event Graph. In C++, bind to them with AddDynamic().
| Event | When it’s called |
|---|---|
| On Dialogue Start | Dialogue has started. |
| On Dialogue Complete | Dialogue has ended, either at the end of the dialogue, at a <<stop>> Command, or because Stop Dialogue was called. |
| On Node Start | The Dialogue Runner has entered a node. Passes the node’s name. |
| On Node Complete | The Dialogue Runner has left a node. Passes the node’s name. |
| On Unhandled Command | A Command didn’t match anything you’ve registered. Passes the Command’s text. See Commands. |

For example, to stop the player moving while they’re in a conversation, connect On Dialogue Start to a Set Ignore Move Input node with New Move Input turned on, and On Dialogue Complete to one with it turned off. Both nodes target the Player Controller, from Get Player Controller.
In C++:
void ARosa::BeginPlay()
{
Super::BeginPlay();
DialogueRunner->OnDialogueStart.AddDynamic(this, &ARosa::HandleDialogueStart);
DialogueRunner->OnDialogueComplete.AddDynamic(this, &ARosa::HandleDialogueComplete);
}
void ARosa::HandleDialogueStart()
{
if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController())
{
PlayerController->SetIgnoreMoveInput(true);
}
}
void ARosa::HandleDialogueComplete()
{
if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController())
{
PlayerController->SetIgnoreMoveInput(false);
}
}This needs #include "GameFramework/PlayerController.h" at the top of Rosa.cpp.
When a Command doesn’t match anything you’ve registered, the Dialogue Runner logs an error and calls On Unhandled Command. With Continue on Unhandled Command on, which is the default, the dialogue then carries on. Turn it off to make the dialogue wait until you call Continue on the Dialogue Runner, for example once your own code has handled the Command.
How it works with Presenters
When the Dialogue Runner reaches a line, it gives the line to every Presenter in its list at the same time. It waits until all of them have finished with it, then moves on. A Line Presenter and a Voice Over Presenter can work on the same line, and the Dialogue Runner continues only once the text has been dismissed and the clip has finished.
When it reaches a set of options, it gives them to every Presenter in the same way, and uses the first option any of them picks.
The Line Advancer tells the Dialogue Runner to move on when the player presses a key. If you’re building your own controls, call these on the Dialogue Runner yourself:
- Request Hurry Up asks the current line to finish appearing at once, such as by skipping the typing effect. The line stays on screen.
- Request Next Line asks the Presenters to finish with the current line and move on.
- Request Hurry Up Option asks the options to finish appearing at once.
Options
These settings, under Behaviour, change how options work.
| Setting | Default | What it does |
|---|---|---|
| Run Selected Option as Line | Off | After the player picks an option, show its text as a line of dialogue before continuing. Every Presenter in the list gets it, as it would any other line. |
| Allow Option Fallthrough | On | If none of your Presenters can show options, carry on with the dialogue after the options, as if none had been picked. |
Changing the Yarn Project while the game runs
To make a Dialogue Runner use a different Yarn Project while the game runs, such as when the player moves to a new Level, call Set Yarn Project on it with the new Yarn Project asset. In C++, call SetYarnProject().
If dialogue is running, it stops first. Your variables are kept, and variables you haven’t set yet take their starting values from the new project. Call Start Dialogue afterwards to run a node from the new project.
Saving and loading
Yarn Spinner can save your Yarn variables to a save game slot, using Unreal’s save game system, and load them back. In Blueprints, use Save Variables to Slot and Load Variables from Slot, under Yarn Spinner > Persistence. Each takes the Dialogue Runner, a Slot Name, which defaults to YarnVariables, and a User Index, which defaults to 0.
In C++, they’re static functions on UYarnBlueprintLibrary:
#include "YarnBlueprintLibrary.h"
UYarnBlueprintLibrary::SaveVariablesToSlot(DialogueRunner, TEXT("YarnVariables"), 0);
UYarnBlueprintLibrary::LoadVariablesFromSlot(DialogueRunner, TEXT("YarnVariables"), 0);Both return true if they worked. Loading replaces every variable in the Dialogue Runner’s Variable Storage with the saved ones. Use a different slot name for each save slot, such as YarnSave_Slot1 and YarnSave_Slot2. Does Variable Slot Exist tells you whether a slot has been saved, and Delete Variable Slot deletes one.
See Variables and Storage for other ways to save your variables along with the rest of your game.