#[derive(Bundle)] #[bundle(ignore_from_components)] Bundle spawns with Empty Children List
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version and features
bevy = { version = "0.18.0", features = ["debug"] }
## What you did
`#[derive(Bundle)]` is not behaving as I would expect with a bundle struct defined as:
```rust
#[derive(Bundle)]
#[bundle(ignore_from_components)]
pub struct PipeBundle {
pub pipe: Pipe,
pub name: Name,
pub visibility: Visibility,
pub transform: Transform,
pub children: SpawnRelatedBundle<
ChildOf,
(
Spawn,
Spawn,
Spawn,
),
>,
}
impl PipeBundle {
pub fn new(asset_server: Res, position: f32) -> Self {
Self {
...
children: children![
PipeTopBundle { ... },
PipeGateBundle { ... },
PipeBottomBundle { ... },
],
}
}
}
```
## What went wrong
If used in `commands.spawn(PipeBundle::new(asset_server, gap_y_position));` it will produce a Entity that has it's own components and a empty children list
I can confirm that if instead of using the struct I use a common tuple with the exact same contents then the Entity spawns correctly with all its children.
## Additional information
Doing some looking into the definition of the derive macro I noticed that ` unsafe fn apply_effect( ... ) {}`, which I believe is responsible for spawning the children, has a empty function body.
Contributor guide
Research direction
Start with the #[derive(Bundle)] implementation and inspect the generated apply_effect function mentioned in the report. Reproduce the issue with commands.spawn(PipeBundle::new(...)) and compare it with the equivalent tuple bundle; done means the derived bundle spawns the expected children instead of an empty children list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100