Fix high latency, simulate 1000 ping
This commit is contained in:
parent
45b7e69006
commit
953df8d2d0
@ -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)]
|
||||
|
||||
@ -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) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user