Proposal: Improve diagnostics when multi-component structs are incorrectly derived as Component instead of Bundle #24169
not-null-nil
started this conversation in
Ideas
Replies: 1 comment
-
|
I would argue that even one component might be confusing given discussions like this one. Anyway, I believe you could do it by adding a method on |
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.
-
Summary
In Bevy ECS, it is easy to accidentally define a struct that looks like a Bundle but is incorrectly derived as Component, which leads to silent logic failures at runtime (e.g. Query<..., With> returning empty results).
This pattern produces no compile-time or runtime warnings, yet results in invalid entity composition.
Minimal example
Spawn:
Query:
Query<(Entity, &HexCoord), With<Enemy>>Result:
Query returns empty
No warnings or errors
Root cause is non-obvious in larger codebases
Expected behavior
When a struct:
has multiple fields
and all fields implement Component
but is derived as Component
It is likely intended to be a Bundle.
Why this matters
This pattern is:
very easy to make
hard to debug
produces silent ECS mismatch (no entities in query)
It becomes especially problematic in:
large component-heavy architectures
gameplay prototyping phases
systems relying heavily on With filtering
Beta Was this translation helpful? Give feedback.
All reactions