多人网络游戏中的同步?
最近我一直在开发一个多人网络应用程序。我已经使用 Bonjour 服务和 NSStream 对象成功实现了客户端服务器模型。双向通信已成功完成。
我面临的问题是:运行该应用程序的两个设备通过本地 wifi 连接。从客户端向服务器发送消息时存在延迟问题,反之亦然。
简单描述:
- 这是一款最多两名玩家的赛车游戏。
- 一台服务器和另一台客户端。
- 当客户端按下按钮时,会向服务器发送一条特定消息,告知按下了哪个键或按钮。然后服务器做出相应响应并在服务器本身上对客户端的汽车进行更改。这些变化并不总是相同的。客户端屏幕上的汽车实际位置与服务器屏幕上的汽车实际位置总是存在差异。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
欢迎来到网络世界。 :)
这些是游戏网络编程的典型困难。有很多不同的技术可以克服这些问题。
该博客提供了有关该主题的大量信息,可能会对您有所帮助。
http://gafferongames.com/networking-for-game-programmers/
您可以对这篇文章特别感兴趣:
http://www.gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking
祝你好运!
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!