#checking if a component is inside of an entity

4 messages · Page 1 of 1 (latest)

frail raven
#

How do I check if a component is inside of an entity?

placid hill
#

What's the context? If you are Querying, you can query for Option<&Component> and then just check if the option is None.

#

Or if you have an Entity already and just want to know if it has a component, you could add another query to your system like

fn my_system(with_component: Query<(), With<Component>>) {
    // ... obtain an `entity: Entity`
    if with_component.contains(entity) {
        // ...
    }
}
frail raven
#

oh ok thank you