Skip to content

Entity Markers #6556

Description

@DasLixou

What problem does this solve or what need does it fill?

A Marker trait that can mark an entity. example

#[derive(Marker)]
pub enum Players {
    Red,
    Blue,
    Green,
}

then we can assign an entity with a marker

commands.spawn(PlayerBundle::default()).mark(Players::Red);

and we can easily query players

fn add_items_to_red_and_blue(red_query: Query<Player, Or<MarkedAs<Players::Red>>, MarkedAs<Players::Blue>>>) {
    // ...
}

What solution would you like?

An Marker that works like a Resource but holds a EntityID and the Marker can be used in Queries.

What alternative(s) have you considered?

Manually make Resources holding EntityIDs and then using a normal query and using .get with the entityID from the resource.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useX-Needs-SMEThis type of work requires an SME to approve it.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions