Skip to main content

Dialogue Controllers

Dialogue Controllers are used to play dialogue and process Dialogue Assets, keeping track of the current state of a conversation and determining where to go next.

EasyTalk provides a lot of flexibility with how you can set up your project, but in many cases, it makes the most sense to have a single Dialogue Controller for each character.

Controllers send signals to registered Dialogue Listeners (such as Dialogue Displays) to let them know what's going on in a conversation, such as when the current line of dialogue changes, or when a character change occurs, or when options are supposed to be presented to the player.

It's up to Dialogue Displays and other components to signal the controller back to let it know when to continue or when an option is chosen.

Playing Dialogue

When you want to play dialogue, you just call PlayDialogue() on a controller with the dialogue you want to play:

using EasyTalk.Controller;
...
void Start()
{
//Retrieve the dialogue controller component from the current GameObject
DialogueController controller = GetComponent<DialogueController>();

//Start dialogue playback.
controller.PlayDialogue();
}

You can also provide an entry point ID to the PlayDialogue() method if you have multiple Entry nodes in your dialogue and you want to start from a certain point:

using EasyTalk.Controller;
...
void Start()
{
//Retrieve the dialogue controller component from the current GameObject
DialogueController controller = GetComponent<DialogueController>();

//Start dialogue playback at the Entry node which has the ID of "intro"
controller.PlayDialogue("intro");
}

If you haven't assigned a Dialogue Display to the controller, it will automatically search for a Dialogue Display in the scene and use the first one found whenever you call PlayDialogue().

If you need to switch which Dialogue Asset a controller is using during gameplay, you can call the ChangeDialogue() method.

Controller Settings

Dialogue Controller Settings
SettingDescription
DialogueThe Dialogue Asset containing the dialogue or logic which the controller will use.
Playback TypeDetermines how dialogue should be played on the controller, either waiting for player input to continue to the next line of dialogue, or automatically proceeding based on a timer (or the length of audio for a line).
Dialogue Display(Optional) Tells the controller which dialogue display it should use when PlayDialogue() is called. If this isn't set, it will search for one in the scene.
Conversation Display(Optional) The conversation display to use for displaying dialogue for this controller. If left empty, the Dialogue Display will use its currently set conversation display.
Audio Source(Optional) The audio source to use when playing audio for lines of dialogue. If left empty, the Dialogue Display will attempt to use an audio source of its own instead.
Dialogue ListenersDialogue Listeners to call as events happen during dialogue playback. Controllers automatically register and unregister Dialogue Displays as needed, but you can add your own Dialogue Listeners here if you want to implement custom logic that responds to dialogue playback.

Dialogue Listeners

Dialogue Listeners can be added to this list and their relevant methods will be called as events take place during dialogue playback. By creating your own Dialogue Listener extension class you can create more complex systems which respond to dialogue events.

Controller Events

Event NameDescription
On PlayTriggered whenever dialogue playback starts.
On StopTriggered whenever dialogue playback stops.

Dialogue Events

Event NameDescription
On ContinueCalled whenever dialogue playback continues to the next line of dialogue, or in some cases, the next node.
On Display OptionsCalled whenever dialogue options are to be presented to the player.
On Option ChosenCalled whenever a dialogue option has been chosen/finalized.
On Display LineCalled whenever a line of dialogue is to be displayed.
On Dialogue EnteredCalled whenever dialogue playback begins.
On Dialogue ExitedCalled whenever dialogue playback ends.
On Exit CompletedCalled one frame after dialogue playback ends.
On StoryCalled whenever a story node is encountered during dialogue playback.
On Variable UpdatedCalled whenever a dialogue variable's value is changed.
On Character ChangedCalled whenever a character change is detected.
On Audio StartedCalled whenever audio playback starts for a line of dialogue.
On Audio CompletedCalled whenever audio playback stops or finishes for a line of dialogue.
On Activate KeyCalled whenever a line of dialogue is being processed.
On WaitCalled whenever a Wait node is encountered during dialogue playback.
On Conversation EndingCalled whenever dialogue playback reaches the last line of dialogue in a Conversation node.
On Node ChangedCalled whenever dialogue playback moves from one node to another.
On PauseCalled whenever a Pause node is encountered during dialogue playback.