Replies: 1 comment
-
You can use a fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_event::<MyEvent>()
.add_system(sender.before(LabelBoth))
.add_system(both.label(LabelBoth))
.add_system(receiver.after(LabelBoth))
.run();
}
struct MyEvent(&'static str);
#[derive(SystemLabel)]
struct LabelBoth;
fn sender(mut writer: EventWriter<MyEvent>) {
writer.send(MyEvent("one"));
}
fn both(mut events: ParamSet<(EventReader<MyEvent>, EventWriter<MyEvent>)>) {
for event in events.p0().iter() {
println!("from both {}", event.0);
}
events.p1().send(MyEvent("two"));
}
fn receiver(mut reader: EventReader<MyEvent>) {
for event in reader.iter() {
println!("from receiver {}", event.0);
}
} This will continuously print:
Because the Alternatives:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, I have an entity that sends an event when it changes to propagate the change to the close entities and those entities do the same in a recursive way
I tried doing
But that yields an error
ResMut<bevy_ecs::event::Events<wfc::ChangeEvent>> in system wfc::propagate_on_change conflicts with a previous Res<bevy_ecs::event::Events<wfc::ChangeEvent>>
How should I do it? Maybe is a XY problem, but I can't think of a way of doing it.
Beta Was this translation helpful? Give feedback.
All reactions