Sync local player too if too far
This commit is contained in:
parent
e1b7572098
commit
66082a7f04
@ -294,6 +294,15 @@ impl Game {
|
|||||||
if player.id != self.self_id.unwrap_or(0) {
|
if player.id != self.self_id.unwrap_or(0) {
|
||||||
player.set_transform(transform);
|
player.set_transform(transform);
|
||||||
player.set_move_dir(dir);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use godot::prelude::*;
|
use godot::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub struct NetVector3 {
|
pub struct NetVector3 {
|
||||||
pub x: f32,
|
pub x: f32,
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{net::util::NetVector3, ui::cli::CommandLinePanel};
|
use crate::{net::util::NetVector3, ui::cli::CommandLinePanel};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub struct NetPlayerTransform {
|
pub struct NetPlayerTransform {
|
||||||
pub location: NetVector3,
|
pub location: NetVector3,
|
||||||
pub rotation: NetVector3,
|
pub rotation: NetVector3,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user