Workflows
The tool has a streamlined process for creating state machine assets:
- Build an empty machine.
- Populate possible states, actions, and conditions involved for the machine.
- List out all actions that occur in each state.
- Create transitions out of states and conditions.
SAC Designer
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.
The developer can also export and import logs as CSV files.