Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synchronization in multiplayer networked game?

Recently I have been working on a multiplayer networking app. I had successfully implemented the client server model using Bonjour services and NSStream objects. The two way communication has been done successfully.

The problem I'm facing is: the two devices running the app are connected via local wifi. There is a latency problem while sending the messages from client to server and vice versa.

Describing in brief:

  • It's a car racing game with at most two players.
  • One server and other client.
  • When client press the buttons a particular message is sent to the server telling which key or button was pressed. Then the server responds accordingly and make changes on the client's car on the server itself. These changes are not always the same. There is always a difference between the actual location of the car on the client's screen and that in the server screen.

Any ideas?

like image 432
Tornado Avatar asked Jan 20 '23 21:01

Tornado


1 Answers

Welcome to the world of networking. :)

These are the classic difficulties with game networking programming. There's a lot of different techniques to overcome these issues.

This blog has great info on the subject and will probably help you out.

http://gafferongames.com/networking-for-game-programmers/

You may be specifically interested in this article:

http://www.gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking

Good luck!

like image 89
KTF Avatar answered Jan 25 '23 20:01

KTF