Page 1 of 1

Handling Lag

Posted: Fri May 01, 2015 2:54 am
by etigah
http://jsfiddle.net/2kfnxLnz/

The link above is demonstration of the idea. If you look at it, the orange bullet is what the shooter sees, blue one is what the dodging player would see, while the purple one is speed adjusted to compensate for the lag.

I think this is a reasonable compromise for a few reasons:
- no death unless hit on own radar (a must IMHO)
- less guessing for the shooter as the bullet hits on both screens at approximately the same time

The drawback is that bullets will be a bit faster than normal with players who have lag (at both ends, so it would be fair)

-
Thoughts?

Re: Handling Lag

Posted: Fri May 01, 2015 10:53 am
by blast
I tweaked it a little to make it loop: http://jsfiddle.net/2kfnxLnz/1/

I don't know if changing the speed of the bullet is a good idea. Your example also doesn't show that the tank positions would appear to be different on both user's screens.

Anyways, we should strive to reward players with lower lag with a more accurate or smooth simulation. The server should decide who lives and dies, and if someone has a lot of lag, they might not be seeing an accurate simulation (or they might have less time to react to bullets).

In 2.99.x we tried to do lag compensation, but we messed up the implementation, instead rewarding the people with the most lag. Effectively, we had time synced clients and servers, and we used the lag amount to offset the positions of shots (and maybe tanks). So, someone with 500ms of lag shooting a bullet that travels at 30 meters per second would appear to be spawning bullets either 7.5 or 15 meters (can't recall if it was based on round-trip lag values) in front of their tank from the perspective of someone with 0 lag (and impossible situation, but using that as a theoretical example). This gave less time to reach to the actions of a laggy player, effectively allowing them to spawn a bullet inside your tank at close range.

So we'd want to do something like that but the other way around.

Re: Handling Lag

Posted: Fri May 01, 2015 12:29 pm
by etigah
It is intended to be as simple to implement as possible, but with reasonable gain. The amount a tank can move in <500 ms is not as significant as the amount a bullet moves in the same period, so I opted to neglect it. I think the bullet is the only element that moves predictably, players can get used to a little bit of variation in its speed.

The solution is not meant to be perfect. Just trying to make it perform acceptably and predictably.


PS. Thx for the tweak :)

Re: Handling Lag

Posted: Fri May 08, 2015 9:03 am
by etigah
There is a server up temporarily to test this functionality @ 192.241.121.197:5154 (titled: Public Hix - Lag Compensation)

A few players have tested it and the reception has been generally positive

Please do test it while the server is up. I will keep it running for a short time.

Re: Handling Lag

Posted: Sun May 10, 2015 8:29 am
by etigah
Created an in-game video to show it in action - https://vid.me/Lm8c
Emulated lag on two clients to show where bullets would appear over time on both.
Notice how the bullets hit the block nearly simultaneously although the initial shot event is delayed by over 1.5 sec on the 2nd client.