There\'s a couple of questions here.
Imagine I have client A who\'s going to send the following message to Server: \"START MOVEMENT FORWARD\".
The server will no
There are several network models to solve these problems;
In network game, you need to sync two things, one is time, other is space.
you should have a look at the article written by age of empire2 game studio, which describe details in lockstep model.
In this Model, Client and server run game logic frame by frame, for example, RTS use 100ms as a frame, Server and client will sync frame Id, which means to sync time.
Client at frame 50, Send Command MoveForward, but not run it immediately, client will tell server to run move command at frame 51; then when frame 51 comes, server and client will run command at the same time. so client and server logic will be same.
In such model, at frame 50, client and server will run command issued at frame 49 perhaps, so there are alway 100ms or more delay in client input feedback.
the lag between client and server not only contains network RTT, but also contains logic frame delay, which is 100ms;
in this model, to sync space, you need to make your client code and server code Deterministic, so they can only sync command and frameId, there are no needs to sync entity state.
in this model, input feedback is large, so you need to play animation or sound to help player ignore the lag.
in this model, we also need to sync time, so client will guess what current time in server.
when player input, client move immediately, then send move command or client target pos to server with current server timestamp, which is estimated by client.
when server receive the client command, it know when the command is issued in server time by client, it will try to run the command with extrapolation.
all other clients will receive the command, with its server time, the all other clients will try to extrapolate the command.
these technologies include Client Prediction, Server Lag compensation, Server Entity interpolation.
in this model, client input feedback is short, but for some impulse command, such as using skill, we still need to use lockstep method, with animation , sound and particle effects to makeup the input feedback time.
In network game, there at least two kinds command, first like movement, command will run for a certain time, like a steady stream, which has the attribute of Continuity.
the other like using skill with cold time, command effect will take in impulse, we should treat them differently.