Facepunch / sbox-tabletennis-vr

🏓 Facepunch presents Table Tennis VR
https://asset.party/facepunch/tabletennis
MIT License
16 stars 0 forks source link

Lag compensation #14

Open handsomematt opened 2 years ago

handsomematt commented 2 years ago

Currently our networking model is Client -> Server -> Client - however one of the clients is pretty much always going to be the server.

An example of lag would be if one client has 100ms ping, when the client hits the ball the physics simulation would've already been running for 100ms extra making the ball appear further away and then suddenly teleporting forwards.

A solution I'm thinking is: when a client hits the ball, calculate how long it will take to reach the opposing players end of the table and slow your local physics simulation down over that delta so the ball will reach it's intended destination 100ms later. This should seem seamless, at the most extreme it'd probably only slow down by 10% which will barely be perceived by the player.