bevy-navigation
БесплатноБез исполняемых скриптовНе проверенBevy ECS skill for navigation. Keywords: Bevy, navigation, pathfinding, ECS.
от thedivergentai★ 1 019 звёзд на GitHubОб этом скилле
Bevy navigation
When to use
Load this when agents need a path over walkable space before adding a crate. Movement of the actor after a path exists belongs on bevy-character-movement. Policy for chase, patrol, and retarget belongs on bevy-ai-navigation.
ECS shape
- Components store the goal cell and the waypoint list for one agent.
- Resources own the walk grid: width, height, and blocked cells.
- Systems search on
Update, then step along the path onFixedUpdate..chain()keeps the new path visible before motion. - Schedule: search and follow stay on the app schedules above. Crowd policy stays on bevy-ai-navigation.
Ownership
| Need | Bevy shape |
|---|---|
| Agent | An entity with a goal and a waypoint list |
| Walkable space | A WalkGrid resource of blocked cells |
| Avoidance | Separation stays on bevy-ai-navigation |
| Next waypoint | AgentPath stepped on FixedUpdate |
Scope
- A grid, a breadth-first search, and a follower are enough for walkable cells. Navmesh baking and crowd radius stay outside this skill.
- Actor locomotion after a waypoint exists belongs on bevy-character-movement.
Examples
[package]
name = "navigation"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = "0.20"
The grid is a resource. Search writes waypoints. The follower consumes them on the fixed step.
use std::collections::VecDeque;
#[derive(Resource)]
struct WalkGrid {
width: i32,
height: i32,
cell: f32,
blocked: Vec<bool>,
}
#[derive(Component)]
struct GoalCell(i32, i32);
#[derive(Component)]
struct AgentPath {
waypoints: Vec<Vec3>,
index: usize,
}
fn cell_index(grid: &WalkGrid, x: i32, y: i32) -> Option<usize> {
if x < 0 || y < 0 || x >= grid.width || y >= grid.height {
return None;
}
Some((y * grid.width + x) as usize)
}
fn search(grid: &WalkGrid, start: (i32, i32), goal: (i32, i32)) -> Vec<Vec3> {
let Some(start_i) = cell_index(grid, start.0, start.1) else {
return Vec::new();
};
if grid.blocked[start_i] {
return Vec::new();
}
let mut prev: Vec<Option<(i32, i32)>> = vec![None; grid.blocked.len()];
let mut queue = VecDeque::new();
prev[start_i] = Some(start);
queue.push_back(start);
while let Some((x, y)) = queue.pop_front() {
if (x, y) == goal {
break;
}
for (nx, ny) in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] {
let Some(i) = cell_index(grid, nx, ny) else {
continue;
};
if grid.blocked[i] || prev[i].is_some() {
continue;
}
prev[i] = Some((x, y));
queue.push_back((nx, ny));
}
}
let Some(_) = cell_index(grid, goal.0, goal.1).filter(|i| prev[*i].is_some()) else {
return Vec::new();
};
let mut cells = Vec::new();
let mut cursor = goal;
cells.push(cursor);
while cursor != start {
let Some(i) = cell_index(grid, cursor.0, cursor.1) else {
break;
};
let Some(parent) = prev[i] else {
break;
};
if parent == cursor {
break;
}
cursor = parent;
cells.push(cursor);
}
cells.reverse();
cells
.into_iter()
.map(|(x, y)| Vec3::new(x as f32 * grid.cell, 0.0, y as f32 * grid.cell))
.collect()
}
fn plan_paths(
grid: Res<WalkGrid>,
mut agents: Query<(&Transform, Ref<GoalCell>, &mut AgentPath)>,
) {
let grid_changed = grid.is_changed();
for (tf, goal, mut path) in &mut agents {
if !grid_changed && !goal.is_changed() {
continue;
}
let start = (
(tf.translation.x / grid.cell).floor() as i32,
(tf.translation.z / grid.cell).floor() as i32,
);
path.waypoints = search(&grid, start, (goal.0, goal.1));
path.index = 0;
}
}
fn follow_paths(time: Res<Time<Fixed>>, mut agents: Query<(&mut Transform, &mut AgentPath)>) {
let step = 4.0 * time.delta_secs();
for (mut tf, mut path) in &mut agents {
let Some(goal) = path.waypoints.get(path.index).copied() else {
continue;
};
let delta = goal - tf.translation;
let dist = delta.length();
if dist <= step || dist == 0.0 {
tf.translation = goal;
path.index += 1;
} else {
tf.translation += delta / dist * step;
}
}
}
pub struct NavigationPlugin;
impl Plugin for NavigationPlugin {
fn build(&self, app: &mut App) {
let width = 8;
let height = 8;
app.insert_resource(WalkGrid {
width,
height,
cell: 1.0,
blocked: vec![false; (width * height) as usize],
})
.add_systems(Update, plan_paths)
.add_systems(FixedUpdate, follow_paths);
}
}
Mark a cell blocked and give an agent a goal. Planning runs again
Установить bevy-navigation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bevy-navigation?
Bevy ECS skill for navigation. Keywords: Bevy, navigation, pathfinding, ECS.
Как установить скилл bevy-navigation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bevy-navigation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic