The goal of this document is to provide the maximum amount of important content in the minimum amount of words. It can be useful to give this to your language model to give it an up to date source of information about Bevy.The full text of this document in markdown can be found on the Bevy starterBevy is an archetype Entity-Component-System (ECS) game engine built in Rust. It emphasizes modularity, performance, and ease of use.Entity and ComponentsAn Entity on its own holds no data or behavior. The actual Entity is just an identifier to find associated components where the real data is stored.Each Entity can only have a single Component of each type. These components can be added and removed dynamically over the course of the entity's lifetime. Everything is stored inside a World and everything is managed by the App.A good mental model to use is that entities represent a row in an in-memory database, while components are our columns.Entities An identifier for a rowComponents A column in a rowSystems All the behaviorWe define components by deriving the Component trait:#[derive(Component)] struct Player; #[derive(Component)] enum Ship { Destroyer, Cruiser, Battleship, } #[derive(Component)] struct Health(f32); #[derive(Component)] #[component(on_add = on_position_added)] struct Position { x: i32, y: i32, } Components have 5 different life-cycle hooks we can use to handle side effects that need to happen:#[component(on_add = on_add_function)]#[component(on_insert = on_insert_function)]#[component(on_replace = on_replace_function)]#[component(on_remove = on_remove_function)]#[component(on_despawn = on_despawn_function)]Components can also be required by other components#[derive(Component)] #[require(Position, Ship)] struct Player; fn spawn_player_with_required_components( mut commands: Commands ) { commands.spawn(Player); } When a component is spawned, if it has any required components, it will automatically add them unless we override them. The only requirement is that...
First seen: 2025-10-19 01:59
Last seen: 2025-10-19 02:59