Story Machine supports a flexible system for implementing branching narratives and conversations. It shares some DNA with tools like Twine, KiriKiri, Inklewriter, and TyranoBuilder, but is designed to integrate directly into a Story Machine scene, which makes it much more powerful than most text-based systems. Branching narrative systems in Story Machine are also applicable to much more than visual novels: they can be used as a general purpose logic sequencing tool, with conditional branching, action sequence triggers, and support for complex variable manipulation.
Table of Contents
In Story Machine, branching dialog is implemented in four parts:
- The Dialog Flow script, a text file that defines the conversation sequence and branches.
- The Dialog Flow component, the engine that ingests the dialog script and hooks it up to objects in the scene.
- The Control Dialog action, which tells the Dialog Flow component when to start and stop, and when a branch choice has been selected.
- An Action Library component, which defines named actions that can be triggered by the script.
Scene Setup
To integrate branching dialog into your scene, you will need at a minimum:
- A game object that contains a Dialog Flow component.
- To create one, select
Add > Empty Game Object
and thenAdd > Dialog Flow
.
- To create one, select
- A game object with an Action Library component.
- For simplicity, this can be the same object as your Dialog Flow object. Select it and choose
Add > Action Library
to add it.
- For simplicity, this can be the same object as your Dialog Flow object. Select it and choose
- A text box object in the scene that will be where the conversation dialog is displayed.
- A game object that has an Event Receiver or other action executing component (such as a Clickable) with a Control Dialog action to start the dialog.
- You could add an Event Receiver to the Dialog Flow game object, set its event type to Start, and add the Control Dialog action to its sequence with “(this object)” as the target. This will cause the dialog to automatically begin when the scene is started.
Once these elements are added to your scene, the Dialog Flow component needs to be set up. Drag the text box object into the Target Text Box field, and the object with the Action Library component into the Action Library field. Finally, you’ll need to drag your Dialog Flow script file from the project to the Dialog Text field.
Action Library Setup
Dialog Flow script files can invoke actions in your scene via the Action Library. For example, a script might include the line [Rebecca - Sad]
to indicate that the Rebecca character should look sad. When the Dialog Flow component reaches that command, it will go look in the associated Action Library for an action sequence called “Rebecca - Sad” and will execute it. That action sequence can do anything, whatever actions are appropriate to make Rebecca look sad in your scene.
Actions can be use to shake the camera, load the next scene, play sounds, or anything else. The Dialog Flow script allows you to trigger those actions at the right time in your narrative flow.
See the Dialog Flow script reference for more information on triggering actions from dialog scripts.
Choices
Branching dialog conversations often need to present choices to the player to select one branch over another. The Dialog Flow script includes a system for enumerating choices at particular points in the conversation, which will pause the flow of the dialog until one is selected. But how a “choice” is presented to the player is entirely up to you.
For example, some games might elect to show a list of buttons that specify a choice. Others might ask the player to navigate their character to a particular area of the map to make their choice. Still others might require the player to achieve a certain score before a choice can be made. How your game presents choices to the player is up to you.
The Dialog Flow component includes a list of “choice objects,” which will be turned on when choices are encountered in the dialog script. For example, if the script includes three choices, the first three items in the Choice Objects list will be enabled. It also includes a “Choice Text” list, which is a list of text boxes, one for each choice, that will be filled in with the script’s text for that choice. When a choice is encountered in the Dialog Flow script, the first available Choice Object is enabled and the first available Choice Text is set to the script’s text of that choice. This system is designed to give the author of the scene full control over how choices appear to the player.
When a choice has been selected by the player, the Control Dialog action is used to inform the Dialog Flow component that a choice has been made, and tell it which choice (from 0 to N, where N is the number of choices currently displayed) was chosen. From there the Dialog Flow component will jump to the appropriate branch of the conversation and continue.
For more details on implementing branching narratives in Story Machine, see the Dialog Flow script and Dialog Flow component documentation.