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).
Bevy version
v0.16.0
What you did
Code:
What went wrong
When the component
Ais removed from the entity, the observerfoois correctly triggered. However, theHas<A>in query still reportstrue. This is a MRE, my actual implementation is way complicated, solely relay onOnRemoveto 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).