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)