-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
Bevy version
v0.16.0
What you did
Code:
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_observer(foo)
.add_systems(Startup, setup)
.add_systems(Update, update)
.run();
}
#[derive(Component)]
struct A;
fn foo(t: Trigger<OnRemove, A>, q: Query<Has<A>>) {
println!("foo: {:?}", q.get(t.target()));
}
fn setup(mut commands: Commands) {
commands.spawn(A);
}
fn update(mut commands: Commands, q: Query<Entity, With<A>>, time: Res<Time>) {
if time.elapsed_secs() > 2.0 {
for entity in q.iter() {
commands.entity(entity).remove::<A>();
}
}
}What went wrong
When the component A is removed from the entity, the observer foo is correctly triggered. However, the Has<A> in query still reports true. This is a MRE, my actual implementation is way complicated, solely relay on OnRemove to tell if the component presents in my case is impossible, unless I totally rewrite that part of the logics (which is probably the only workaround, AFAIK).
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished