xr controller update now handles no controller entities
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use bevy::log::info;
|
||||
use bevy::log::{debug, info};
|
||||
use bevy::prelude::{
|
||||
Added, BuildChildren, Commands, Component, Entity, Query, Res, Transform, Vec3, With, Without,
|
||||
};
|
||||
@@ -74,8 +74,9 @@ pub fn update_open_xr_controllers(
|
||||
let left_grip_space = controller.grip_space(Hand::Left);
|
||||
let left_aim_space = controller.aim_space(Hand::Left);
|
||||
let left_postion = left_grip_space.0.pose.position.to_vec3();
|
||||
let left_aim_pose = left_controller_query.get_single_mut().unwrap().1;
|
||||
let left_aim_pose = left_controller_query.get_single_mut();
|
||||
match left_aim_pose {
|
||||
Ok(left_entity) => match left_entity.1 {
|
||||
Some(mut pose) => {
|
||||
*pose = AimPose(Transform {
|
||||
translation: left_aim_space.0.pose.position.to_vec3(),
|
||||
@@ -84,6 +85,8 @@ pub fn update_open_xr_controllers(
|
||||
});
|
||||
}
|
||||
None => (),
|
||||
},
|
||||
Err(_) => debug!("no left controlelr entity found"),
|
||||
}
|
||||
|
||||
left_controller_query
|
||||
@@ -99,8 +102,9 @@ pub fn update_open_xr_controllers(
|
||||
let right_aim_space = controller.aim_space(Hand::Right);
|
||||
let right_postion = right_grip_space.0.pose.position.to_vec3();
|
||||
|
||||
let right_aim_pose = right_controller_query.get_single_mut().unwrap().1;
|
||||
let right_aim_pose = right_controller_query.get_single_mut();
|
||||
match right_aim_pose {
|
||||
Ok(right_entity) => match right_entity.1 {
|
||||
Some(mut pose) => {
|
||||
*pose = AimPose(Transform {
|
||||
translation: right_aim_space.0.pose.position.to_vec3(),
|
||||
@@ -109,6 +113,8 @@ pub fn update_open_xr_controllers(
|
||||
});
|
||||
}
|
||||
None => (),
|
||||
},
|
||||
Err(_) => debug!("no right controlelr entity found"),
|
||||
}
|
||||
|
||||
right_controller_query
|
||||
|
||||
Reference in New Issue
Block a user