ECS examples
The engine's ECS examples: what each one shows, whether it runs in a browser and the command that runs it.
Entities, components, systems, queries, change detection, messages, observers, hooks, relationships and schedules. There are 35 examples on this page. For the concepts behind them, see ECS.
Run any of them from the engine core's workspace (the folder of the engine source that holds the neo crate's Cargo.toml); see Run an example.
Examples#
| Example | What it shows | Web | Run |
|---|---|---|---|
| Callbacks | Store arbitrary systems in components and run them on demand | Yes | cargo run --example callbacks |
| Change Detection | Change detection on components and resources | No | cargo run --example change_detection --features track_location |
| Component Hooks | Define component hooks to manage component lifecycle events | No | cargo run --example component_hooks |
| Contiguous Query | Demonstrates contiguous queries | No | cargo run --example contiguous_query |
| Custom Executor | Demonstrates how to make a custom SystemExecutor | No | cargo run --example custom_executor |
| Custom Query Parameters | Groups commonly used compound queries and query filters into a single type | No | cargo run --example custom_query_param |
| Custom Schedule | Demonstrates how to add custom schedules | No | cargo run --example custom_schedule |
| Delayed Commands | Demonstrates how to schedule ECS commands with a delay | Yes | cargo run --example delayed_commands |
| Dynamic ECS | Dynamically create components, spawn entities with those components and query those components | No | cargo run --example dynamic --features debug |
| ECS Guide | Full guide to NEO's ECS | No | cargo run --example ecs_guide |
| Entity disabling | Demonstrates how to hide entities from the ECS without deleting them | Yes | cargo run --example entity_disabling |
| Error handling | How to return and handle errors across the ECS | No | cargo run --example error_handling --features mesh_picking |
| Extraction | Demonstrates different ways of extracting components, copying them from the main world to the render world | No | cargo run --example extraction |
| Fallible System Parameters | Systems are skipped if their parameters cannot be acquired | No | cargo run --example fallible_params |
| Fixed Timestep | Shows how to create systems that run every fixed timestep, rather than every tick | No | cargo run --example fixed_timestep |
| Generic System | Shows how to create systems that can be reused with different types | No | cargo run --example generic_system |
| Hierarchy | Creates a hierarchy of parents and children entities | No | cargo run --example hierarchy |
| Hotpatching Systems | Demonstrates how to hotpatch systems | No | cargo run --example hotpatching_systems --features hotpatching |
| Immutable Components | Demonstrates the creation and utility of immutable components | No | cargo run --example immutable_components |
| Iter Combinations | Shows how to iterate over combinations of query results | Yes | cargo run --example iter_combinations |
| Message | Illustrates message creation, activation, and reception | No | cargo run --example message |
| Nondeterministic System Order | Systems run in parallel, but their order isn't always deterministic. Here's how to detect and fix this. | No | cargo run --example nondeterministic_system_order |
| Observer Propagation | Demonstrates event propagation with observers | Yes | cargo run --example observer_propagation |
| Observers | Demonstrates observers that react to events (both built-in life-cycle events and custom events) | Yes | cargo run --example observers |
| One Shot Systems | Shows how to flexibly run systems without scheduling them | No | cargo run --example one_shot_systems |
| Parallel Query | Illustrates parallel queries with ParallelIterator | No | cargo run --example parallel_query |
| Relationships | Define and work with custom relationships between entities | No | cargo run --example relationships |
| Removal Detection | Query for entities that had a specific component removed earlier in the current frame | No | cargo run --example removal_detection |
| Run Conditions | Run systems only when one or multiple conditions are met | No | cargo run --example run_conditions |
| Startup System | Demonstrates a startup system (one that runs once when the app starts up) | No | cargo run --example startup_system |
| State Scoped | Shows how to spawn entities that are automatically despawned either when entering or exiting specific game states. | No | cargo run --example state_scoped |
| System Closure | Show how to use closures as systems, and how to configure Local variables by capturing external state | No | cargo run --example system_closure |
| System Parameter | Illustrates creating custom system parameters with SystemParam | No | cargo run --example system_param |
| System Piping | Pipe the output of one system into a second, allowing you to handle any errors gracefully | No | cargo run --example system_piping |
| System Stepping | Demonstrate stepping through systems in order of execution. | No | cargo run --example system_stepping --features neo_debug_stepping |