diff --git a/src/camera.rs b/src/camera.rs index 5215fe8..a8f660c 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -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();