Inconsistent behaviour when using SpawnRelated with Observers
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 4d 8m
- Merged PRs (30d)
- 147
Description
## Bevy version and features
Main: `71114e1`
## What you did
Spawning related entities using `SpawnRelated` is inconsistent with `Insert/Add` observers.
```rust
fn print_name(
insert: On,
names: Query<&Name>,
) -> Result<(), BevyError> {
let name = names.get(insert.entity)?;
dbg!(name);
}
fn spawn_widgets(
mut commands: Commands
) {
commands.spawn((
UiRoot,
// This will panic
children!(
(Button, Name::new("Special Button")),
),
// This will not panic
Children::spawn_one((Button, Name::new("Different Button"))),
// And neither will this
Children::spawn(SpawnRelated(|parent: &mut RelatedSpawner| {
parent.spawn((Slider, Name::new("Interesting Slider"));
})
));
}
```
## What went wrong
When using `children!()` it will panic with `The query does not match entity (...)`.
Contributor guide
Assessment
This issue has not been assessed yet.