Calculate y-rot differently

This commit is contained in:
Sofia 2026-07-25 01:19:01 +03:00
parent fe2d586a50
commit 3e5a9b3163
2 changed files with 12 additions and 1 deletions

View File

@ -1066,6 +1066,7 @@ impl Player {
let max_distance = (self.data.ping as f32 / 500.)
* (character.dyn_bind().get_move_speed() + character.dyn_bind().get_y_speed());
godot_print!("{}", max_distance);
if client_pos.distance_to(server_pos) <= max_distance {
character.dyn_bind_mut().apply_position(client_pos);

View File

@ -76,6 +76,7 @@ pub struct LocalPlayer {
movement_dir: Vector3,
y_speed: f32,
y_rot: f32,
look_up: f32,
is_dead: bool,
@ -558,12 +559,21 @@ impl ICharacterBody3D for LocalPlayer {
}
let y_rot = -x * self.look_sensitivity;
self.base_mut().rotate_y(y_rot);
self.y_rot = self.base().get_global_rotation().y + y_rot;
}
}
}
}
fn physics_process(&mut self, _: f64) {
let rot = self.y_rot;
let new_rot = Vector3 {
y: rot,
..self.base().get_global_rotation()
};
self.base_mut().set_global_rotation(new_rot);
}
fn exit_tree(&mut self) {
if let Some(game) = Game::singleton()
&& !game.bind().game_started