Skip to content

Commit

Permalink
fix pose offset
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Sep 25, 2024
1 parent 9526a21 commit 935ec25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ impl Plugin for VrControllerPlugin {
input::xr::read_xr_input,
),
movement::void_teleport,
movement::apply_xr_pose,
movement::move_player,
movement::move_xr_root,
),
Expand Down
33 changes: 9 additions & 24 deletions src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,26 @@ pub fn move_player(
*last_time = time.elapsed_seconds();
}

pub fn apply_xr_pose(
mut players: Query<
(&mut Transform, &PlayerHeight),
(With<PlayerBody>, Without<XrTrackingRoot>),
>,
pub fn move_xr_root(
player: Query<(&Transform, &PlayerHeight), (With<PlayerBody>, Without<XrTrackingRoot>)>,
mut xr_root: Query<&mut Transform, (With<XrTrackingRoot>, Without<PlayerBody>)>,
views: Res<OxrViews>,
) {
let Some(view) = views.first() else {
let Ok(mut root_tr) = xr_root.get_single_mut() else {
return;
};

for (mut player_tr, player_height) in players.iter_mut() {
// player_tr.translation += view.pose.position.to_vec3();
// player_tr.translation.y -= player_height.0 / 2.0;
}
}

pub fn move_xr_root(
players: Query<(&Transform, &PlayerHeight), (With<PlayerBody>, Without<XrTrackingRoot>)>,
mut xr_root: Query<&mut Transform, (With<XrTrackingRoot>, Without<PlayerBody>)>,
views: Res<OxrViews>,
) {
let Some(view) = views.first() else {
let Ok((player_tr, player_height)) = player.get_single() else {
return;
};

let Ok(mut root_tr) = xr_root.get_single_mut() else {
let Some(view) = views.first() else {
return;
};

for (player_tr, player_height) in players.iter() {
root_tr.translation = player_tr.translation;
root_tr.translation.y -= player_height.0 / 2.0;
// root_tr.translation -= view.pose.position.to_vec3();
}
root_tr.translation = player_tr.translation;
root_tr.translation.y += player_height.0 / 3.0;
root_tr.translation -= view.pose.position.to_vec3();
}

pub fn void_teleport(
Expand Down

0 comments on commit 935ec25

Please sign in to comment.