Search Unity

Industry Standard Solution Lag Compensation Problem

Discussion in 'Multiplayer' started by SynergiAios, Jan 31, 2017.

  1. SynergiAios

    SynergiAios

    Joined:
    Feb 3, 2015
    Posts:
    35
    So I'm currently implementing the industry standard solution for lag compensation with server authority.

    So standard is to send the player input to the server, while having a local character controller that immediately uses the input to show the player the input result. The inputs are send to the server with a timestamp of the client when he pressed the buttons.

    The server gathers all the inputs of all players, checks the time difference of each input and applies them to the clients character for the time difference the server is in and the clients input was pressed. for the time till the next input the server predicts the movements. The server runs on a fixed update timer, and applies movement and actions then.

    The server then takes the previous state of the game and the current state and broadcasts these 2 states to all clients. The client receives then his own state and the state of the other clients. For his own character he checks for a given tolerance in placement, ... and if in tolerance interpolates to correct position over time and if out of tolerance kicks the client. For the other characters of the other clients, the client interpolates in between the previous state and the current state given by the server. The current state is actually no longer the current state, so each client will see the world in past.

    ======================================

    Everything clear and already done, but one big problem currently I can't figure out a solution currently for. Of course are the players able to trigger actions. These actions are now based on a world they see in the past. As the client triggers an action, the server will be noticed with the time of the client and the time of the state the client saw. So the server knows where to rewind to, to check for collision at that time.

    But how to rewind?

    Storing movement vectors for each character after each change for a given time?
    Storing input to rewind?
    Storing anything ... ?

    So basically my question is, what do I store on the server to rewind the clients action properly. (My movement is not physics based)

    As an example, if I store a direction vector and the velocity at point x for each change , how to deal with actions like jump which will lead to a parable movement vector with lower velocity at the end.

    I'm extremely idealess currently pls help x)

    =====================================

    Next problem same situation, dealing with actions. Normally I do just interpolate for other characters the client sees, in between 2 states the server delivered. But what to do, if a character was running forward in state 1 and in state 2 is high in the air because he jumped somewhere in between the 2 states. Should I now just interpolate and set the jump animation when the timecode is reached on the client? This could lead to a jumping character that has not the jump animation running because he is just moving.

    So basically how would I sync the animations with the actions on each client corresponding to the 2 states I deliver to the clients, or even better, howto exactly replay the actions for each character on each client. Is interpolation in between 2 states a bad design?

    Pls need input and ideas x)

    Tia Synergi