WIP crisper camera controls (fix rotation/accleration with vehicles)

This commit is contained in:
yuni 2024-11-17 00:37:40 +01:00
parent 2e35f90a19
commit 3a7ab8c9ac

View file

@ -588,6 +588,7 @@ pub fn handle_vehicle_enter_exit(
commands.entity(driver).remove::<PlayerCamera>();
commands.entity(driver).remove::<WantsRotationChange>();
commands.entity(driver).remove::<Collider>();
commands.entity(driver).remove::<WantsAcceleration>();
commands.entity(driver).insert(JustNowEnteredVehicle);
commands
.entity(vehicle)
@ -595,6 +596,7 @@ pub fn handle_vehicle_enter_exit(
commands.entity(vehicle).remove::<hud::IsTargeted>();
commands.entity(vehicle).insert(PlayerCamera);
commands.entity(vehicle).insert(PlayerDrivesThis);
commands.entity(vehicle).insert(WantsMaxRotation(0.0));
if let Ok(mut flashlight_trans) = q_playerflashlight.get_single_mut() {
flashlight_trans.rotation = Quat::from_rotation_y(0f32);
flashlight_trans.translation = Vec3::new(0.0, 0.0, 0.0);
@ -614,11 +616,15 @@ pub fn handle_vehicle_enter_exit(
Quat::from_rotation_y(180f32.to_radians());
flashlight_trans.translation = Vec3::new(0.0, 0.0, 1.0);
}
commands.entity(driver).insert(WantsAcceleration::default());
commands.entity(driver).insert(RigidBody::Dynamic);
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::ExitVehicle));
commands.entity(vehicle).remove::<WantsMaxRotation>();
commands.entity(vehicle).remove::<PlayerCamera>();
commands.entity(driver).insert(PlayerCamera);
commands.entity(vehicle).remove::<PlayerDrivesThis>();
commands.entity(vehicle).remove::<WantsAcceleration>();
commands.entity(vehicle).remove::<WantsRotationChange>();
*vehicle_vis = Visibility::Visible;
}
}