Skip to content

Creating a State Tree Example

This walkthrough builds the NPC from the part 3 video tutorial: a mannequin that stands idle and waves at the player when they step into a trigger volume. It’s the smallest useful State Tree you can build and it covers every mechanic that bigger trees are built out of.

The finished NPC waves at the player as they enter the trigger

State Trees run on a VA component. For a single actor, put that component on a Blueprint.

  1. In the Content Browser, right-click → Blueprint Class → Actor. Name it BP_NPC.
  2. Open it. Add a Vertex Animation Mesh Component.
  3. Select the component and set its Vertex Animation Asset to your mannequin VA Asset Collection.
  4. Compile, save, and drop an instance into your level.

BP_NPC with VA Mesh Component and Collection set

  1. In the Content Browser, right-click → Artificial Intelligence → State Tree.
  2. A dialog will ask which schema to use. Pick VA StateTree Schema. This makes the tree compatible with the VA instance system and exposes the VA-specific Tasks, Conditions, and Evaluators.
  3. Name the asset using the StateTree_ prefix. We’ll call this one ST_NPC.

Creating a VA StateTree asset with the schema picker

Every VA State Tree needs to know which Asset Collection it targets. Setting this up initially makes all animation pickers in the tree context-sensitive. Dropdowns will only show animations that exist in your collection.

  1. Open ST_NPC. Find the Asset Details panel (top-right by default).
  2. Set Preview Collection to the same mannequin collection you put on BP_NPC.

Asset Details panel showing Preview Collection set to the mannequin

  1. Right-click the root → Add State. Name it Idle.
  2. With Idle selected, expand the Tasks section and click +. Pick Play Vertex Animation.
  3. Set Animation to your idle clip and enable Loop. The NPC will now stand idle forever while this state is active.
  4. Add a sibling state called Wave. Add a Play Vertex Animation task, pick the wave clip, and leave Loop off. This lets the state complete when the clip finishes.

Idle and Wave states with Play Vertex Animation tasks

Press Compile. The NPC in your level will start idling immediately. State Trees update in real time while the editor is open.

Idle should loop indefinitely and only hand over to Wave when a gameplay tag event fires.

  1. Create a Gameplay Tag Mannequin.Wave (Project Settings → Project → Gameplay Tags, or add it inline in the Event Tag picker).
  2. Select Idle. In the Transitions panel click +.
  3. Set Trigger = On Event, Event Tag = Mannequin.Wave, Transition To = Wave.
  4. On Wave, add a transition: Trigger = On State Completed, Transition To = Idle.

On Event transition firing on the Mannequin.Wave tag

Compile. The tree now sits in Idle and only moves to Wave when something broadcasts the Mannequin.Wave tag at it.

Tip: On State Completed is also how you chain states into a fixed loop (Idle → Wave → Idle) if you don’t need an external trigger. See Transitions for all the trigger types.

6. Trigger the Event from the Level Blueprint

Section titled “6. Trigger the Event from the Level Blueprint”

The last piece is the code that fires the event when the player overlaps the trigger.

  1. Add a Trigger Volume to the level and select it.
  2. Open the Level Blueprint. With the trigger still selected, right-click in the graph and add On Actor Begin Overlap.
  3. From Other Actor, Cast To your player character class. Branch on the cast result.
  4. Get a reference to your BP_NPC actor (any method works. A variable on the level, Get Actor Of Class, etc.).
  5. Off the reference, call Get VA Mesh to retrieve the Vertex Animation Mesh Component.
  6. Off the component, call Broadcast Anim Event.
  7. For the event’s Tag, plug in a Make Literal Gameplay Tag set to Mannequin.Wave.

Level Blueprint overlap chain broadcasting Mannequin.Wave

Broadcast Anim Event is one of three broadcast nodes on the VA component. See Triggering Events for Broadcast Anim Event With Instances (target specific instance handles) and Broadcast Throttled Event (spread the per-instance dispatch across frames, good for large crowds).

Press Play and walk your character into the trigger. The NPC waves, finishes the clip, and returns to idle. Re-enter the trigger and it waves again.

Tip: Run slomo 0.2 in the console if the animations play too fast to see the transitions cleanly while you’re testing.

Vertex Animation Studio ships a working example State Tree that goes much further than this one. Open Plugins/VertexAnimation/Content/DemoMap/Blueprints/ and look at StateTree_SoccerFan for a crowd-scale tree with reaction states, weighted random idles, and per-instance parameters.

  • Tasks Reference - every built-in VA task, with parameters.
  • Transitions - completion vs event vs tick, and transition conditions.
  • Triggering Events - broadcasting events from Blueprints and C++, including the throttled variant for large crowds.