- Home /
Same movement speed on server, despite send rate from client
On a networked game, the game clients send their desired positions via fixed send rate, example:
while(true) {
SendMyPos(posX);
Thread.Sleep(30);
}
On server-side, I calculate the next player position, applying a speed (stored on server) value to it:
player.position.x += x * speed_StoredOnServer;
The server sends the player positions with a fixed send rate too, but that's not a problem.
The problem:
The player's actual speed is affected by the client-to-server send rate. The higher the client-to-server send rate is, the faster the player will move on the server side.
My goal is to make the speed on server-side independent from the client-to-server send rate. I'm sure it can be achieved with a simple formula, but so far I have no solution.
Answer by Griverson · Sep 12, 2019 at 02:28 PM
I think, you must send to server much more data to sync with other players. 1) Current position 2) Current movement vector 3) Current time, synchronized with server time 4) Optionally, movement speed, if the player controls it.
Hi @Griverson , I don't think it needs to sync with other players cause they all have the same send rate. The thing is, the speed must change based on the client-to-server send rate. For example, if the rate is 25, the speed on server side should be 0,9, and so on. I couldn't find a pattern, so in the end I decided to apply fixed values. Example:
sendRate = speed, 10 = 1.5, 15 = 1.2, 10 = 0.8, 11 = 0.4
Thanks.