From 0662f88fdde4616acfcd92c741fecf08fbcafb63 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 31 Mar 2024 05:13:21 +0200 Subject: [PATCH] play collision sound only on start of collision --- src/actor.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 61a3d07..d962963 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -561,13 +561,13 @@ pub fn handle_chat_scripts( } fn handle_collisions( - mut collision_event_reader: EventReader, + mut collision_event_reader: EventReader, mut ew_sfx: EventWriter, q_player: Query>, ) { if let Ok(player) = q_player.get_single() { - for Collision(contacts) in collision_event_reader.read() { - if contacts.entity1 == player || contacts.entity2 == player { + for CollisionStarted(entity1, entity2) in collision_event_reader.read() { + if *entity1 == player || *entity2 == player { ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Crash)); } }