tinkering on 3rd person mode
This commit is contained in:
parent
a57b0808b6
commit
a5c796d491
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -2696,7 +2696,7 @@ dependencies = [
|
||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
"either",
|
"either",
|
||||||
"nalgebra",
|
"nalgebra",
|
||||||
"num-derive 0.4.2",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
@ -2718,7 +2718,7 @@ dependencies = [
|
||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
"either",
|
"either",
|
||||||
"nalgebra",
|
"nalgebra",
|
||||||
"num-derive 0.4.2",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl Default for Actor {
|
||||||
v: Vec3::ZERO,
|
v: Vec3::ZERO,
|
||||||
inside_entity: NO_RIDE,
|
inside_entity: NO_RIDE,
|
||||||
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.001, 0.01, 0.003),
|
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.001, 0.01, 0.003),
|
||||||
camdistance: 10.0,
|
camdistance: 15.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,10 +306,9 @@ pub fn handle_vehicle_enter_exit(
|
||||||
if vehicle == event.vehicle {
|
if vehicle == event.vehicle {
|
||||||
if event.is_entering {
|
if event.is_entering {
|
||||||
// Entering Vehicle
|
// Entering Vehicle
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::EnterVehicle));
|
|
||||||
*driver_vis = Visibility::Hidden;
|
*driver_vis = Visibility::Hidden;
|
||||||
*driver_trans = vehicle_trans.clone();
|
|
||||||
if event.is_player {
|
if event.is_player {
|
||||||
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::EnterVehicle));
|
||||||
//player_actor.inside_entity = entity.index();
|
//player_actor.inside_entity = entity.index();
|
||||||
*vehicle_vis = Visibility::Hidden;
|
*vehicle_vis = Visibility::Hidden;
|
||||||
driver_actor.v = vehicle_actor.v;
|
driver_actor.v = vehicle_actor.v;
|
||||||
|
@ -320,9 +319,9 @@ pub fn handle_vehicle_enter_exit(
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Exiting Vehicle
|
// Exiting Vehicle
|
||||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
|
|
||||||
*driver_vis = Visibility::Inherited;
|
*driver_vis = Visibility::Inherited;
|
||||||
if event.is_player {
|
if event.is_player {
|
||||||
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch));
|
||||||
*vehicle_vis = Visibility::Inherited;
|
*vehicle_vis = Visibility::Inherited;
|
||||||
vehicle_actor.v = driver_actor.v;
|
vehicle_actor.v = driver_actor.v;
|
||||||
vehicle_actor.angular_momentum = driver_actor.angular_momentum;
|
vehicle_actor.angular_momentum = driver_actor.angular_momentum;
|
||||||
|
@ -333,7 +332,6 @@ pub fn handle_vehicle_enter_exit(
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*driver_trans = vehicle_trans.clone();
|
*driver_trans = vehicle_trans.clone();
|
||||||
*driver_trans = vehicle_trans.clone();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,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, (With<actor::Player>, Without<actor::PlayerCamera>)>,
|
||||||
) {
|
) {
|
||||||
for mut vis in &mut q_playercam {
|
for mut vis in &mut q_playercam {
|
||||||
if settings.third_person {
|
if settings.third_person {
|
||||||
|
@ -85,6 +86,9 @@ fn manage_player_actor(
|
||||||
*vis = Visibility::Hidden;
|
*vis = Visibility::Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for mut vis in &mut q_hiddenplayer {
|
||||||
|
*vis = Visibility::Hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
@ -219,12 +223,12 @@ fn run_camera_controller(
|
||||||
+ mouse_delta.y * RADIANS_PER_DOT * controller.sensitivity)
|
+ mouse_delta.y * RADIANS_PER_DOT * controller.sensitivity)
|
||||||
.clamp(-PI / 2., PI / 2.);
|
.clamp(-PI / 2., PI / 2.);
|
||||||
controller.yaw += mouse_delta.x * RADIANS_PER_DOT * controller.sensitivity;
|
controller.yaw += mouse_delta.x * RADIANS_PER_DOT * controller.sensitivity;
|
||||||
player_transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, -controller.yaw, controller.pitch);
|
player_transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, -controller.yaw, controller.pitch).normalize();
|
||||||
camera_transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, PI-controller.yaw, -controller.pitch);
|
camera_transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, PI-controller.yaw, -controller.pitch).normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings.third_person {
|
if settings.third_person {
|
||||||
camera_transform.translation = player_transform.translation + camera_transform.rotation * Vec3::new(0.0, 0.0, actor.camdistance);
|
camera_transform.translation = player_transform.translation + camera_transform.rotation * (actor.camdistance * Vec3::new(0.0, 0.2, 1.0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
camera_transform.translation = player_transform.translation;
|
camera_transform.translation = player_transform.translation;
|
||||||
|
|
|
@ -41,6 +41,7 @@ impl Plugin for WorldPlugin {
|
||||||
//app.add_systems(Update, asset_loaded.after(load_cubemap_asset));
|
//app.add_systems(Update, asset_loaded.after(load_cubemap_asset));
|
||||||
//app.add_systems(Update, swap_world_on_ar_toggle);
|
//app.add_systems(Update, swap_world_on_ar_toggle);
|
||||||
app.add_plugins(PhysicsPlugins::default());
|
app.add_plugins(PhysicsPlugins::default());
|
||||||
|
//app.add_plugins(PhysicsDebugPlugin::default());
|
||||||
app.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)));
|
app.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)));
|
||||||
app.insert_resource(Gravity(Vec3::splat(0.0)));
|
app.insert_resource(Gravity(Vec3::splat(0.0)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue