Add bullet on-impact despawning system

This commit is contained in:
2025-08-10 18:43:56 -05:00
parent 364fbd7530
commit cdd665cc93
2 changed files with 10 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
use crate::{
AngularVelocity, GameAssets,
event::BulletDestroy,
physics::{Velocity, Wrapping},
};
@@ -35,3 +36,11 @@ pub fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
.with_translation(Vec3::new(-0.5, 0.0, -0.1)),
));
}
/// Watch for [`BulletDestroy`] events and despawn
/// the associated bullet.
pub fn bullet_impact_listener(mut commands: Commands, mut events: EventReader<BulletDestroy>) {
for event in events.read() {
commands.entity(event.0).despawn();
}
}