Add bullet on-impact despawning system
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user