-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spawning duplicate components is inconsistent #6622
Comments
For your first example, how would do you propose we handle: .spawn((TransformBundle {transform: Transform::from_xyz(10, 20, 30),
SpatialBundle {transform: Transform::from_xyz(30, 20, 10)})); There's no meaningful sense by which not erroring can be the correct behaviour when completing the inserting in a single call, because there is no ordering within a (Allowing it when both are exactly the If the issue is with it being inconsistent, perhaps we should make both versions panic? |
A few things:
For this particular example, it is fine, but when you have two distinct bundles with a matching component, especially from 3rd party crates, it becomes quickly intractable. I'd be strongly against panicking in all case as long as the error message is not more helpful. I'll give more concrete example where I hit this issue, but it's already late for me so I'll have to leave that for tomorrow. |
#6660 contains a compelling use case for non-panicking duplicate components. Reproducing here.
|
I think the current behavior should be the one adopted. I think the only thing necessary would be to document the behavior |
Bevy version
Bevy 0.9.0 / 7231e00
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
andTransformBundle
have aTransform
andGlobalTransform
. When spawning them together with aspawn(<TUPLE>)
, it panics, but if I spawn them separately, it doesn't panic:What I expect
I expect neither version to panic.
The text was updated successfully, but these errors were encountered: