File tree 1 file changed +10
-2
lines changed
crates/bevy_transform/src/components
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ impl FromWorld for Parent {
22
22
23
23
impl MapEntities for Parent {
24
24
fn map_entities ( & mut self , entity_map : & EntityMap ) -> Result < ( ) , MapEntitiesError > {
25
- self . 0 = entity_map. get ( self . 0 ) ?;
25
+ // Parent of an entity in the new world can be in outside world, in which case it
26
+ // should not be mapped.
27
+ if let Ok ( mapped_entity) = entity_map. get ( self . 0 ) {
28
+ self . 0 = mapped_entity;
29
+ }
26
30
Ok ( ( ) )
27
31
}
28
32
}
@@ -47,7 +51,11 @@ pub struct PreviousParent(pub(crate) Entity);
47
51
48
52
impl MapEntities for PreviousParent {
49
53
fn map_entities ( & mut self , entity_map : & EntityMap ) -> Result < ( ) , MapEntitiesError > {
50
- self . 0 = entity_map. get ( self . 0 ) ?;
54
+ // PreviousParent of an entity in the new world can be in outside world, in which
55
+ // case it should not be mapped.
56
+ if let Ok ( mapped_entity) = entity_map. get ( self . 0 ) {
57
+ self . 0 = mapped_entity;
58
+ }
51
59
Ok ( ( ) )
52
60
}
53
61
}
You can’t perform that action at this time.
0 commit comments