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

Only if

Conditional keeps a branch admitted while a fact holds, and with Self abort it also takes the branch away when the fact stops holding.

A Conditional is a gate with the fact written on it. The branch under it runs while the fact succeeds, and the gate is re-read every time the tree comes back to it.

Chasing is only sensible while the player is visible. A Condition at the front of a Sequence answers that once, at the start of the chase, and then the chase owns the agent until it finishes. If the player ducks behind a crate two seconds in, the enemy keeps running at a wall.

DocumentationDecorators.bqbehavior shows the gate shape as the Conditional called while visible over the chase action. Its name is the promise: the fact is checked for as long as the branch is alive.

  • Work that stays valid only under a condition: chase while visible, hold a door while the player is near, drive the recovery loop while recovery is active.
  • A gate that reads better than a Sequence, because the fact belongs to the whole subtree instead of being step one.
  • Branch cancellation with Self abort, when the fact turning false should drop the running work immediately.
The while visible gate sits over continue chasing: on the passes where its fact does not hold the child never starts and no pill appears on it, and when the tick reaches the gate with the fact true the child picks the pill up.
The while visible gate sits over continue chasing: on the passes where its fact does not hold the child never starts and no pill appears on it, and when the tick reaches the gate with the fact true the child picks the pill up.

The fact is true, the Conditional admits the child, and the child runs. The fact goes false and the Conditional reports Failure without the child starting at all.

  1. Open Assets/Platformer/Behavior/DocumentationDecorators.bqbehavior and select the Conditional called while visible.

  2. The rail shows condition variable, a dropdown over the graph’s readable declared values. This node reads player_visible. An unset gate shows the prompt Choose a condition variable….

  3. Below it sits abort mode, with two choices: none and self. Leave it on none for a plain gate.

  4. Read the Child line. A decorator wraps exactly one child; here it is the chase action.

  5. For the running version, open Assets/Platformer/Behavior/DocumentationReactiveAborts.bqbehavior, which carries the same while visible gate inside a reachable chase branch. Run an agent on it with player_visible false: the branch’s sight condition stops the Sequence and the gate is never reached.

  6. Set player_visible true and the gate admits the chase. That graph’s gate is already on self, so setting the value back to false while the chase is Running drops the chase mid-run instead of letting it finish.

Conditional decorating a chase action
Figure 1. The gate owns the fact. The child owns the work.

The Conditional evaluates its own fact every time the tree reaches it, then decides whether the child may run.

Result

Success
The child ran and returned Success. A Conditional never rewrites its child's result.
Failure
The fact did not succeed, so the child was refused. A false blackboard comparison lands here.
Running
The fact succeeded and the child is working.
  • Admission needs Success. Anything else, including the Blocked that a false blackboard comparison produces, refuses the child and the decorator reports Failure.
  • A completed child’s result passes to the Conditional’s parent unchanged. The gate decides whether work happens, never what the work reported.
  • abort mode on this node offers none and self. Lower Priority lives on the Selector, because it is about branch priority instead of a single gate.
  • With self, the fact is re-evaluated on every update, even while the child is deep in its own work. The moment it stops succeeding, the branch is cancelled, pending work owned by that subtree is cancelled with a Self reason, and the hosting Selector re-decides from its first child.
  • self needs an enclosing Selector branch. A Self Conditional with no Selector above it is reported by validation rather than silently ignored.
  • A runtime fault while evaluating the fact travels up as a fault. Admission is never guessed from a failed read.

When it goes wrong

SymptomCheckFix
The child never runs even though the fact looks true.Read the condition variable dropdown for the prompt or an invalid saved name.Choose a readable declared value of a comparable type.
The branch keeps running after the fact turned false.Read abort mode on the Conditional.Set it to self.
Validation rejects the Self Conditional.Look for a Selector above it in the branch.Put the guarded work in a Selector branch, which is what gives the cancellation somewhere to go.
The gate reports Failure and you expected Blocked.The decorator converts a refused admission into Failure.Nothing to repair. Read the child Condition in Live for the underlying reason.
Chase restarts from the beginning after each cancel.Self cancellation re-enters the hosting Selector at its first child.Keep restart-safe work under a Self gate, and keep progress in your own component when a restart would lose it.
Full-size image