From 88849990747d7087631ca5f0bcfaacb5a5b78a51 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 3 Apr 2024 13:53:49 +0200 Subject: [PATCH] adjust exit distance to vehicle size --- src/camera.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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();