Skip to content
crates · rust · bevy

Flow-field navigation forbevy_pathfinder

A grid pathfinding crate for Bevy tile worlds — a walkability grid, BFS-computed direction fields toward shared goals, per-agent A*, and a narrow-passage detector, on a pure-Rust core.

Flow fields and A*, by goal count

When many agents share the same goal, a single BFS builds a direction field once and every agent looks up its next move in O(1). When each agent has a destination of its own, A* searches the same grid per agent.

RustBevy crate
0.1.2Version
OptionalBevy feature
MITLicense

What it gives you

Features

BlockGrid

2D walkability grid with per-cell height and terrain cost.

FlowField

BFS-computed direction vectors pointing every walkable cell at one or more goals. Agents share a goal and look up their next move in O(1) instead of running per-agent A*.

A* search

Per-agent search over the same BlockGrid for guards, wanderers, and anyone walking somewhere of their own.

FlowGate

Narrow-passage detector, useful for ambush AI, territory control, and patrol route generation.

Pure-Rust core

No engine dependency by default; the bevy feature adds Resource derives, and tile-graph adds TileGraph / PathField over sparse graphs such as dungeon rooms.

Questions

Frequently asked

What does the bevy_pathfinder crate do?

It provides grid pathfinding for tile worlds — a walkability grid, BFS-computed direction fields toward shared goals, per-agent A* over the same grid, and a narrow-passage (chokepoint) detector. An optional tile-graph feature adds BFS over sparse node-and-edge graphs.

Why flow fields instead of per-agent A*?

Both are there. When many agents share the same goal, a single BFS builds a direction field once and every agent looks up its next move in O(1); when each agent has a destination of its own, the astar module searches per agent. Both step by the same BlockGrid::can_step rule, so they agree on what a legal move is.

Is Bevy required to use it?

No. The crate is pure Rust by default; enabling the optional bevy feature adds Resource derives for ECS integration.

Discuss on the forum

Questions, fixes and notes on this page live in the KBVE forum.