Hello my dear,
if you are here you might sak yourself “hey bruh , how can i make the game better for people in multiplayer and avoid latency problems”
answer is simple : maximaze the compression of data sent.
for example :
when your character move, they do not send evey data on their position , rather , they send their objective and the client.
the game should be sending the fewest information, there it would send a 32 bits long information for each character.
let me explain, there are 2 kinds of data that have to be transfered :
Randomly generated data that’s why people prefer to use "the seeds"
it avoids a lot of problems
users input and functions:
So a data packet should look like :
[User][Function][Target][Data] and so you will be optimizing a lot of things.
the blocks willing to be build should not be tranfered, it makes no sens, they should bevisible to the player only as a visualization tool.
so for example you would have :
and here you go , you don’t have to create each orc and you juste have to send the seed generated to every player.
the server also controls other caracters :
and this command let the individuals attack the other base without having to do much.
a vilain will attack the nearest enemy and if pathfinder is well done, they should find the way easily. (i reccomend using a 3 way calculation : straight, sinuous , long_calculated)
this avoids a lots of problems to reach someone entrance as you juste have to generate a new path and not send the path data.
to ensure everything is right,
the server does a position check and send it to players every once in a while.
so player have a better experience and are sure their game is behaving properly.
if you have any question on how to optimize network usage, i’ll be glad to give you indication on how to do so ^^