简体   繁体   English

游戏网络延迟补偿

[英]Game network latency compensation

I am developing a simple fast-paced 2 dimensional real-time multiplayer game in Flash. 我正在Flash中开发一个简单的快节奏2维实时多人游戏。 Players can only shoot and walk in point to move fashion. 玩家只能射击并行走才能移动时尚。 I use TCP socket connection (AS3 doesnt offer UDP). 我使用TCP套接字连接(AS3不提供UDP)。

All I want is to synchronize players' actions so Player1 could see the same on its screen as Player2,Player3... or just see close representation (position,taking damage,etc). 我想要的只是同步玩家的动作,以便Player1在屏幕上可以看到与Player2,Player3相同的图片,或者只是看到近距离的表示(位置,受到伤害等)。

I know movement vector coordinates and I can easily interpolate on them using latency. 我知道运动矢量坐标,因此可以使用延迟轻松地对其进行插值。 However, I can not figure out an effective way to determine how much time ( T1 ) did it take the state update to travel client1-server-client2 and then make corrections to client2's screen based on T1 . 但是,我无法找到一种有效的方法来确定状态更新要花费多少时间( T1 )才能到达client1-server-client2,然后根据T1对client2的屏幕进行更正。 (You know, ping times may fluctuate quite a bit). (您知道,ping时间可能会波动很多)。

I need a way to do the above-mentioned, i need way which is as fast and as accurate as posssible but not extremely sophisticated. 我需要一种方法来完成上述任务,我需要尽可能快而准确的方法,但又不是非常复杂。 (what algorithm should i use? what is the solution - timestamps, maybe or what? - I dont know.) (我应该使用哪种算法?解决方案是什么-时间戳,也许还是什么?-我不知道。)

First of all, I think the server should constantly have updated information about the entire "world". 首先,我认为服务器应该不断更新有关整个“世界”的信息。 All the clients send their playing actions (that is, what the player does, like movements, shootings, etc) to the server, and using compressed data. 所有客户端均使用压缩数据将其播放操作(即播放器的动作,例如动作,射击等)发送到服务器。

I would divide the "world" into regions. 我将“世界”分为多个区域。 Each player has of course a limited view, so he can't see all the world at once (luckily), thus he needs to get updates to only the regions he can see. 当然,每个玩家的视野都有限,因此他不能一次(幸运地)看到整个世界,因此,他只需要更新他可以看到的区域。

So the thing is: 所以事情是:

  • The server generates the world, and divides it into regions. 服务器生成世界,并将其划分为多个区域。
  • When a player enters the world, it gets general information about the entire world and detailed information about the regions in his sight 当玩家进入世界时,它将获得有关整个世界的一般信息以及有关他所看到的区域的详细信息
  • Each action of a player that has consequences, must be sent to the server (compressed) that acquires the information. 玩家产生的任何后果都必须发送到获取信息的服务器(压缩)。 If the status change has the effect of changing one or more regions, each user interested in those regions must receive the change notification 如果状态更改具有更改一个或多个区域的效果,则对这些区域感兴趣的每个用户都必须收到更改通知

It looks like a publish/subscribe design pattern (Observer), but 它看起来像一个发布/订阅设计模式(观察者),但是

  • each client is the publisher and the server is the subscriber for what concerns the player status change. 对于播放器状态更改,每个客户端都是发布者,而服务器是订阅者。
  • the server is publisher and the clients are subscribers for what concerns the world change, but only for the regions each player is interested in. this is a particular Observer in that the subscription changes over time (regions) due to movement 服务器是发布者,客户是与世界变化有关的订户,但仅针对每个玩家感兴趣的区域。这是一个特殊的观察者,因为订阅会随着移动而随着时间(区域)而变化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM