-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Observers and hooks doesn't pair well with mapped entities #14465
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsA-NetworkingSending data between clients, servers and machinesSending data between clients, servers and machinesA-ScenesComposing and serializing ECS objectsComposing and serializing ECS objectsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsA-NetworkingSending data between clients, servers and machinesSending data between clients, servers and machinesA-ScenesComposing and serializing ECS objectsComposing and serializing ECS objectsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Type
Projects
Status
No status
Bevy version
v0.14.0
What you did
I have a component that stores an entity. The component implements and reflects
MapEntities, so on scene deserialization it automatically maps entities inside it.What went wrong
When I implement
on_addhook orOnAddobserver for such component, it triggers beforeMapEntitieswhich results in invalid entity access.It happens because we insert components here:
bevy/crates/bevy_scene/src/scene.rs
Lines 117 to 123 in eabb58a
But entities mapped later:
bevy/crates/bevy_scene/src/scene.rs
Lines 128 to 131 in eabb58a
I think we should map entities before the insertion.