Fix sync
This commit is contained in:
parent
66082a7f04
commit
704ea006c9
@ -292,15 +292,16 @@ impl Game {
|
||||
for (player_id, (dir, transform)) in sync_data {
|
||||
if let Some(player) = self.players.iter_mut().find(|p| p.id == player_id) {
|
||||
if player.id != self.self_id.unwrap_or(0) {
|
||||
// Sync remote players always
|
||||
player.set_transform(transform);
|
||||
player.set_move_dir(dir);
|
||||
} else {
|
||||
// Sync local player only if it's far enough
|
||||
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. {
|
||||
player.set_transform(transform);
|
||||
player.set_move_dir(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user