bevyengine / bevyengine/bevy

Allow multiple `children!` in one bundle

Open
#19,398 7 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Usability D-Complex S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?
```
commands.spawn((
children![],
children![],
));
```

currently crash with `has duplicate components: bevy_ecs::hierarchy::Children`

## What solution would you like?

Allow multiple `bevy_ecs::hierarchy::Children` and merge them.

maybe some component can have a "merge strategy" instead of panic.

or maybe it will be solved as part of bsn?

## What alternative(s) have you considered?

## Additional context

I want to have this:
```
pub fn children_opt(opt: Option) -> impl Bundle {
Children::spawn(
SpawnIter(opt.into_iter())
)
}
pub fn two_opt_children_bundle(
) -> impl Bundle {
(
children_opt(Some(Name::new("c1"))),
children_opt(Some(Name::new("c2")))
)
}
```

Also if we can do this then it gives an alternative solution to https://github.com/bevyengine/bevy/issues/18953, you can have the cfg outside one `children!` marco, and have another one.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how children! bundles are assembled and where duplicate components cause the reported panic. Determine how multiple Children components should be combined, including the proposed merge-strategy alternative, and verify that multiple child bundles no longer fail while existing bundle behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.