[英]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: 所以事情是:
It looks like a publish/subscribe design pattern (Observer), but 它看起来像一个发布/订阅设计模式(观察者),但是
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.