jet engine sound

closes HEZ-32
This commit is contained in:
2025-04-14 00:10:28 +02:00
parent 33ddac2f18
commit 2e5ec8f3d8
3 changed files with 14 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ use crate::{
heads::HeadChanged,
heads_database::{HeadControls, HeadsDatabase},
hitpoints::Hitpoints,
loading_assets::GameAssets,
loading_assets::{AudioAssets, GameAssets},
physics_layers::GameLayer,
sounds::PlaySound,
tb_entities::SpawnPoint,
@@ -203,6 +203,7 @@ fn on_update_head(
head: Query<Entity, With<PlayerHeadMesh>>,
mut player_head: Query<&mut ActiveHead, With<Player>>,
head_db: Res<HeadsDatabase>,
audio_assets: Res<AudioAssets>,
) {
let Ok(head) = head.get_single() else {
return;
@@ -218,6 +219,7 @@ fn on_update_head(
commands.trigger(PlaySound::Head(head_str.to_string()));
//TODO: load from dynamic asset collection? or keep lazy?
let mesh = asset_server
.load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", head_str)));
@@ -230,6 +232,14 @@ fn on_update_head(
commands
.entity(head)
.with_child((Transform::from_xyz(0., -1., 0.), SceneRoot(mesh)));
.with_child((Transform::from_xyz(0., -1., 0.), SceneRoot(mesh)))
.with_child((
Name::new("sfx"),
AudioPlayer::new(audio_assets.jet.clone()),
PlaybackSettings {
mode: bevy::audio::PlaybackMode::Loop,
..Default::default()
},
));
}
}