Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[programming/events] include the need to register your system #277

Open
Zarthus opened this issue Apr 6, 2024 · 0 comments
Open

[programming/events] include the need to register your system #277

Zarthus opened this issue Apr 6, 2024 · 0 comments

Comments

@Zarthus
Copy link

Zarthus commented Apr 6, 2024

In https://bevy-cheatbook.github.io/programming/events.html, it was unclear to me that I also needed to trigger the event (e.g. using an Update or FixedUpdate), my silly assumption was that Bevy would automatically know if the EventReader<T> has been filled if an EventWriter<T> sends one and that it doesn't need periodic running. (and that it was handled with app.add_event::<>(); and the reading functions somehow magically discovered.)

For it to click for me, I had to refer to the official example (https://github.com/bevyengine/bevy/blob/v0.13.0/examples/ecs/event.rs) which registers the function too as a system.

While it is written in the "usage advice", it kind of flew over my head.

I'd suggest a simple enhancement here

You need to register your custom event types via the [app builder][cb::app]:
```rust,no_run,noplayground
{{#include ../code013/src/programming/events.rs:events-appbuilder}}
```

to the sorts of something like this:

As well as register the system

app.add_systems(Update, debug_levelups);

I love the book, it's been super helpful :) this is the only pitfall I fell into so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant