Repository navigation
feat: Add the flame_navigation package for path finding - #4259
Conversation
flame_navigation package for path finding
|
My clanker's response:
Clearance is now measured to the closest point of each blocked cell, not to its center, so it's exact in every direction (5b9736c). I went with the exact fix: the same distance transform on a lattice of half-cell steps. The √2/2 version was too strict for agents that are small compared to the cells. Your repro is now a test.
region.revision now picks up changes made to the grid directly, like setAreaCosts (5c541bf)
Regions are tracked per game instead of being looked up through the component tree (8d9cf60). Rebakes caused only by obstacles reuse the shapes of the sources, while markDirty still reads them again, since that's how users report moved hitboxes (33f5cc2). Obstacles now compare their transform instead of building shapes every frame (2315dbc)
fromBytes checks the header explicitly and throws a FormatException (7229e15). |
flame_navigation package for path findingflame_navigation package for path findin
flame_navigation package for path findinflame_navigation package for path finding
Description
This adds
flame_navigation, a new package for path finding in Flame games.Flame has no path finding today. With this package, you bake the obstacles of your world into a
navigation grid once, and then agents find their way through it. You don't place waypoints or
build a graph by hand.
What the package has:
NavigationRegionbakes aNavigationGridfrom its sources, and finds paths through it.NavigationAgentis added as a child of a component. It finds a path to itstargetand movesits parent along it. With
autoMove: false, it only gives adesiredVelocity, for games thatmove their characters themselves.
HitboxNavigationSourcebakes the hitboxes of the world,ShapesNavigationSourcebakes shapes made in code, and you can write your own.
closest obstacle, and an agent only walks on the cells where it fits.
of some areas.
NavigationObstacleis for things that move, like doors and crates. Only the part of the gridaround them is baked again.
NavigationGrid.toBytesandNavigationGrid.fromBytessave and load a grid, so big levels canbe baked ahead of time and shipped as an asset.
debugMode, in the same way as hitboxes. Flags choose what is drawn: thegrid, the blocked cells, the areas, the clearance, the cells that a search explored, the paths
of the agents, and more.
NavigationBakerandAStarcan also be used without any components.1-click-to-move.mp4
2-agent-sizes.mp4
3-areas.mp4
4-obstacles.mp4
5-path-finding.mp4
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues