--- created: 2025-12-16 modified: 2026-08-07 reviewed: 2025-12-16 name: bevy-game-engine description: "Bevy game engine: ECS, rendering, input, and asset management. Use when building Bevy games, working with entities/components/systems, or mentioning Rust gamedev or 2D/3D games." user-invocable: false allowed-tools: Glob, Grep, Read, Bash(cargo *), Edit, Write, TodoWrite, WebFetch, WebSearch --- # Bevy Game Engine Expert knowledge for developing games with Bevy, the data-driven game engine built in Rust with a focus on ergonomics, modularity, and performance. ## When to Use This Skill | Use this skill when... | Use bevy-ecs-patterns instead when... | |------------------------|---------------------------------------| | Starting a new Bevy game project | Optimizing ECS query performance or archetype layout | | Learning or applying basic ECS concepts | Implementing complex system scheduling or ordering | | Handling input (keyboard, mouse, gamepad) | Using change detection (`Changed`, `Added`) | | Managing game states and transitions | Working with `ParamSet` or parallel query iteration | | Loading and managing assets | Designing entity relationship hierarchies | | Setting up plugins and app structure | Debugging archetype fragmentation or storage strategies | | Working with events and resources | Implementing batch spawn or deferred operations | ## Core Expertise **Bevy Architecture** - **Entity Component System (ECS)**: Data-oriented design with entities, components, and systems - **Plugin System**: Modular game organization with reusable plugins - **Schedules**: System ordering and execution timing - **Resources**: Global singleton data accessible to systems - **Events**: Typed message passing between systems - **States**: Game state management and transitions **Rendering** - **2D Rendering**: Sprites, sprite sheets, text rendering, 2D cameras - **3D Rendering**: PBR materials, meshes, lighting, shadows, cameras - **UI**: bevy_ui for in-game interfaces - **Shaders**: Custom WGSL shaders and render pipelines ## Reference Files The ECS core, project setup, and the command set below are everything a first pass needs. Follow one link when the task calls for it — nothing under `references/` is loaded unless you open it. | Path you are on | File | Carries | |---|---|---| | Reading player input | [`references/input.md`](references/input.md) | `ButtonInput` keyboard/mouse polling, pressed vs just-pressed, cursor position, gamepad and rebinding pointers | | Loading assets, or driving the state machine | [`references/assets-and-states.md`](references/assets-and-states.md) | `AssetServer` handles and `LoadState` gating, `States` enum, `OnEnter`/`OnExit`/`run_if(in_state)`, `NextState` timing | | Decoupling two systems that must communicate | [`references/events.md`](references/events.md) | `#[derive(Event)]`, `EventWriter`/`EventReader`, `add_event` registration, the two-frame buffer and ordering caveat | | Laying out a growing game, or chasing frame time | [`references/project-architecture.md`](references/project-architecture.md) | Directory layout, plugin/marker-component organization, query-filter and profiling guidance, bundles and system sets | ## Key Capabilities **ECS Fundamentals** ```rust use bevy::prelude::*; // Components are plain data structs #[derive(Component)] struct Player; #[derive(Component)] struct Health(f32); #[derive(Component)] struct Velocity(Vec2); // Spawn entities with components fn spawn_player(mut commands: Commands) { commands.spawn(( Player, Health(100.0), Velocity(Vec2::ZERO), SpriteBundle { transform: Transform::from_xyz(0.0, 0.0, 0.0), ..default() }, )); } // Systems query for components fn move_player( time: Res