Add asteroid destruction sound

This commit is contained in:
2025-12-17 16:18:31 -06:00
parent ae093d2c9c
commit d7802bdbed
3 changed files with 14 additions and 2 deletions

View File

@@ -115,6 +115,7 @@ pub fn split_asteroids(
mut respawn_events: MessageWriter<SpawnAsteroid>,
mut commands: Commands,
query: Query<(&Transform, &Asteroid, &Velocity)>,
game_assets: Res<GameAssets>,
) {
for event in destroy_events.read() {
if let Ok((transform, rock, velocity)) = query.get(event.0) {
@@ -137,6 +138,12 @@ pub fn split_asteroids(
// Always despawn the asteroid. New ones (may) be spawned in it's
// place, but this one is gone.
commands.entity(event.0).despawn();
// Play a sound for the asteroid exploding
commands.spawn((
AudioPlayer::new(game_assets.asteroid_crack_sound()),
PlaybackSettings::DESPAWN,
));
}
}
}