Handling Lag

Make suggestions for improving one of the best games on the net!
Post Reply
etigah
Private First Class
Private First Class
Posts: 98
Joined: Tue May 22, 2012 4:08 pm

Handling Lag

Post 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?
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Handling Lag

Post 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.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
etigah
Private First Class
Private First Class
Posts: 98
Joined: Tue May 22, 2012 4:08 pm

Re: Handling Lag

Post 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 :)
etigah
Private First Class
Private First Class
Posts: 98
Joined: Tue May 22, 2012 4:08 pm

Re: Handling Lag

Post 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.
etigah
Private First Class
Private First Class
Posts: 98
Joined: Tue May 22, 2012 4:08 pm

Re: Handling Lag

Post 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.
Post Reply