How do I maintain movement speed with a server?

257 views Asked by At

I'm programming a server for my game and cannot figure out how to mantain the movement speed. Depending on what's running on the computer, the movement is either very fast or very slow. I've already tried to make my own delta methods for the server, but it won't work. I cannot use the Slick delta variable on update since the server is programmed using AWT & Kryonet.

Does anyone know how to maintain movement?

1

There are 1 answers

0
aglassman On

Your game server needs to have a definitive global time. I'd suggest using System.currentTimeMillis();

You'll have to base movement off of equations based on time then. Since loops on your machine won't execute at an exact rate, you need to get delta time passed by using the System.currentTimeMillis() subtracted from the previous time value. Use that value in your movement equations to get consistent looking movement. If you are calculating physics (ie movement), you'll want to use Runge Kutta order 4 equations, not the normal Euler equations (Euler compunds errors over time).

Other helpful 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