From f234830c546c3981a30b240f02e17f4de2b4d35e Mon Sep 17 00:00:00 2001 From: Sardelka9515 Date: Thu, 18 Aug 2022 22:08:06 +0800 Subject: [PATCH] Fix stuff --- .../Sync/Entities/SyncedVehicle.Members.cs | 1 + RageCoop.Client/Sync/Entities/SyncedVehicle.cs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/RageCoop.Client/Sync/Entities/SyncedVehicle.Members.cs b/RageCoop.Client/Sync/Entities/SyncedVehicle.Members.cs index 61362460..79b71ea5 100644 --- a/RageCoop.Client/Sync/Entities/SyncedVehicle.Members.cs +++ b/RageCoop.Client/Sync/Entities/SyncedVehicle.Members.cs @@ -71,6 +71,7 @@ internal bool IsFlipped internal int _lastLivery = -1; List _predictedTrace = new List(); List _orgTrace = new List(); + private Vector3 _predictedPosition; float _elapsed; #endregion diff --git a/RageCoop.Client/Sync/Entities/SyncedVehicle.cs b/RageCoop.Client/Sync/Entities/SyncedVehicle.cs index e3fd2305..1e127424 100644 --- a/RageCoop.Client/Sync/Entities/SyncedVehicle.cs +++ b/RageCoop.Client/Sync/Entities/SyncedVehicle.cs @@ -261,20 +261,21 @@ internal override void Update() } void DisplayVehicle(bool touching) { - _elapsed = Owner.PacketTravelTime+0.001f*LastSyncedStopWatch.ElapsedMilliseconds; - Position += _elapsed*Velocity; + _elapsed = Owner.PacketTravelTime + 0.001f * LastSyncedStopWatch.ElapsedMilliseconds; + _predictedPosition = Position + _elapsed * Velocity; var current = MainVehicle.ReadPosition(); - var dist = current.DistanceTo(Position); - var cali = dist*(Position - current); - if (Velocity.Length()<0.1) { cali*=10; } - if (dist>10) + var dist = current.DistanceTo(_predictedPosition); + var cali = dist * (_predictedPosition - current); + if (Velocity.Length() < 0.1) { cali *= 10; } + if (dist > 10) { - MainVehicle.Position = Position; + MainVehicle.Position = _predictedPosition; MainVehicle.Velocity = Velocity; MainVehicle.Quaternion = Quaternion; return; } - + + MainVehicle.Velocity = Velocity+cali; if (IsFlipped)