bevyengine / bevyengine/bevy

Spawning duplicate components is inconsistent

Open
#6,622 4 comments 0 reactions 0 assignees View on GitHub
A-ECS C-Bug C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

Bevy 0.9.0 / 7231e00507

## What I did

Since the addition of `Bundle`/`Component` agnostic spawns, the way bevy handles duplicate components is inconsistent.

Depending on how components are spawned, it either leads to a panic or just the first value of the component being overwritten.

Here, both `SpatialBundle` and `TransformBundle` have a `Transform` and `GlobalTransform`. When spawning them together with a `spawn()`, it panics, but if I spawn them separately, it doesn't panic:

```rust
// THIS PANICKS!!!
commands.spawn((
TransformBundle::default(),
SpatialBundle::default(),
))
// THIS just overwrites the GlobalTransform and Transform components
commands.spawn(TransformBundle::default())
.insert(SpatialBundle::default())
```

## What I expect

I expect neither version to panic.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the two `commands.spawn` examples using `TransformBundle` and `SpatialBundle`; compare duplicate-component handling in tuple spawning with the separate `insert` path. Trace the Bundle/Component-agnostic spawn behavior, then verify that neither example panics and that duplicate components follow consistent behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.