Author Topic: Vehicle sync methods  (Read 2162 times)

ntlofub

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Vehicle sync methods
« on: December 19, 2008, 08:24:14 pm »
I'm posting this topic in regards to Liberty Unleashed's current implementation of vehicle synchronization. These observations are made based on my experience with the latest public beta client. It is not directed to any particular member on this forum, but rather the team as a whole.

It appears as though you are updating the vehicle's position, velocities, pitch, roll, and rotation vectors either every frame or every time the client receives a packet from another player. This is precisely the approach MTA:GTA3 took, aswell as MTA:VC.  While it does get the job done to an extent, there is still a significant margin of precision error. The sudden direct alteration of position, velocity etc causes the vehicle to slightly jump from its previous location.  This could be due to a number reasons, one being that's not how the game dictates pedestrians driving vehicles in single player. Constantly forcing a new position between two clients with separate framerates is going to produce undesirable effects that some people mistake as lag. The problem is not entirely lag; it's how you're controlling the movement of vehicles.

Instead of directly modifying the position and other vectors, consider incrementing the velocity of the vehicle exponentially in the direction of the new position. This is essentially taking advantage of the game's own interpolation scheme, making the vehicle smoothly travel from one position to the next. This is a different approach as opposed to changing the position every frame; when you gradually alter the velocity of the vehicle to accommodate the new position over a series of frames, rather than one, the result is smoother movement at the expense of slightly decreased accuracy.

There are similar approaches to this method of vehicle synchronization in VC:MP, SA-MP, and even MTA:SA DM.  I suggest taking a look, although the algorithm used to achieve the effect in this game would be slightly different.

ntlofub

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: Vehicle sync methods
« Reply #1 on: December 19, 2008, 11:58:30 pm »
Well, to start off with the vehicle sync in LU is nowhere near finished. needs more coding to get it nicer.

Also, the sync methods i'm using is the same type of methods used in sa-mp and vc-mp. its nothing like mta:gta3 and mta:vc.

What i do is send the speeds for moving, turning etc aswell as the coords and angles. On receive, the client reads these values and checks them. It sets and tweaks the speeds to compensate for small latency (due to it being basic) and also checks the coordinates.
If the coordinates are too far out (more than 5 coords away from where it should be) then it 'warps' the vehicle back into place. When sync is finished it will interpolate back but hopefully the prediction should stop it being too far out.

It also does the same for angles etc. The game does try to predict where it should be as it also sets its own speeds due to the vehicle being handled like an actual player is driving and not a ped. unfortunately it cannot compensate for network latency.


 

© Liberty Unleashed Team.