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

Director with weighted choices

Give a wave director a Random Selector with real weights so each surge feels different without feeling arbitrary.

Weights on a Random Selector are graph data, so the designer who wants brutes rarer edits a number.

Every wave the same. Players learn the pattern and the tension goes. Randomizing it in code means a switch on Random.Range buried in a spawner, and the designer who wants brutes to be rarer has to file a ticket.

A state machine for the phases, and a Random Selector inside the phase that needs variety.

HordeDirector.bqbehavior holds three states: Build Up, Surge, and Relax, with transitions that read elapsed time and the live enemy count. The Surge state runs a Random Selector named Choose Surge whose three children carry weights.

A Random Selector named Choose Surge with three action children, Swarm weighted 5 at 50 percent, Rush weighted 3 at 30 percent, and Brute weighted 2 at 20 percent.
Figure 1. The editor shows each branch’s raw weight and the share it works out to, so a designer reads the odds without doing arithmetic.

Surge carries a repeat lifetime, so each pass through the state rolls again. The weights are graph data, which means tuning the feel of the game is an edit in a window.

  • Random Selector for the weighted pick.
  • State and Entry State for the three phases.
  • Transition with condition groups: Build Up leaves on an All group of elapsed time and enemy count, while Surge leaves on an Any group so either a timeout or a crowd ends it.
  • Blackboard values for every threshold, including build_up_duration, surge_duration, and surge_live_enemy_limit.

The director does not spawn anything. Each action asks the game’s own spawner for a flavor of wave, and the game owns budgets, pooling, and placement. That split is what lets you retune pacing without touching spawn code.

Full-size image