diff --git a/rust/src/game/mod.rs b/rust/src/game/mod.rs index 82e8d92..078ecd9 100644 --- a/rust/src/game/mod.rs +++ b/rust/src/game/mod.rs @@ -1079,7 +1079,12 @@ impl Game { if let Some(local_net_transform) = player.get_transform() { let local_location: Vector3 = local_net_transform.location.into(); let remote_location: Vector3 = transform.location.into(); - if local_location.distance_squared_to(remote_location) > 2. { + + let max_distance = (player.data.ping as f32 / 1000.) + * (player.get_move_speed() + player.get_y_speed()) + * 2.; + + if local_location.distance_to(remote_location) > max_distance { player.set_transform(transform); } } @@ -1690,6 +1695,22 @@ impl Player { None } } + + fn get_move_speed(&self) -> f32 { + if let Some(character) = &self.character { + character.dyn_bind().get_move_speed() + } else { + 0. + } + } + + fn get_y_speed(&self) -> f32 { + if let Some(character) = &self.character { + character.dyn_bind().get_y_speed() + } else { + 0. + } + } } #[derive(Debug, Default, Serialize, Deserialize, Clone)] diff --git a/rust/src/net/network_manager.rs b/rust/src/net/network_manager.rs index 4611969..4b6575a 100644 --- a/rust/src/net/network_manager.rs +++ b/rust/src/net/network_manager.rs @@ -271,7 +271,7 @@ impl NetworkManager { None, PeerConfig::default() .with_identifier(NetworkManager::identifier()) - .with_additional_ping(Duration::from_millis(100)), + .with_additional_ping(Duration::from_millis(1000)), ); match peer { Ok(mut peer) => {