Synchronization in multiplayer networked game?

大憨熊 提交于 2020-01-11 17:39:12

问题


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?


回答1:


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!



来源:https://stackoverflow.com/questions/5832616/synchronization-in-multiplayer-networked-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!