adjust exit distance to vehicle size

This commit is contained in:
yuni 2024-04-03 13:53:49 +02:00
parent 0142d6d77b
commit 8884999074

View file

@ -125,9 +125,14 @@ fn manage_player_actor(
}
}
for (mut vis, mut pos, mut rot, mut v, mut angv) in &mut q_hiddenplayer {
// If we are riding a vehicle, place the player at the position where
// it would be after exiting the vehicle.
// I would rather place it in the center of the vehicle, but at the time
// of writing, I couldn't set the position/rotation of the player *during*
// exiting the vehicle, so I'm doing it here instead, as a workaround.
*vis = Visibility::Hidden;
if let Ok((ride_trans, ride_pos, ride_rot, ride_v, ride_angv)) = q_ride.get_single() {
pos.0 = ride_pos.0 + DVec3::from(ride_trans.rotation * Vec3::new(0.0, 0.0, 10.0));
pos.0 = ride_pos.0 + DVec3::from(ride_trans.rotation * Vec3::new(0.0, 0.0, ride_trans.scale.z * 2.0));
rot.0 = ride_rot.0 * DQuat::from_array([-1.0, 0.0, 0.0, 0.0]);
*v = ride_v.clone();
*angv = ride_angv.clone();