A Subgraph Reference places reusable state machine behavior inside another graph. Use it when the same group of states, Actions, and transitions is needed in several graphs, or when a parent graph should remain focused on its high-level flow.

In the editor

Add a Subgraph Reference state to the parent graph and assign one or more Subgraph assets to it.

A Subgraph Reference state placed in a State Designer graph.

Add outgoing transitions to the Subgraph Reference when the parent graph needs to define what happens after the referenced behavior finishes. If several Subgraphs are assigned to one reference, their order in the list controls the order in which they are processed.

Use Shared Variable Overrides when the parent graph should provide different values without changing the reusable Subgraph asset.

The Subgraph Reference inspector mapping a source Shared Variable to an override value.

Each override maps a Source variable from the Subgraph to the Override value or variable supplied by the parent graph. Leave an override empty when the Subgraph should keep its own default value.

How it runs

Subgraph Reference is a structural entry point. When execution reaches it, State Designer injects the referenced Subgraph content, and the States and Actions inside that content perform the gameplay behavior. Conditions on its transitions continue to control movement between States.

If a State inside the Subgraph reaches its end without an outgoing transition, execution can continue through an outgoing transition on the Subgraph Reference in the parent graph. This gives the parent one clear place to decide what follows the reusable behavior.

When one reference contains multiple Subgraphs, State Designer processes them in list order.

Key reuse choices

Use one Subgraph with different overrides when the structure should remain the same but values such as a target, speed, timer, or flag should vary by parent graph.

For an advanced setup, the selected Subgraph can change at runtime. After changing that selection, call StateMachine.ReevaluateSubgraphReferences(). State Designer then reevaluates the references and rebuilds the injected content using the current selection and override mappings.