Skip to content

Commit

Permalink
Fix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Sardelka9515 committed Aug 18, 2022
1 parent 5075289 commit f234830
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions RageCoop.Client/Sync/Entities/SyncedVehicle.Members.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ internal bool IsFlipped
internal int _lastLivery = -1;
List<Vector3> _predictedTrace = new List<Vector3>();
List<Vector3> _orgTrace = new List<Vector3>();
private Vector3 _predictedPosition;

float _elapsed;
#endregion
Expand Down
17 changes: 9 additions & 8 deletions RageCoop.Client/Sync/Entities/SyncedVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f234830

Please sign in to comment.