--- name: bevy-ai-navigation description: "Bevy 0.20 chase, patrol, and wait policy: an enum brain, a goal, a desired velocity, and a retarget timer on FixedUpdate. Use when an actor must choose a goal before movement. Paths stay on bevy-navigation. Keywords: Brain, Goal, DesiredVelocity, PatrolRoute, FixedUpdate, chase, patrol." --- # Bevy AI navigation ## When to use Load this when an actor must chase, patrol, or wait. This skill owns the intent and the desired velocity. Paths stay on bevy-navigation. Transform integration stays on bevy-character-movement. Line-of-sight sensors stay on bevy-spatial-queries. ## ECS shape - **Components:** a mode flag can be an enum `Component` (see bevy-state-machines for the pattern). Goal position can be your own component. No agent, radius, or layer type was opened. - **Resources:** a shared patrol table can be a `Resource` you define. No navigation resource was opened. - **Systems:** read the mode and write a desired velocity or waypoint on `Update` or `Fixed`. Use `.chain()` so policy runs before movement. Do not call an agent callback that writes `Transform`. - **Schedule:** `Fixed` / `FixedMain` when the result feeds the movement step. ## Policy map | Need | Owner | | --- | --- | | Chase vs patrol vs wait | Enum `Component` plus a system that writes `Goal` | | Retarget throttle | `Timer` resource ticked on `FixedUpdate` | | Crowd and avoidance | bevy-navigation | | Bake and obstacles | bevy-navigation | | Line of sight | bevy-spatial-queries | Policy writes `DesiredVelocity`. It does not move `Transform` and it does not query a navmesh. ```toml [dependencies] bevy = "0.20" ``` ```rust #[derive(Clone, Copy, PartialEq, Eq, Component)] enum Brain { Wait, Patrol, Chase, } #[derive(Component)] struct WaypointIndex(usize); #[derive(Component)] struct Goal(Vec3); #[derive(Component)] struct DesiredVelocity(Vec3); #[derive(Component)] struct Player; #[derive(Resource)] struct PatrolRoute { points: Vec, } #[derive(Resource)] struct RetargetClock(Timer); fn tick_policy( time: Res