🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Linux and Client prediction

posted in trill41 for project ABx
Published June 01, 2019
Advertisement

Linux

Some time ago I started to port all the servers to Linux. This process is more or less finished now, it compiles fine with Clang (didn't try GCC) and it even runs without any problems. For that I also had to port DirectXMath, which is used by the game server, to Linux.

Even the client compiles and runs on Linux, but it doesn't work well, it always loses the connection to the game server.

VirtualBox_Manjaro_29_05_2019_12_43_10.thumb.png.9bab1f93a333df50e5e59d45922bc131.png

Now that everything compiles and runs, I tried to connect with the client to the server running inside a Linux VM. What I realized first was that I'm dealing now with real world conditions when it comes to network latency. When the client connects to a server running on the same machine, I always had a Ping (actually a round trip) of 50ms, which is fine. When the client is connected to the Linux server, I get a round trip of ~200ms - ouch! To be honest, I have no idea why it is so high, because the server and client still runs on the same hardware.

WinClient_LinuxServer.thumb.jpg.cedac1428d698166367bc49884ea1088.jpg

Anyway, I think an online RPG must deal with pings above 200ms, and even much higher pings.

Client prediction

Rountrip.png.93cd09779dfbf49221817ddbeec2b89e.png

In the screenshot above, the round trip time (RTT) is ~250ms, this means it takes 250ms from sending the move command to get the new position. 250ms doesn't sound much, but it is perceivable and feels really bad.

To deal with that problem, there are different techniques, one is Client prediction, what I made now. Client prediction means, the players client calculates its position on its own and moves the player to this likely position. It does not wait to get a position from the server. From time to time, the client checks if the client position and the server position are too different and adjusts the client position to the server position, also known as rubberbanding. This causes several problems:

  1. The position of the player on the client and server are probably not the same.
  2. Rubberbanding
  3. Sometimes the players character is controlled by the server, e.g. when following an other actor. This is easy to fix, the server just sends a message to the player to turn off client prediction.
  4. The players client is always ahead of the server and all other clients, but that might not be a big problem, since it's just visual.
  5. The client is very dump and does just a rough estimation of the likely position, without considering collisions resulting in even worse rubberbanding.

While the first are mere details, the collision checking seems to be a tough one. For now I have just added a message that forces the client to set the position of an object, e.g. when it would collide with an object. This results in even more jittering, but I look forward to implement basic collision checking also on the client.

Previous Entry Items and AI
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement