top | item 9737089

Help with server logic for a multiplayer game server in GO/Unity

5 points| diericx | 10 years ago | reply

I am trying to create a simple multiplayer server for a simple game using GO. I currently have it so that users can join, sign in, connect, and see other users. The issue I currently have is that moving around is very laggy because I send user input to the server and all actions are performed on the server rather than on the client. Clients and the server only get and send packets every 20 milliseconds.

I was wondering what the best solution to this is. I feel like I have 2 options: exchange a lot more packets to make the game run a lot smoother for the client, or create some sort of prediction on the client where the client will do what it thinks is right until corrected by the server.

I read somewhere that Agar does not use any client side prediction/correction so it must be possible to continue without that.

What is the down side to sending more packets? Is that a reasonable way to solve this lag issue? And if so should I only send more on one side of the game to be optimized correctly (as in send a lot of packets from the server but not a lot from the client)?

5 comments

order
[+] iamflimflam1|10 years ago|reply
This is a good article - http://gafferongames.com/networking-for-game-programmers/wha...

If you really are sending packets every 20ms then that is the equivalent of 50fps - I suspect that if you log out how often you are getting packets from the server you'll find that you are not actually getting packets at that rate, or the jitter on the packets is unacceptable.

Client side prediction doesn't have to be very clever. You can get good results with very simple algorithms.

I gave a talk on this a few years ago at iOSDevUK - https://dl.dropboxusercontent.com/u/508075/GameCenter%20and%...

I'm not an expert in games, but even my simple code worked pretty well.

From what I remember I was sending user inputs from the client side every 0.2 seconds - and from the server once I had the client prediction in place I could get away with very slow updates from the server and still have the illusion of 60fps.

[+] diericx|10 years ago|reply
I actually just noticed a bug in my code where I was only looking for data from the server every 20 milliseconds rather than every frame. Now the movement is smooth but the controls feel a bit sticky. I made the client send every 10 milliseconds and it looks pretty good, but this is a really bad way to solve this problem. I'll look at your links and try to optimize it better! Thanks a ton for those:)

Edit: I read your keynote and I'm not sure how exactly your client prediction worked. Is there any video anywhere of the keynote? Or could you give a brief description?