How to simulating two client-controlled vehicles colliding (sensibly) in a typical client/server setup for a network game? I did read this eminent blog post on how to do distributed network physics in general (without traditional client prediction), but this question is specifically on how to handle collisions of owned objects.
Example
Say client A is 20 ms ahead of server, client B 300 ms ahead of server (counting both latency and maximum jitter). This means that when the two vehicles collide, both clients will see the other as 320 ms behind – in the opposite direction of the velocity of the other vehicle. Head-to-head on a Swedish highway means a difference of 16 meters/17.5 yards!
What not to try
It is virtually impossible to extrapolate the positions, since I also have very complex vehicles with joints and bodies all over, which in turn have linear and angular positions, velocities and accelerations, not to mention states from user input.
What I eventually ended up doing was simply skipping prediction alltogether and simply doing this:
meshoffset=meshpos-physposwhen receiving a positional update from the server and then setsmeshpos=physpos+meshoffseteach frame and gradually decreasesmeshoffset.It looks quite good most of the time (in low latency situation), I don’t even have to slerp my quaternions to get smooth transitions.
Skipping prediction probably gives high-latency clients an awful experiance, but I don’t have time to dwell on this if I’m ever going to ship this indie game. Once in a while it’s nice to create a half-ass solution that works good enough but best. 😉
Edit: I eventually ended up adding the “ownership” feature that Glen Fiedler (the blogger mentioned in the question) implemented for Mercenaries 2: each client gets ownership of (dynamic) objects that they collide with for a while. This was necessary since the penetration otherwise becomes deep in high latency and high speed situations. That soluation works just as great as you’d think when you see the GDC video presentation, can definitely recommend it!