fix position/rotation after exiting vehicle
This commit is contained in:
parent
2f060a3250
commit
8531a9b8c1
|
@ -5,7 +5,7 @@ use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
|
||||||
use bevy::core_pipeline::tonemapping::Tonemapping;
|
use bevy::core_pipeline::tonemapping::Tonemapping;
|
||||||
use bevy::pbr::CascadeShadowConfigBuilder;
|
use bevy::pbr::CascadeShadowConfigBuilder;
|
||||||
use bevy::transform::TransformSystem;
|
use bevy::transform::TransformSystem;
|
||||||
use bevy::math::DVec3;
|
use bevy::math::{DVec3, DQuat};
|
||||||
use bevy_xpbd_3d::prelude::*;
|
use bevy_xpbd_3d::prelude::*;
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
use crate::{settings, audio, actor};
|
use crate::{settings, audio, actor};
|
||||||
|
@ -113,8 +113,8 @@ pub fn handle_input(
|
||||||
fn manage_player_actor(
|
fn manage_player_actor(
|
||||||
settings: Res<settings::Settings>,
|
settings: Res<settings::Settings>,
|
||||||
mut q_playercam: Query<&mut Visibility, With<actor::PlayerCamera>>,
|
mut q_playercam: Query<&mut Visibility, With<actor::PlayerCamera>>,
|
||||||
mut q_hiddenplayer: Query<(&mut Visibility, &mut Transform, &mut LinearVelocity, &mut AngularVelocity), (With<actor::Player>, Without<actor::PlayerCamera>)>,
|
mut q_hiddenplayer: Query<(&mut Visibility, &mut Position, &mut Rotation, &mut LinearVelocity, &mut AngularVelocity), (With<actor::Player>, Without<actor::PlayerCamera>)>,
|
||||||
q_ride: Query<(&Transform, &LinearVelocity, &AngularVelocity), (With<actor::PlayerDrivesThis>, Without<actor::Player>)>,
|
q_ride: Query<(&Transform, &Position, &Rotation, &LinearVelocity, &AngularVelocity), (With<actor::PlayerDrivesThis>, Without<actor::Player>)>,
|
||||||
) {
|
) {
|
||||||
for mut vis in &mut q_playercam {
|
for mut vis in &mut q_playercam {
|
||||||
if settings.third_person {
|
if settings.third_person {
|
||||||
|
@ -124,11 +124,11 @@ fn manage_player_actor(
|
||||||
*vis = Visibility::Hidden;
|
*vis = Visibility::Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (mut vis, mut trans, mut v, mut angv) in &mut q_hiddenplayer {
|
for (mut vis, mut pos, mut rot, mut v, mut angv) in &mut q_hiddenplayer {
|
||||||
*vis = Visibility::Hidden;
|
*vis = Visibility::Hidden;
|
||||||
if let Ok((ride_trans, ride_v, ride_angv)) = q_ride.get_single() {
|
if let Ok((ride_trans, ride_pos, ride_rot, ride_v, ride_angv)) = q_ride.get_single() {
|
||||||
trans.translation = ride_trans.translation + Vec3::new(0.0, 0.0, 10.0);
|
pos.0 = ride_pos.0 + DVec3::from(ride_trans.rotation * Vec3::new(0.0, 0.0, 10.0));
|
||||||
trans.rotation = ride_trans.rotation;
|
rot.0 = ride_rot.0 * DQuat::from_array([-1.0, 0.0, 0.0, 0.0]);
|
||||||
*v = ride_v.clone();
|
*v = ride_v.clone();
|
||||||
*angv = ride_angv.clone();
|
*angv = ride_angv.clone();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue