Query Sets

For safety reasons, a system cannot have multiple queries with mutability conflicts on the same components.

Bevy provides a solution: wrap them in a QuerySet:

fn reset_health(
    // access the health of enemies and the health of players
    // (note: some entities could be both!)
    mut q: QuerySet<(
        Query<&mut Health, With<Enemy>>,
        Query<&mut Health, With<Player>>
) {
    // set health of enemies
    for mut health in q.q0_mut().iter_mut() {
        health.hp = 50.0;

    // set health of players
    for mut health in q.q1_mut().iter_mut() {
        health.hp = 100.0;

This ensures only one of the conflicting queries can be used at the same time.

The maximum number of queries in a query set is 4.