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,11 +39,17 @@ 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 {
if transforms.get(entity).is_ok() {
commands.entity(entity).insert(TransformBundle::default());
}
}
}
pub struct VolumetricPlugin;