Skip to content
Bit Quirky Behavior Trees and
State Machines

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or enter a complete API identifier.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v0.6.0
Menu

Guard and investigate

Capture a stimulus once, hold it on the blackboard, and give the guard a branch that goes and looks before it gives up.

A thrown coin is a fact that keeps changing, so the guard stores one copy and investigates that instead.

Throw a coin behind a guard. It should turn, walk over, look around, find nothing, and go back to its route. Done with a bool the guard investigates the newest noise every frame and never arrives anywhere, because the fact keeps changing under it.

Split it in two. One branch captures a stimulus and stores it; a lower branch acts on the stored copy until it expires.

Guard2.bqbehavior does exactly this. Its capture stimulus Sequence runs three nodes: newest eligible signal pending, store one stimulus payload atomically, then consume the captured signal. Below it, the investigate branch works from the stored payload through enter suspicious, a dwell, a validity check, move to the stimulus, and look around, with a sibling that expires a stale stimulus first.

A live behavior tree for Guard_2: the investigation priority selector over the suspicion and investigation sequence, whose dwell node is marked Running with its card title elided by the card width.
Figure 1. Guard2 in Live. The investigation branch owns the tick, and hold and face the active stimulus is the node actually running; the validity check and the walk to the stimulus wait their turn beside it.

Storing the stimulus is what makes the walk finish. The guard commits to one coin instead of re-deciding against whatever is newest.

Reach for this whenever the game hands the actor a fact that keeps changing: the newest noise, the latest damage direction, the last seen position. Capture it once into a blackboard value, then act on the stored copy until it expires, and the actor finishes the trip it started. Your code keeps the ranking rules; the graph just decides when to commit.

  • Sequence for capture, and again for the investigation steps.
  • Member condition for newest eligible signal pending and the staleness check.
  • Method for store, consume, move, and look, all of which stay in the game’s own guard code.
  • Selector above the two investigation branches so expiry is checked before dwelling.

The hearing rules, stimulus ranking, navigation, and the catch reset are Dungeon Heist C#. The graph decides which of them gets this moment.

Full-size image