Help determine the lag compensation for the browser-based agari-like game. Client and server communication via websockets. That is, it should be borne in mind that instead of the loss of UDP packets, we will face, if anything, a late arrival of foul TCP packets. I got acquainted with a huge number of articles on lag compensation for shooters. The theory seems to be clear, but in practice questions arise for the arcade version.
Preparation: the server simulates the game world in equal intervals of time - 1 tick = 50 ms. To increase accuracy, the simulation itself is performed 5 times for one tick, that is, 10 ms each. The important point is that if a little more than one tick has passed, the rest of the time is transferred to the next tick. On each tick, a frame of changes is formed and sent to all clients. On the client, all objects are conditionally divided into 2 groups - the player's body and all the rest. The server models the world in its own time, rolling away nothing. There are no timestamps on the client side yet. All actions of the players are collected into the buffer and are applied simultaneously at the beginning of the next tick, since the action was initiated precisely for this time.
Estimated algorithm (client side): Player bodies are modeled on the client at the current time without waiting for server confirmation. All other bodies are modeled using interpolation with a delay of 50 ms. We have two frames - the past and the future. The position of the body is interpolated from the past frame to the future. Upon the timely arrival of the next frame, frames are shifted. If there is a delay of the next frame, then extrapolation is used for another 100 ms of the spare time or before the arrival of this frame. At the expiration of the spare time the body stops.
The following is not clear: how with such an approach to correctly combine the player's division into two parts? After all, the enemy attacked by the player is slightly in the past on the player’s screen (50 ms for interpolation + the player himself half a ping in front of the server). It turns out the server is obliged to roll back the position of at least the players (and in the general case of all moving objects) for an exact miscalculation of the interaction? Or you can somehow simplify the algorithm and calculations? Is it possible for such a game plan to take a completely different approach?