Tools / Tutorials / A* Pathfinding

Tutorial

A* Pathfinding in Unity Without NavMesh Baking

Unity's NavMesh is great — until it isn't. 2D games, tile-based worlds, procedurally generated levels, and obstacles that move at runtime all fight against baked navigation. A* grid pathfinding is the answer. Here's how it works.

Where NavMesh struggles

NavMesh requires baking navigation data ahead of time. That breaks down when your world changes at runtime: destructible terrain, player-built walls, procedural dungeons, or anything in 2D (NavMesh is fundamentally a 3D system). You can rebake at runtime, but it's expensive and complex. For these games, you need pathfinding that thinks in grids, not baked meshes.

How A* works (the 30-second version)

A* (A-star) searches a grid of walkable cells from start to goal, always expanding the most promising cell first — the one with the lowest combined cost of "distance traveled so far" plus "estimated distance to goal." That heuristic is what makes it fast: unlike brute-force search, A* heads toward the target instead of wandering. The result is the shortest walkable path, even around complex obstacles.

Grid pathfinding in practice

A practical A* setup has four pieces:

  1. A grid over your world — cells marked walkable or blocked, in 2D or 3D.
  2. Agents that request paths from A to B.
  3. Obstacles that mark cells unwalkable — ideally updatable at runtime.
  4. A simple API — "give me the waypoints from here to there" — so your game code stays clean.

The grid approach shines for tower defense, RTS, roguelikes, puzzle games, and any tile-based design — genres where NavMesh was never the right tool.

The fast way: NexPath

NexPath is a ready-made A* pathfinding system for Unity: grid-based navigation for 2D and 3D, agents with dynamic obstacle updates, and a simple waypoint API — no NavMesh baking, no pathfinding math to write yourself. Drop it in, define your grid, and your characters start moving intelligently.

A* pathfinding, no baking required

NexPath — grid-based A* pathfinding for 2D/3D with dynamic obstacles and a simple waypoint API. $16.99 direct.

Get NexPath — $16.99

Or see full details · Also on the Unity Asset Store ($19.99)

Performance notes

A* on large grids with many agents can get expensive — keep your grid resolution as coarse as your gameplay allows, cache paths instead of recomputing every frame, and stagger path requests across frames for crowds. A well-tuned grid solver handles hundreds of agents without breaking a sweat.