I am still having issues with camera stutter, it is now on the update schedule and this is the updated code
time: Res<Time>, // Access the delta time resource
mut query1: Query<&mut Transform, (With<MainCamera>, Without<Player>)>,
query2: Query<&Transform, (With<Player>, Without<Camera>)>
) {
if let Ok(mut cam_trans) = query1.get_single_mut() {
if let Ok(player_trans) = query2.get_single() {
let target_position = player_trans.translation + Vec3::new(10.0, 10.0, 10.0);
// Control the speed and smoothness with delta time
let smooth_factor = 5.0; // Adjust this for more or less smoothing
let interpolation_factor = 1.0 - f32::exp(-smooth_factor * time.delta_seconds());
// Calculate the new interpolated position
let new_position = cam_trans.translation.lerp(target_position, interpolation_factor);
// Apply some minimum distance threshold to prevent jitter from tiny updates
if (new_position - cam_trans.translation).length() > 0.001 {
cam_trans.translation = new_position;
}
}
}```