| Crates.io | bevy_northstar |
| lib.rs | bevy_northstar |
| version | 0.4.0 |
| created_at | 2025-03-29 15:43:02.175909+00 |
| updated_at | 2025-09-20 01:55:09.976181+00 |
| description | A Bevy plugin for Hierarchical Pathfinding |
| homepage | https://github.com/jtothethree/bevy_northstar |
| repository | https://github.com/jtothethree/bevy_northstar |
| max_upload_size | |
| id | 1611409 |
| size | 1,020,852 |
bevy_northstar works by dividing the map into chunks and then calculates nodes based on the entrances between chunks. The nodes are used in pathfinding to get a higher level path that is significantly faster to calculate over long distances. Once the high level path is determined between a start and goal position it can be refined to get a more accurate path. The crate is designed to significantly reduce the performance hit of A* pathfinding on complex maps.
The crate provides:
Blocking component to flag blockers.
cargo run --example demo --features stats --release
Press P to switch between Refined HPA*, Coarse HPA*, and traditional A* Press C to disable/enable collision Press R to change the nav data for random tiles every 5 seconds.

This crate has the following Cargo features:
stats: Enables pathfinding benchmarks. Useful to get an idea of how much time it's using per frame.parallel: Enabled by default. Disable default features to run grid builds single-threaded if needed for WASM.Add required dependencies to your Cargo.toml file:
[dependencies]
bevy = "0.16"
bevy_northstar = "0.3"
The basic requirements to use the crate are to spawn an entity with a Grid component, adjust the grid cells, and then call Grid::build() so the neighbors, chunk entrances, and internal paths can be calculated.
To use the built-in pathfinding systems for the crate, insert the NorthstarPlugin specifying the Neighborhood to use.
The built-in neighborhoods are:
CardinalNeighborhood 4 directions allowing no diagonal movement.CardinalNeighborhood3d 6 directions, including up and down, allowing no diagonal movement.OrdinalNeighborhood 8 directions allowing for diagonal movement.OrdinalNeighborhood3d 26 directions which includes the base ordinal movements and their up/down directions.use bevy::prelude::*;
use bevy_northstar::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
// Add the Northstar Plugin with a selected neighborhood to use the built in pathfinding systems
.add_plugins(NorthstarPlugin::<CardinalNeighborhood>::default())
.add_systems(Startup, (startup, build_grid.after(startup)))
.run();
}
fn startup(mut commands: Commands) {
commands.spawn(Camera2d::default());
// Build the grid settings.
let grid_settings = GridSettingsBuilder::new_2d(16, 16)
.chunk_size(4)
.build();
// Spawn the grid component
commands.spawn(CardinalGrid::new(&grid_settings));
}
fn build_grid(grid: Single<&mut CardinalGrid>) {
let mut grid = grid.into_inner();
// Let's set the position 8, 8 to a wall
grid.set_nav(UVec3::new(8, 8, 0), Nav::Impassable);
info!("Building the grid...");
// The grid needs to be built after setting the cells nav data.
// Building the grid will calculate the chunk entrances and cache internal paths.
grid.build();
info!("Grid built successfully!");
}
Pathfinding and grid algorithms involve a lot of branching, which can make debug builds significantly slower. You can set the optimization settings for this crate so you can still debug your game without the performance hit.
Follow Bevy Quickstart Cargo Workspaces to add opt-level = 3 to your Cargo.toml dependencies.
Or alternatively add the following to your Cargo.toml:
[profile.dev.package."bevy_northstar"]
opt-level = 3
| bevy | bevy_northstar |
|---|---|
| 0.16 | 0.2/0.3/0.4 |
kenny-minimap-pack: an 8x8 tileset from Kenney, licensed under CC0 1.0
Thanks to the following crates and blogs that have been used as references