Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bevy_orca

Walkers that steer around each other without colliding. ORCA (optimal reciprocal collision avoidance) gives each agent the velocity closest to the one it wanted that no neighbour can object to, assuming every neighbour reasons the same way and each takes half the dodge. It is a plain library on bevy_math’s Vec2, with no ECS, plugin or schedule: you call a function and get a velocity back.

Add it

cargo add bevy_orca

The README has a single-agent quick start that is compiled on every cargo test.

What it gives you

  • new_velocity for one agent, with a documented, finite answer for every unusable input and never a velocity over max_speed (one agent).
  • Crowd for many: a neighbour grid, a deterministic tie-break, a sideways nudge, and no allocation once warm (a whole crowd).
  • Right of way through priority, and Crowd::begin / CrowdStep::solve_range to split a step over your own thread pool with bit-identical results.
  • ObstaclesBuilder for buildings, walls, polygons and tile maps, as RVO2’s obstacle lines (static obstacles).
  • serde and reflect features on Agent, CrowdMember and CrowdParams.

Use it in the Cauldron

The Cauldron takes this crate behind its bevy_orca feature for the crowd preview (issue #107): it walks N people from one area of a map to another, each stepping with bevy_orca’s Crowd against its neighbours and against the cells the map’s pieces make solid, and lays their trails and congestion into a bevy_stigmergy field. The editor draws the result over the map with how many arrived and where congestion peaks, and saves nothing to the map. The settings it passes are the crate’s own CrowdParams, which are Serialize/Deserialize behind the serde feature.