One of the most useful applications for a state machine is to build interactive tutorials. To get started, you can load either:
- The TutorialBuldingDemo file located in the
Content Browser.
- The interactive Basics tutorial via the Getting Started tab of Application Home.
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
- In the Outliner, turn off
.
- Filter by the term "stage".
- 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.
- Open
.
- 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
- Open
.
- Click
.
- Select a script in the upper-left column to view its contents.
Both example files are fully commented and documented for convenience.