State Machine Editor

Workflows

The tool has a streamlined process for creating state machine assets:

  1. Build an empty machine.
  2. Populate possible states, actions, and conditions involved for the machine.
  3. List out all actions that occur in each state.
  4. Create transitions out of states and conditions.

SAC Designer

Clicking on a state shows which actions are listed as part of the state's actions
Clicking on a state shows which actions are listed as part of the state’s actions

The States, Actions, Conditions Designer (SAC Designer) allows the designer to quickly add or remove assets and customize them without having to jump around the project view too much.

Particularly for actions and conditions, these two types of state machine assets need to be scripted. Without this tool, it would be cumbersome for the designer and programmer to have to manually write these scripts and copy and paste to new ones if the behaviors are similar.

SAC Designer solves this by auto-generating scripts. With this auto-generation, the developer can go straight to adding the content of the action/condition.

StateAction template

// template.txt
using UnityEngine;
using Sporadic.FungAI.Runtime;

namespace {scriptNamespace}
{
    [CreateAssetMenu(menuName = "{createAssetMenuRootName}/Actions/{name}")]
    public class {sanitizedName}Action : StateAction
    {
        // add fields here; specify access modifier for fields

        // use this method if there are NO public fields that can be edited in inspector
        protected override StateAction CreateStateAction() => CreateInstance<{sanitizedName}Action>();

        // otherwise

        // uncomment this method if there are public fields that can be edited in inspector
        // protected override StateAction CreateStateAction()
        // {
        //     var instance = CreateInstance<{sanitizedName}Action>();
        //     // access fields through instance and initialize here
        //     return instance;
        // }

        public override void Initialize(StateMachine stateMachine)
        {
            // implement code to run before state enters
            // similar to the Awake() method
        }

        public override void OnEnter()
        {
            // OPTIONAL METHOD
            // implement code to run when state is entering
        }

        public override void OnUpdate()
        {
            // implement code to run while state is updating
        }

        public override void OnExit()
        {
            // OPTIONAL METHOD
            // implement code to run when state is exiting
        }
    }
}

Debug View

Eventually, when running many state machines in a scene, it will be difficult to track how each machine is transitioning. It would even be difficult to track just one machine since transitions can happen rapidly. Hence, I implemented a debug view.

Debug view during runtime
Logs can be filtered

The developer can also export and import logs as CSV files.

Logs imported into a spreadsheet
Logs imported into a spreadsheet
Tony Nguyen
Tony Nguyen
Technical Game Designer

Tenacious game developer with an unwavering passion for overcoming game development challenges.