Skip to content

#[derive(Bundle)] #[bundle(ignore_from_components)] Bundle spawns with Empty Children List #22756

@RubberEyes

Description

@RubberEyes

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:

#[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<PipeTopBundle>,
            Spawn<PipeGateBundle>,
            Spawn<PipeBottomBundle>,
        ),
    >,
}

impl PipeBundle {
    pub fn new(asset_server: Res<AssetServer>, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions