hit sounds and general sound effects sys

This commit is contained in:
2025-03-16 20:37:13 +01:00
parent 4fdd15d765
commit 7241f30094
10 changed files with 68 additions and 35 deletions

View File

@@ -1,4 +1,6 @@
use crate::{billboards::Billboard, player::Player, squish_animation::SquishAnimation};
use crate::{
billboards::Billboard, player::Player, sounds::PlaySound, squish_animation::SquishAnimation,
};
use avian3d::prelude::*;
use bevy::prelude::*;
use std::f32::consts::PI;
@@ -46,7 +48,6 @@ fn collect_key(
mut collision_event_reader: EventReader<CollisionStarted>,
query_player: Query<&Player>,
query_collectable: Query<&Key>,
asset_server: Res<AssetServer>,
) {
for CollisionStarted(e1, e2) in collision_event_reader.read() {
let collectable = if query_player.contains(*e1) && query_collectable.contains(*e2) {
@@ -59,11 +60,7 @@ fn collect_key(
let key = query_collectable.get(collectable).unwrap();
commands.spawn((
AudioPlayer::new(asset_server.load("sfx/effects/key_collect.ogg")),
PlaybackSettings::DESPAWN,
));
commands.trigger(PlaySound::KeyCollect);
commands.trigger(KeyCollected(key.0.clone()));
commands.entity(collectable).despawn_recursive();
}