Skip to content

feat: Add the flame_navigation package for path finding - #4259

Open
ufrshubham wants to merge 31 commits into
mainfrom
devkage/flame-navigation
Open

ufrshubham wants to merge 31 commits into
mainfrom
devkage/flame-navigation

Conversation

@ufrshubham

@ufrshubham ufrshubham commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

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.

world.add(
  NavigationRegion(
    bounds: const Rect.fromLTWH(0, 0, 800, 600),
    cellSize: 8,
    sources: [HitboxNavigationSource(world)],
  ),
);

final agent = NavigationAgent(
  agentType: const NavigationAgentType(radius: 12),
  maxSpeed: 120,
);
world.add(PositionComponent(children: [agent]));
agent.target = Vector2(700, 300);

What the package has:

  • NavigationRegion bakes a NavigationGrid from its sources, and finds paths through it.
  • NavigationAgent is added as a child of a component. It finds a path to its target and moves
    its parent along it. With autoMove: false, it only gives a desiredVelocity, for games that
    move their characters themselves.
  • Sources: HitboxNavigationSource bakes the hitboxes of the world, ShapesNavigationSource
    bakes shapes made in code, and you can write your own.
  • One grid works for agents of any size. Each cell stores its clearance, the exact distance to the
    closest obstacle, and an agent only walks on the cells where it fits.
  • Areas with costs, like mud that is slow to walk through, and area masks to keep some agents out
    of some areas.
  • NavigationObstacle is for things that move, like doors and crates. Only the part of the grid
    around them is baked again.
  • NavigationGrid.toBytes and NavigationGrid.fromBytes save and load a grid, so big levels can
    be baked ahead of time and shipped as an asset.
  • Debug drawing behind debugMode, in the same way as hitboxes. Flags choose what is drawn: the
    grid, the blocked cells, the areas, the clearance, the cells that a search explored, the paths
    of the agents, and more.
  • NavigationBaker and AStar can 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

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

@ufrshubham ufrshubham changed the title feat: Add the flame_navigation package for path finding feat: Add the flame_navigation package for path finding Nov 29, 2026
@ufrshubham
ufrshubham marked this pull request as ready for review December 1, 2026 19:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant