bevyengine / bevyengine/bevy

Trigger::components() does not return the expected results

Open
#17,634 2 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Bug D-Modest S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## How can Bevy's documentation be improved?

The docs [here](https://github.com/bevyengine/bevy/blob/9bc0ae33c37728fc5215c833e3f4e78dc2abb7b9/crates/bevy_ecs/src/observer/mod.rs#L90) mention that the trigger components will be
```
the components that triggered the observer, out of the
/// components defined in `B`
```

That is not the observed behaviour
```
world.spawn(
Observer::new(|trigger: Trigger| {
dbg!(trigger.components());
})
);
let mut entity = world.spawn((A, B));
```

When the observer runs, the `trigger.components()` will contain the component ids for A and B.

Contributor guide

Open the contributing guide

Research direction

Read the observer documentation in crates/bevy_ecs/src/observer/mod.rs around the linked section, then run the provided Observer::new and world.spawn((A, B)) reproducer. Compare the documented Trigger::components() behavior with the observed component IDs and update the documentation so it accurately describes the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation, game-dev
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.