Don't add transforms to non-existent entities.

This commit is contained in:
Nolan Darilek 2023-04-01 10:37:22 -05:00
parent 865bdc333c
commit 0774599ef4

View File

@ -39,9 +39,15 @@ fn update(
} }
} }
fn removed(mut commands: Commands, mut removed: RemovedComponents<Volumetric>) { fn removed(
mut commands: Commands,
mut removed: RemovedComponents<Volumetric>,
transforms: Query<Entity, (With<Transform>, With<GlobalTransform>)>,
) {
for entity in &mut removed { for entity in &mut removed {
commands.entity(entity).insert(TransformBundle::default()); if transforms.get(entity).is_ok() {
commands.entity(entity).insert(TransformBundle::default());
}
} }
} }