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:
@@ -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
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user