diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index 75476f2..627dd16 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -294,6 +294,15 @@ impl Game { if player.id != self.self_id.unwrap_or(0) { player.set_transform(transform); player.set_move_dir(dir); + } else { + 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); + } + } } } } diff --git a/rust/src/net/util.rs b/rust/src/net/util.rs index 28f3536..ed1ea00 100644 --- a/rust/src/net/util.rs +++ b/rust/src/net/util.rs @@ -1,7 +1,7 @@ use godot::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct NetVector3 { pub x: f32, pub y: f32, diff --git a/rust/src/player.rs b/rust/src/player.rs index 8ce2ed4..8bc4c40 100644 --- a/rust/src/player.rs +++ b/rust/src/player.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use crate::{net::util::NetVector3, ui::cli::CommandLinePanel}; -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct NetPlayerTransform { pub location: NetVector3, pub rotation: NetVector3,