Spawning related entities in an OnAdd
observer downstream of a World::spawn
in a Command
causes a crash
#18452
Labels
A-ECS
Entities, components, systems, and events
C-Bug
An unexpected or incorrect behavior
P-Regression
Functionality that used to work but no longer does. Add a test for this!
S-Needs-Investigation
This issue requires detective work to figure out what's going wrong
Milestone
Bevy version
main
What you did
Created an
OnAdd
observer for a component that adds related (ChildOf
) entities usingCommands
. Then, spawn an entity with that component in an implementation ofCommand::apply
usingWorld::spawn
. Here is the MRE (excludingApp
creation and observer/system insertion):What went wrong
It is claimed that the entity doesn't exist. The following error is emitted, and the app crashes:
Additional information
The same thing happens with
on_add
hooks directly on the component as opposed to an observer. If I spawn the component usingCommands
instead ofWorld
, it works as expected.In version 0.15.x, I was able to perform spawning using this exact pattern without this error.
The text was updated successfully, but these errors were encountered: