How to Make a Dialogue System with Choices
A dialogue system is a small graph walker with good manners. Here is the data shape, the conditions that make choices matter, the timing values that feel right and the bugs to test for.

Key takeaways
- Write dialogue as a graph of nodes in data: lines, choices with conditions, and effects that set flags. Never hard-code conversations in game logic.
- Choices matter when they read and write state the rest of the game uses: flags, relationship values, quest steps, items.
- Respect the reader: a typewriter that finishes on the first tap, advances on the second, and never eats a tap meant for a choice.
A dialogue system with choices is a graph of conversation nodes stored as data: each node shows a line from a speaker, then either moves to the next node or offers choices, and each choice can require conditions (a flag, an item, a stat) and apply effects (set a flag, start a quest, change how a character feels about you). The game walks that graph, draws a text box, and saves where things stand. Build it that way and you can write a hundred conversations without touching code again.
A graph, not a script
A linear story can live in a script file read top to bottom, which is how the visual novel guide approaches it. Games with exploration need something slightly different: characters you talk to many times, in any order, whose lines depend on what you have done elsewhere. That calls for many small graphs, one per conversation, with entry rules that pick which graph runs.
- Line node: speaker id, text, optional portrait mood, optional voice or sound cue, and the id of the next node.
- Choice node: a prompt plus 2 to 4 options. Each option has text, an optional condition, optional effects and a target node.
- Branch node: no text, just a condition that jumps to one of two nodes. Useful for "if the player has the key, say this, otherwise that" without showing a choice.
- Effect node: sets flags, gives or takes items, starts or advances a quest, then continues. Keeping effects in their own node makes them easy to spot when debugging.
- End node: closes the box and optionally sets which conversation this character offers next time.
Each character then has an ordered list of conversations with entry conditions, checked top to bottom: "after the bridge is fixed", "quest active", "met before", "first meeting". The first match runs. This one list is what makes a village feel alive, because the blacksmith says something new after every story beat without anyone writing a special case.
Conditions and flags: where choices start to matter
Players can tell when choices are cosmetic. Two answers that lead to the same next line feel like a quiz with one correct answer. The fix is not more branches (branches multiply writing work fast) but state: a choice sets a flag or changes a number, and some later conversation, price, door or ending reads it.
- Flags: named true or false values (`toldGuardAboutThief`). Name them by what happened, never by node id, so they survive rewrites.
- Counters: relationship or reputation values, typically from -10 to 10 or 0 to 100. Change them in small steps (1 to 3 points per choice) so no single answer swings a character completely.
- Checks: an option that needs a stat or item ("[Strength 6] Lift the gate") should be shown but greyed out when unmet, so players learn what is possible. Hide options only when knowing they exist would spoil something.
A useful design pattern is branch and fold: let a choice split into two short branches of 2 to 4 lines each, then fold back into the main path, with the difference carried forward as a flag. You get a reaction to every choice for a fraction of the writing of fully separate paths.
Timing values that read well
- Typewriter speed: 30 to 50 characters per second for normal speech. Add a short pause after punctuation (about 0.15 seconds after a comma, 0.3 after a period) and it reads like speech instead of a ticker.
- Tap behavior: the first tap while text is typing completes the line instantly; the next tap advances. This is the rule players expect and the one most often broken.
- Choice lockout: ignore input for about 0.25 to 0.4 seconds after choices appear, so a player tapping through lines does not pick an answer by accident.
- Line length: keep lines to two or three rows in the text box, roughly 90 to 140 characters on a phone. Split longer speech into several lines.
- Blips: a short sound per 2 or 3 characters (pitch varied by about 5 percent per character, a different base pitch per speaker) gives voices to characters without voice acting.
- Auto mode and skip: offer auto-advance (wait roughly 1.5 seconds plus 0.03 seconds per character) and a skip for lines already seen. Track seen lines per node id.
Edge cases and the bugs they cause
- The world keeps running. An enemy walks up and hits the player during a conversation. Decide whether dialogue pauses the game (most story conversations) or runs alongside it (barks, radio chatter), and make it explicit.
- Double triggers. Pressing talk twice on the same frame opens two conversations, or the interact button that closed the box immediately reopens it. Add a short cooldown, around 0.3 seconds, after a conversation ends.
- Effects that run twice. A player reopens a conversation and gets the reward again. Effects that give items or advance quests should check a flag first, or the conversation should move on after the effect.
- Dead ends. A node points to an id that does not exist after an edit. Validate the graph on load: every target exists, every path reaches an end node, no choice list is empty after conditions are applied.
- All options hidden. Conditions remove every choice, leaving the player stuck. Always keep one unconditional option, even if it is just "Leave".
- Saving mid-conversation. Simplest rule: you cannot save inside a conversation, and flags only apply when their effect node runs. Then a save never captures half a conversation.
- Text that does not fit. Long names, inserted numbers and translated text overflow the box. Test the longest line you have on the smallest phone you support.
How dialogue connects to everything else
Dialogue is the front end for half the game's other systems. A conversation starts and completes steps of a quest system, checks and takes items from the inventory, opens a shop, or teaches a recipe. Keep these as effects with ids (`startQuest: "lost-ring"`, `takeItem: { id: "ring", count: 1 }`) so the dialogue file never needs to know how quests or items work inside.
Two smaller relatives are worth adding once conversations work. Barks are one-line remarks that play without a box when something happens (an enemy spots you, a shopkeeper as you walk past). Give each bark a cooldown of 10 to 30 seconds so they do not repeat. Overheard dialogue plays two characters talking in world space while the player keeps control, which suits horror games and exploration.
A dialogue system brief to paste
Add a dialogue system to my top-down adventure game. Store every conversation as data in one folder: nodes of type line (speaker, text, portrait mood), choice (2 to 4 options, each with optional condition, effects and target), branch (condition, two targets), effect (set flag, add or remove item, start or advance quest, change a relationship value from -10 to 10) and end. Each character has an ordered list of conversations with entry conditions; the first match runs. Text box at the bottom with portrait and name, typewriter at 40 characters per second with pauses after punctuation, first tap completes the line, next tap advances, 0.3 s input lockout when choices appear. Options that fail a stat or item check show greyed out with the requirement. Pause gameplay during conversations. Blip sounds per speaker. Validate all conversations on load and log missing targets. Add one sample conversation with the innkeeper that branches on whether the player has the cellar key and folds back together.
The text box, portrait frame and choice buttons are screens you can restyle by hand in the UI Editor. The writing itself is the slow part, so get one character fully working (three conversations, one choice that matters later) before writing the rest of the cast.
Frequently asked questions
What is the best way to store game dialogue?
As data files separate from code: a list of nodes per conversation, with ids, speaker, text, choices, conditions and effects. That keeps writing and logic apart, makes translation possible, and lets you validate every conversation automatically.
How do I make dialogue choices matter?
Have them set flags or change numbers that other parts of the game read later: a character remembers, a price changes, a door opens, an ending shifts. Short branches that fold back with a flag give most of the effect for little writing.
How fast should dialogue text type out?
Around 30 to 50 characters per second, with small pauses after punctuation. Always let the first tap finish the line instantly so fast readers are never held back.
Should the game pause during dialogue?
For story conversations, usually yes. For short remarks and background chatter, no. Decide per conversation type and make it explicit, since an enemy attacking during an unpausable text box is a common bug.

