Skip to content

Commit

Permalink
Clear camera descendants on screen exit
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Jul 26, 2024
1 parent 51cf571 commit 10ff7e1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use serde::Serialize;

use crate::core::pause::Pause;
use crate::core::UpdateSet;
use crate::screen::Screen;
use crate::util::prelude::*;

pub(super) fn plugin(app: &mut App) {
Expand Down Expand Up @@ -50,6 +51,7 @@ impl Configure for CameraRoot {
fn configure(app: &mut App) {
app.register_type::<Self>();
app.init_resource::<Self>();
app.add_systems(StateFlush, Screen::ANY.on_exit(clear_camera_root));
}
}

Expand Down Expand Up @@ -78,6 +80,10 @@ impl FromWorld for CameraRoot {
}
}

fn clear_camera_root(mut commands: Commands, camera_root: Res<CameraRoot>) {
commands.entity(camera_root.primary).despawn_descendants();
}

#[derive(Component, Reflect)]
#[reflect(Component)]
pub struct SmoothFollow {
Expand Down

0 comments on commit 10ff7e1

Please sign in to comment.