Branching dialogue in games: how to build a dialogue tree

A dialogue gets more interesting when the player can choose what to ask and where to go next. Build a branching tree in IMS Creators step by step.

How to build a branching dialogue tree: lines, choices, and loops

This tutorial is a part of the Getting started series — Day 2, Week 1, Month 3.

Why do dialogues need forks?

A linear dialogue plays out like a monologue: the player flips through lines and never steers the conversation. A live exchange asks back, offers choices, and circles through topics until the player decides to end it. You already have the raw material in your scenario; today you move it onto the IMS Creators graph.

In the previous article we put the conversation on the graph and ran it: two lines, one fork, and one play button. That is enough to test the idea, but a full dialogue works harder. The guard can not only answer a question but ask one back, offer three topics, and let the player return to them until they pick "Goodbye".

Start with the Speech node and its fields. Then build those nodes into a tree with loops: loops are what turn a flat sequence of lines into a real conversation.

What is inside a Speech node in IMS Creators?

A Speech node handles one beat of the conversation: a character says one line, and the script decides where to go next. Three fields do the main work: Character for who speaks, Enter speech for the text the player reads or hears, and an optional cover image for the scene. Everything else lives in Speech parameters.

Three fields to know:

  • Character — who says the line;
  • Enter speech — the text the player reads or hears;
  • cover image — an optional picture that accompanies the line visually.

You can tune the rest later in Speech parameters.

To add a node, right-click the graph field, open the node menu, and pick "Speech".

One node is one line or one message. Several nodes form a dialogue: move them, reorder them, and connect them in different ways without rewriting the whole script.

Who says it: the Character field

By default the Character field uses the Text data type. You type the speaker's name by hand, say Dmitri or Chloe, and the editor treats it as a plain string: it has no idea whether that character exists in the project.

To tie your lines to real project characters, change the property type. Open Speech parameters → Speech properties, find the Character property, and set its type to Asset. A base-type selector appears: pick the Character base object, or any other element type you want this field to accept.

Now you choose the speaker from a list of matching elements instead of typing a name. Every line stays tied to the characters you structured in Month 1, so a typo can no longer invent a new character in the middle of a dialogue.

Leave the field empty and the line becomes narration: text with no speaker at all. Use it to describe a location or drop a stage direction between two lines. That is not a mistake, as long as you mean to give the player that information.

The Character property after its type is switched to Asset — the field offers project characters to pick from instead of typed text

What the character says: the speech text

The Enter speech field stores the text itself: the words this character says in the node. For example, the first line of our example ("What do we take: the medkit, the dumbbell, or the fire extinguisher?") is written right here.

The text lives in one place. The team reads it in the element, the scene uses it at playback, and any tool that works with the project gets the same version. You do not maintain a separate "final" copy somewhere else or port changes over by hand: the script and the game have no way to drift apart.

How the scene looks: the cover image

The Attach cover image button puts a picture on the node: a speaker portrait, a shot of the location, or an image that sets the scene's mood.

The cover renders next to the line in the editor, so the script author sees the visual context of the moment, not only the text. When the image is no longer needed, press Delete cover and confirm.

A Speech node filled in: a character as the speaker, the line typed in, and a cover image attached

Speech parameters: add your own fields

Not every detail about a dialogue belongs inside the spoken text. Extra data goes into Speech parameters.

Open any Speech node and click the gear in its header; its tooltip reads "Settings". The window that opens has two sections:

  • Speech properties: fields available in every Speech node, describing the line itself;
  • Response options properties: fields that appear on every response option, storing data tied to that answer.

To create a new field, press Add, give it a name, and pick a Data type (Boolean, Integer, Float, Text, String, Asset, and more). Set a Default value if you need one. The new property shows up in every existing and future node.

Plain short values want the String type. Use Text where formatting matters, for example on the speech line itself.

You can edit created properties: rename them, Duplicate them, or Delete them. Before deletion the editor asks for confirmation: "Are you sure want to delete variable?".

Extra fields pay off whenever the data must stay out of the spoken text. For example:

Field Data type What to use it for
Mood String Mark that Dmitri says the line "nervous". The animator and the voice actor see the same note, and the dialogue text stays clean
Camera String Set the shot: "close-up" or "wide two-shot". The setting is stored next to the line it belongs to
Sound cue String Set shutter_rattle so the right sound stays tied to a specific line instead of living in a separate document
Needs VO Boolean Track lines that still need a voice recording. Work through the dialogue and flip values right in the editor
Price Integer Set the cost of a response option. The property belongs to the option, not the spoken line; at runtime the number shows next to the option text

One setting removes repetitive typing: "Automatically populate value from previous speech node". If several lines in a row use the same parameter, the next node pulls its value from the previous one.

We come back to extra fields later this month. Every Text and String property flows into the localization table automatically, so the translator works next to the original without copying anything by hand.

The Speech parameters dialog with the Speech properties section (Mood, Camera, and Needs VO) and the Response options properties section with Price

How do you connect speech lines and build a tree of choices?

Once your nodes are ready, add response options to a line. Press Add option, type the reply, and connect the option's exit to the node the conversation should jump to: the next line, another fork, or an End node. An option with no connection leads nowhere: it looks like a choice while editing but has no follow-up in play.

Our example: Dmitri's line "What do we take: the medkit, the dumbbell, or the fire extinguisher?" gets three options: "Medkit", "Dumbbell", and "Fire extinguisher". Each one leads to its own line, and one of those lines sends the conversation back to the question.

Build the tree in a few steps:

  1. In a Speech node press Add option. Each option is a separate choice the player can pick. Type its text into Enter text. Make it sound natural: this is the exact phrase the player taps.
  2. Drag a connection from the option's exit to the right node: another line, the next fork, or End.
  3. Scan the graph for options with no connection. They have no continuation, so wire every open exit to its node.
  4. Run the dialogue from Start to End and read every option out loud. If each option leads where you planned, the tree is built.

If an option is no longer needed, remove it with Delete option. The editor shows a confirmation first: "Are you sure want to delete option?". It keeps a stray click from deleting the line your writer worked on.

Even one line with three options, each leading to its own continuation, already forms a tree. The player gets several possible paths, and you can see them all on one graph.

A Speech node with three wired options leading to three follow-up lines, one connection looping back into the node itself

How do you add loops to a dialogue?

To send the player back to an earlier question, connect an option or the exit of a line to a node higher up the graph. At runtime the conversation returns to that line, which gives you a repeating menu: the player picks a topic and returns to the list of choices until they decide to end the chat.

Loops are useful for more than menus. They also merge branches: when several options lead to the same continuation, you do not copy identical nodes for each path.

A few ways to use loops and jumps:

  • A repeating menu. No new nodes needed: wire the exit of a line back to an earlier node. In our example the player picks "Dumbbell", Chloe answers "A dumbbell? Seriously? Pick again.", and the graph returns to Dmitri's question "What do we take: the medkit, the dumbbell, or the fire extinguisher?". The menu repeats until the player picks an exit: "Medkit" and "Fire extinguisher" both end at the End node.
  • Merging branches. If two different branches should reach the same line, connect both to one node. You avoid duplicating shared dialogue, and the graph stays compact.
  • Long jumps. When the target node sits far away on the canvas, use the dedicated Jump to node. We cover it in detail next week. While your jumps fit on one screen, plain connections are easier to read and follow.

It does not matter where the path goes: forward, backward, or into a shared branch. At runtime the player walks exactly the route you drew. The graph itself becomes the conversation script.

What's next: a dialogue that tracks the player's choices

You now have a branching tree, but it keeps no memory of the conversation. Every playthrough shows the same choices and walks the same routes.

Next time we add logic to the dialogue: boolean variables, the Branch node, and conditional options, so the script can react to what the player did earlier. Continue with Control your dialogue with variables.

Try it now: open IMS Creators, add three options to the first node, wire each one to its own line, and connect one of those lines back to the same node. Run the dialogue. The moment the player sees the menu again after a choice, you will see exactly how a branching conversation differs from a flat sequence of lines.

FAQ

Can I add a line without a speaker?

Yes. Leave the Character field empty and the line renders as narration, with no speaker named. Handy for environment descriptions and stage directions between lines.

Where do the characters for the Character field come from?

They should already exist in your project as elements with their own properties. The first month of the series covered creating them in Make characters reusable with structured game objects.

By default the Character field uses the Text type, so you can just type a name. To pick characters from the project, open Speech parameters → Speech properties and switch the property type to Asset. The field then lets you choose from the list.

What are loops for in a dialogue?

Loops send the player back to earlier lines. For example, you can keep a menu available until the player picks an exit, let them re-read a hint, or return the conversation to a common topic after side discussions.

Connect an option to an earlier node, and the player can return to it at runtime.

How do I check that the dialogue tree is done?

First check the structure: every exit leads to the right node, and every scripted path reaches an End.

Then run the dialogue from Start and play it out loud, trying each option. Check the loops separately: walk them at least twice to confirm the player can return to the menu and then end the conversation cleanly.

Back to blog