play collision sound only on start of collision
This commit is contained in:
parent
852dd79657
commit
0662f88fdd
|
@ -561,13 +561,13 @@ pub fn handle_chat_scripts(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_collisions(
|
fn handle_collisions(
|
||||||
mut collision_event_reader: EventReader<Collision>,
|
mut collision_event_reader: EventReader<CollisionStarted>,
|
||||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
q_player: Query<Entity, With<PlayerCamera>>,
|
q_player: Query<Entity, With<PlayerCamera>>,
|
||||||
) {
|
) {
|
||||||
if let Ok(player) = q_player.get_single() {
|
if let Ok(player) = q_player.get_single() {
|
||||||
for Collision(contacts) in collision_event_reader.read() {
|
for CollisionStarted(entity1, entity2) in collision_event_reader.read() {
|
||||||
if contacts.entity1 == player || contacts.entity2 == player {
|
if *entity1 == player || *entity2 == player {
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Crash));
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Crash));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue