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.11.0
Menu

Attack with cooldown

Gate the attack branch on a countdown your own component owns, so the graph never keeps a second copy of the timer.

The component that refuses the swing is the component that should be timing the wait.

An enemy should swing, then wait, then swing again. If the graph owns the wait, you have two timers: the one in your combat component that decides whether the hit lands, and the one in the graph that decides whether to try. They drift, and the enemy swings at nothing.

Keep the countdown in the component. On a fresh Attack Sequence entry, check distance, contact range, and cooldown before starting a flurry.

HordeEnemy.bqbehavior runs an Enemy Decisions Selector under repeat forever. It tries Death, Attack Sequence, Chase Sequence, then Wander. Distance Squared Precheck calculates distance_sq_precheck; In Contact Radius Precheck tests it against ContactAttack.RadiusSq; Cooldown Ready Precheck reads ContactAttack.CooldownRemaining and tests ≤ 0. If a precheck fails, Attack Sequence fails and the Selector tries pursuit or wander. Once the prechecks pass, Reset Attack Tally clears attacks_landed and the three-grant Attack Flurry begins. The inner Until Ready guard rechecks distance and cooldown before each counted grant.

Paused Horde attack prechecks with selected read-only details, followed by a separately selected idle Attack Flurry on Count 3.
Figure 1. The paused prechecks show Distance Squared Precheck succeeding and In Contact Radius Precheck failing, leaving Cooldown Ready Precheck untouched. A separate paused enemy’s selected Attack Flurry shows Count 3 and has not started.

The countdown already lives in a component, so the graph reads it as a fact instead of keeping a second clock.

  • Selector with death, attack, chase, and wander branches in that order.
  • Sequence for Attack Sequence, so the first failing precheck ends a fresh attempt.
  • Member condition reading ContactAttack.CooldownRemaining before a new flurry and again between its grants.
  • Method for the static distance calculation that the contact-range checks compare against.

Put the countdown where the ability already lives, so the component that refuses the swing also measures the wait. Place the cooldown precheck before the flurry; inside a flurry, check it again before each grant. Attack Flurry counts real grants, not the frames spent waiting between them.

Full-size image