From 78d36aa4d216e0308619ebfb9366437669c7e0c3 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 19 Jan 2022 16:36:04 -0600 Subject: [PATCH] Add additional constraints for listener. --- src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fe47b58..9ecd6fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -266,9 +266,9 @@ impl DerefMut for GlobalEffects { fn update_listener( context: ResMut, - query: Query<(&Listener, Option<&Transform>, Option<&GlobalTransform>)>, + listener: Query<(Option<&Transform>, Option<&GlobalTransform>), With>, ) { - for (_, transform, global_transform) in query.iter() { + if let Ok((transform, global_transform)) = listener.get_single() { let transform: Option = global_transform .map(|v| { let transform: Transform = (*v).into(); @@ -293,6 +293,9 @@ fn update_listener( context.set_position([0., 0., 0.]).ok(); context.set_orientation(([0., 0., 1.], [0., 1., 0.])).ok(); } + } else { + context.set_position([0., 0., 0.]).ok(); + context.set_orientation(([0., 0., 1.], [0., 1., 0.])).ok(); } }