2022-01-22 13:08:58

Greetings everyone,
lets say I have a multiplayer game, and I want the client to know about a map. I have seen some posts here discouraging sending the map data to the client and just letting the client handle the map.
What's the correct way, then? The only logical way my mind came up with is having the client ask the server about the next tile, then waiting for a response, then move or not move the player depending on that.
But wouldn't that be quite laggy? If a player has a 100 MS ping, that's plus 100 ms to the moving time. Is that the correct way or is there a better way?
Thanks for your answers

2022-01-22 13:49:30

It depends. Ideally you want the client to handle as little as possible, like only inputs or button presses from the client. It would be alright to store the map data on the clients side, so long as that data has nothing to do with the server. So for example player presses up to move up on a grid map, it sends that to the server and the server moves the player up on its map, then sends a response saying its ok to the client, which moves the player up on its side. Now its true that based on this strict setup you may get some lag because of the transfer time, so you should look into "client side prediction", where the client "predicts" whats likely to happen and does it, then corrects any errors in the prediction when the answer from the server arrives.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-01-22 19:34:21

Yeah, so basically.  The client and the server both get the map.  The client sends the server inputs.  But it *also* moves the player, and checks that all of the things the server sends back match what it thought it was going to have to do.  If they don't, it throws out the predictions in favor of what the server says.  As you get replies from the server, you knock the interpolation points off the list of predictions the client made, and re-run your algorithm.  Lots of info on Google about this stuff under the terms client-side prediction and client-side interpolation, as previously stated.

It's okay if the client handles the map, if you're fine with the kinds of cheating that allows.  For example, if you're doing some sort of shooter where me and my friends all play together but we aren't playing with a bunch of strangers at the same time, then who cares?  If people don't want to play with cheaters they'll just not play with them.  The issue is when having an authoritative client opens up the ability for players to affect other players who aren't people you know, or in ways that affect the world permanently, because that's unfair since people can't just walk away from cheaters.

My Blog
Twitter: @ajhicks1992

2022-01-22 20:09:13

Thanks! I think I got the idea