Add bullet/laser sound

Firing the weapon now makes a sound. I've implemented this by spawning
the playback component on the bullet rather than the gun. This seemed
easier than figuring out how to reset a playback component that lives on
the ship entity -- although thats probably better for memory access
patterns.
This commit is contained in:
2025-12-17 14:29:57 -06:00
parent 3963b548b9
commit ae093d2c9c
3 changed files with 11 additions and 2 deletions

View File

@@ -199,6 +199,8 @@ fn input_ship_shoot(
MeshMaterial2d(game_assets.bullet().1),
ship_pos.clone(), // clone ship transform
Lifetime(Timer::from_seconds(BULLET_LIFETIME, TimerMode::Once)),
AudioPlayer::new(game_assets.laser_sound()),
PlaybackSettings::ONCE, // `Lifetime` already despawns the entity, so this doesn't need to
));
}
}