better camera jitter avoidance

as described here: https://docs.rs/bevy_xpbd_3d/latest/bevy_xpbd_3d/index.html#why-does-my-camera-following-jitter
This commit is contained in:
yuni 2024-03-30 18:50:53 +01:00
parent ce8f4666c5
commit 26b974ea16

View file

@ -3,8 +3,8 @@ use bevy::input::mouse::MouseMotion;
use bevy::window::PrimaryWindow; use bevy::window::PrimaryWindow;
use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings}; use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
use bevy::core_pipeline::tonemapping::Tonemapping; use bevy::core_pipeline::tonemapping::Tonemapping;
use bevy::transform::TransformSystem;
use bevy_xpbd_3d::prelude::*; use bevy_xpbd_3d::prelude::*;
use bevy_xpbd_3d::{PhysicsSchedule, PhysicsStepSet};
use std::f32::consts::*; use std::f32::consts::*;
use crate::{settings, audio, actor}; use crate::{settings, audio, actor};
@ -15,7 +15,9 @@ impl Plugin for CameraControllerPlugin {
app.add_systems(Startup, setup_camera); app.add_systems(Startup, setup_camera);
app.add_systems(Update, handle_input); app.add_systems(Update, handle_input);
app.add_systems(Update, manage_player_actor); app.add_systems(Update, manage_player_actor);
app.add_systems(PhysicsSchedule, sync_camera_to_player.in_set(PhysicsStepSet::BroadPhase)); app.add_systems(PostUpdate, sync_camera_to_player
.after(PhysicsSet::Sync)
.before(TransformSystem::TransformPropagate));
app.add_systems(Update, update_fov); app.add_systems(Update, update_fov);
app.add_systems(Update, apply_input_to_player); app.add_systems(Update, apply_input_to_player);
} }