The blackboard is the list of Shared Variables available to a state machine. It lets states and actions use the same value, so one action can update information that another action reads without duplicating the data.

Create and assign a value

Create and organize variables in the Shared Variables pane. The example groups object and integer values for the Resource, Juice, and Club parts of the graph.

The Shared Variables pane showing Resource, Juice, and Club variables in Graph scope.

Select a compatible Shared Variable from a field in the Element Inspector. Here, the SetInteger action reads the Gather Animation Index variable for its Value.

The SetInteger action using Gather Animation Index as its shared Value.

Share the value at runtime

Every action field assigned to the same Shared Variable references the same value. In this example, the SetInt action stores 5 in Gather Animation Index. The SetInteger action shown above then reads that updated value.

The SetInt action storing the value 5 in the Gather Animation Index shared variable.

Create a float Health variable in Graph scope with an initial value of 100. Bind Float 1 on both threshold Conditions to that same variable, while Float 2 supplies each literal threshold. The graph enters Flee at Health 25 and returns to Patrol at Health 40.

The Shared Variables pane selects Graph scope and contains the float variable Health with an initial value of 100.

The Any-to-Flee transition uses Continuous evaluation, has Can Reenter disabled, and compares the shared Health value with 25 using LessThanOrEqualTo.

Any redirects the Idle, Patrol, Chase and Attack flow into Flee. Recovery returns Flee to Patrol above the normal flow, while Attack returns to Idle below it.

Keep each variable in the narrowest scope that needs it:

  • Graph: Available to the current graph and appropriate for most variables.
  • GameObject: Available to state machines on the same GameObject.
  • Scene: Available to state machines in the same scene.
  • Project: Available to state machines throughout the project.

Related: