Tainted\\Coders

Iterate over all entities in a world

Bevy version: 0.18Last updated:

We can use an EntityRef by using an exclusive system and reading directly from the world.

An EntityRef is a read-only reference to an Entity and its components.

fn do_crazy_things(world: &mut World) {
  // we can do anything with any data in the Bevy ECS here!
  let mut query = world.query::<EntityRef>();

  for entity_ref in query.iter(world) {
    // ...
  }
}

This type of system cannot run in parallel and should run at the end of all other systems. Its performance will be limited.