How to maintain speed with the server?

I am programming a server for my game and cannot figure out how to maintain speed. Depending on what works on the computer, the movement is very fast or very slow. I already tried to use my own delta methods for the server, but this will not work. I cannot use the Slick delta variable when updating, as the server is programmed using AWT and Kryonet.

Does anyone know how to keep moving?

+4
source share
1 answer

Your game server must have final global time. I would suggest using System.currentTimeMillis ();

In doing so, you will have to base the movement on time-based equations. Since the loops on your machine will not run at a certain speed, you need to get the delta time using System.currentTimeMillis (), subtracted from the previous time value. Use this value in your equations of motion to get consistent motion. If you are calculating physics (i.e., Motion), you will want to use Runge Kutta 4 order equations, rather than the usual Euler equations (Euler compunds errors over time).

Other useful links:

http://gafferongames.com/game-physics/integration-basics/

https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization

+4
source

Source: https://habr.com/ru/post/1414795/


All Articles