Game dev
Saved & recent

Flow field

Related terms: vector field, crowd pathfinding

Instead of computing a path for each unit, compute once, for every cell of the map, which direction leads toward the goal. Any number of units then just follow the arrow under their feet.

The cost depends on the size of the map, not on the number of units. That suits armies, hordes and crowds all heading to the same place. It is built by flooding outward from the goal and pointing each cell at its cheapest neighbor.

Further reading
Flow Field Pathfinding for Tower Defense
shared goal downhill neighbor
Flooding out from the gold goal assigns each reachable cell a cost. Each arrow leads to a neighbor one step cheaper, so all three rovers can follow the same field.

View in the full Game dev collection