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

Any State

Put the handoffs that hold from every mode in one ordered list instead of copying the same edge onto every state.

Death, a level reset, and a klaxon do not care which mode the actor is in. Any State holds those rules once, for the whole machine.

You add a fourth mode to a guard and now you owe it the same “the level reset, go back to the start” edge that the other three already have. Miss one and the guard keeps patrolling through a reset. Copy it four times and the next change is four edits, with four chances to leave one behind.

DocumentationStateControls.bqbehavior keeps that rule in one place. Its Any State owns a transition called reset patrol whose predicate is reset_requested == true, and it holds from patrolling and from chasing without either state carrying an edge for it.

  • A death, defeat, or shutdown mode that has to win from anywhere.
  • A level-wide reset like the Platformer fixture’s patrol reset.
  • One alarm shared by every mode of a machine, where the destination is valid no matter which mode was live.
The Any State row wins: reset patrol fires while chasing is active and hands the machine back to patrolling, whose Entry actions start over.
The Any State row wins: reset patrol fires while chasing is active and hands the machine back to patrolling, whose Entry actions start over.

DocumentationStateControlsLive.bqbehavior runs the same shape while the game is playing. The reset row wins from the mode that happens to be live, and the rail’s Precedence card shows why the order matters: the Any State subheading lists reset patrol as row one, and the patrolling subheading lists that mode’s own player spotted as row two.

Any State with its machine-wide reset transition
Figure 1. Any State is a dashed plate beside the ordinary modes. It is never the active mode; it only owns the rows that leave from anywhere.
  1. Open Assets/Platformer/Behavior/DocumentationStateControls.bqbehavior and find the dashed Any State plate below the ordinary modes.

  2. Select it. The rail names it Any State, and its name is fixed, so there is nothing to rename. It has no Entry, no Active Update, no Exit, no Completion. The first line of its rail states its whole job: “These transitions are checked before the active state’s own list. A row targeting the active state is skipped.”

  3. Select the transition reset patrol that leaves it. Its Trigger compares reset_requested with true, and its destination is patrolling.

  4. Read the Evaluate card. When offers Continuous alone, and the line under the control explains why: Any State has no Active Update whose finish or pass could arm a row.

  5. Read the Precedence card on that rail. Put the most urgent rule first, because the first matching row wins before any local row is considered.

The Evaluate card on an Any State transition
Figure 2. One choice and a reason. The rail refuses to offer a finish cadence Any State could never reach.

Where it sits in the update

The active machine’s Any State rows are scanned before the active state’s own rows, in authored order, at the boundary that opens every update and again right after Active Update produces a terminal result. The first match wins and at most one transition fires per update.

A row whose destination is already the active mode is skipped. That is what keeps a predicate that stays true from restarting its own destination every update, and it is why there is no “can re-enter” toggle to find.

What Any State is and is not

  • It is never entered and never reported as the active mode, so it produces no result.
  • It owns no Entry, Active Update, Exit, Run, Lifetime, or Completion. Authoring refuses lifecycle work or semantic parameters on it.
  • A machine may hold at most one of them, connected to its root by exactly one containment edge, and it may source only transition rows.
  • Each composed machine owns its own. A referenced child machine uses its own Any State list while the child is active; it does not borrow the parent’s rows, and the parent does not reach into the child’s.

Firing behavior

An Any State Switch cancels the work the active mode owned, gives that mode its one Exit update, then runs the destination’s Entry. An Any State row can also be a Push, which suspends the current mode for a later Return instead of ending it.

Keep the list short

A broad global row preempts every local rule and every mode’s work. It earns its place when the predicate and the destination are both valid from every mode the machine can be in. If a rule matters in one mode, keep it on that mode. If two modes share it and five do not, two local rows say more about your design than one global row does.

When it goes wrong

SymptomCheckFix
The global rule wins in a mode where it should not.Read the predicate and ask whether it is true in modes you did not think about.Narrow the predicate, or move the row back onto the modes where it belongs.
A local transition never gets a turn.Read whether an Any State predicate stays true while that mode is active.Any State is scanned first by design, so make its predicate an event-like edge that goes false again.
The destination restarts every update.Confirm the row really leaves from Any State and not from the destination itself.An Any State row aimed at the active mode is skipped; a local self transition is not, so read its Re-entry card.
Authoring refuses a second Any State.Look for one already on the canvas, possibly scrolled out of view.A machine holds one. Add the extra rows to the existing plate.
The Evaluate card offers no On finish.Read the reason line under the control.Nothing to repair. Any State rows are Continuous, so move finish-shaped rules onto the state that owns the work.
Full-size image