How to handle lag ? (Speed game)

Hi,

I have made a game where you can fire spell (one every 3 secondes for example).

I check on client side if the spell touch, the issue is:

There is 2 players, A and B

Imagine player_A lag, so the player_B become immobile, the player_A shoot him easily. Then the RPC from A is send to B, to said your are dead, but the player B wasn’t at the good position.

I have no idea how to do that correctly.

Wrong decision for me
Solution 1 : Ask player B, are you near that position ? if not, I make no damage, but that make a bad user experience for player A

Solution 2 : Check last value receive from user B, if that is “too old” … bad user experience too

The only good solution is to make my own server logic with server and validate position of each player on server etc… (Game logic). But my skill level for server is near 0. I hope I will found other solution for my game.

If you need a proper lag compensation you will have to deal with shooting and hit detection on the server side.
Bascially you cannot make lag just disappear, so the usual way is to rewind the gamestate back on the server by the delay time of the client requesting the shoot. Then do the shoot action, evaluate hits, and trigger events.
After that, restore the gamestate.
This has drawbacks for the player being hit, though.

Here is a good reference on how to do this, but it needs some custom extra work.
Source Multiplayer Networking - Valve Developer Community (scroll down to “Lag Compensation”)
As far as I know, the Unet HLAPI is not supporting Lag Compensation out of the box (…yet?) - or I haven’t found it yet.

1 Like

I wonder if they’ll add any of this to the library of tools for llapi as well?

I’m using photon, I think I have to learn photon server. I will update this thread.

You should probably remove the Unity Multiplayer tag from your post then, since that is reserved for the new UNET system

I have question about the new UNET system. I read on this link : http://docs.unity3d.com/Manual/UNetUsingHLAPI.html
" the HLAPI is a server authoritative system; although it allows one of the participants to be a client and the server at the same time"

I can use HLAPI to be a server on Amazon for example ? to check collision between client A and client B ?

I believe that is the case (I don’t use the HLAPI). One of the next phases of uNet is supposed to bring more to the table in the way of functionality for dedicated servers.

Honikou, Please take a look at my signature for a free example of what your asking. I made the library to see on the asset store but decided to give it away for free you can find the file at the bottom of the youtube tutorials. It is completely free no gotchas no ads no spam, Just good ol fashion code. Good luck.