State machine example: Interactive Tutorials

One of the most useful applications for a state machine is to build interactive tutorials. To get started, you can load either:
Both of these files are structured similarly, so regardless of which you choose you can get started by doing the following:

To view the state machine

  1. In the Outliner, turn off Display > DAG objects only.
  2. Filter by the term "stage".
  3. Select all the stage nodes.
    Note: There will also be a number of "activate_stage" nodes alongside the stage nodes. You do not need to worry about these yet.
  4. Open Windows > Node Editor.
  5. Click the Show Inputs / Outputs button () to display the stage nodes and their connections.
At this point, you can see how the tutorial stage nodes are structured. Some important things to pay attention to include:

Viewing Activate/Deactivate scripts

Most of the work for a stage happens in its connected script nodes. In both example files above, these are typically named 'activate_stage#' or 'deactivate_stage#'. There are also a number of helper scripts that are not connected to stages, but are often called by them to perform some common tasks. Some examples include:
  • overlayBubble: Handles drawing word bubble-style overlays on-screen.
  • overlayDialog: Handles drawing dialog box-style overlays on-screen. Unlike bubbles, these can be moved and closed.
  • clearOverlays: Delete all bubble-style overlays.
  • clearDialogs: Delete all dialog-style overlays.
  • populateText: Contains a dictionary of all the text for the tutorial which can be referenced via stage name.
  • updateController: Refreshes the text and visibility of the controller.

To view all the scripts for the tutorial

  1. Open Windows > Animation Editors > Expression Editor.
  2. Click Select Filter > By Script Node Name.
  3. Select a script in the upper-left column to view its contents.

Both example files are fully commented and documented for convenience.