好的多人游戏/mmo客户服务器游戏是否在移动计算中使用了延迟? [英] Do good multiplayer/mmo client<>server games use latency within movement calculations?

查看:124
本文介绍了好的多人游戏/mmo客户服务器游戏是否在移动计算中使用了延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有几个问题.

想象一下,我有一个客户A,它将向服务器发送以下消息:"START MOVEMENT FORWARD".

服务器将不会立即收到此消息,因为延迟会导致延迟.

问题1:ping(或更好:往返时间)客户端将消息发送到服务器并接收回响应所花费的时间.如果您可以忽略服务器注意到它已收到一条消息并开始发送响应所花费的时间(这应该很短),这是否表示以下含义?

  1. 客户端向服务器发送东西的时间=往返时间/2
  2. 服务器向客户端发送邮件所需的时间=往返时间/2

因此,当客户端A发送该消息时,假定服务器将在客户端发送该消息后2毫秒来回接收该消息.这使我想到下一个问题.

问题2:客户端应该首先发送软件包,然后等待往返时间/2毫秒,然后实际执行客户端命令(在本例中为前进)来补偿延迟/滞后吗?

现在,服务器将向附近的所有玩家发送以下消息:客户端正在向前移动".然后,这些客户将确保客户a的角色开始移动,这将导致我进入下一个问题.

问题3:客户端收到另一个客户端已移动的消息时,是否应考虑到该消息是服务器往返时间/2毫秒前发送的?这样,用于移动计算时间戳记的当前时间应该减少往返时间/2?

在我看来,考虑到延迟,所有这些方法都可以确保改善客户端之间的同步.这是正确的做事方式吗?其他大多数优秀的多人游戏都能做到这一点吗?您有任何意见,建议,替代方案或随机但相关的喊话吗?预先感谢.

解决方案

我认为,在大多数mmo中,除非发生严重的延迟,否则客户的移动主要是在不与服务器交互的情况下进行的.服务器借助客户端发送给服务器的消息来再现移动.因此,例如,如果服务器出现故障,客户端将停止接收来自服务器的反馈,并恢复到服务器确定您所处的位置.这就是为什么您在严重滞后时会跳回几帧的原因.这样,服务器还可以控制您的速度,因此您不会进行Speedhack.如果您的客户端以超过服务器确定的速度的一定速率移动,则只需跳回多余的帧即可.

在一定时间内,如果没有服务器的响应,其他客户端将完全不允许您移动.这是您经历冻结滞后"的时候.

当然,也会发生服务器仅接受客户端发送的位置并盲目信任它的情况.这些游戏通常容易受到传送黑客的攻击.<​​/p>

当涉及其他玩家的位置时,确实存在延迟,如果您使用两台计算机,连接到哇之类的游戏并同时移动两个角色,则可以看到该延迟.您会看到,在您真正开始移动非本地角色之后,这两个计算机上的非本地角色都将开始移动.

客户通常会有某种滞后补偿.因此,如果另一个玩家朝某个方向移动然后停止,则您的客户端仍将模拟该玩家的移动,直到您从服务器收到一条消息,告知他更改了方向或停止了移动.这就是为什么ping高时其他玩家可以来回跳的原因.这也是为什么当您遇到滞后尖峰时,玩家似乎只是滑动/逃跑/走开,然后当您的客户从服务器接收到位置时回到玩家的真实位置的原因.

这当然会因引擎而异,但这是一个相当普遍的做法.

忘记补充一点,即服务器也使用滞后补偿是很常见的.如果您在您附近的mmo中击中某人,则该人可能不在服务器视图的范围内.因此,服务器将两个客户端的延迟都考虑在内,如果您确实不在对方的范围之内,则尝试进行匹配.

There's a couple of questions here.

Imagine I have client A who's going to send the following message to Server: "START MOVEMENT FORWARD".

The server will not receive this message instantly, as there is a delay because of latency.

Question 1: ping (or better: round trip time) is the amount of time it takes for the client to send a message to the server and receive a response back. Does this mean the following if you can ignore the time it takes for the server to notice that it has received a message and start sending a response (this should be very short)?

  1. time it takes for client to send someting to server = round-trip-time / 2
  2. time it takes for server to send something to client = round-trip-time / 2

So, when client A sends that message, the server will supposedly receive that message round-trip-time / 2 milliseconds after the client has send the message. This leads me to the next question.

Question 2: should the client first send the package, and then wait round-trip-time / 2 milliseconds before actually executing that command client-side (in this case: move forward) to compensate with the latency/lag?

Now, the server will send the following message to all nearby players: "CLIENT A IS NOW MOVING FORWARD". These clients will then make sure that the character of client a starts moving, this leads me to the next question.

Question 3: should the client receiving the message that an other client has moved take into account that this message was send by the server round-trip-time / 2 milliseconds ago? So that the current time used for movement calculations timestamps should be reduced by round-trip-time / 2?

All these methods would in my mind make sure that synchronisation improves between clients, as latency is taken into account. Is this the right way of doing things? Do most other good multiplayer games do this? Any comments, suggestions, alternatives or random but related shouts that you'd like to give? Thanks in advance.

解决方案

I think that in most mmo's your client mainly moves without interaction with the server unless bad lag occurs. The server reproduces the movement with the help of the messages the client send to the server. So if for example the server lags, the client will stop recieving feedback from the server and revert to the position the server determine that you are at. That is why you jump back several frames during bad lag. This way the server will also have control over your speed so that you are not speedhacking. If your client moves at a certain rate which is over the speed determined by the server, you would simply jump back the extra frames.

Other clients would not let you move at all without response from the server within a certain amount of time. This is the times you would experience 'freeze-lag'.

Of course there are also occurences where the server simply take the position sent by the client and blindly trusts it. These are the games that are generally vulnerable to teleport hacks.

When it comes to the position of other players there indeed is a delay, which can be seen if you take two computers, connect to a game such as wow and move the two characters simultaniously. You would see that on both computers the non-local character will start moving after you really started moving him.

The client usually have some sort of lag compensation. So if another player is moving at a certain direction and then stops, your client will still simulate the movement of that player until you recieve a message from the server that he changed direction or stoped moving. That is why other players can jump back and forth when the ping is high. This is also why players can seem to just slide/run/walk away when you hit lagspikes and then return to their real position when your clients recieve positions from the server.

Of course this changes from engine to engine but it's a rather general aproach.

Edit: Forgot to add that it is very common for the server to also use lag compensation. If you hit someone in a mmo that is in range of you, that person might not be in range from the servers view. So the server takes the latency for both your clients and tries to match up if you were really in range of eachother or not.

这篇关于好的多人游戏/mmo客户服务器游戏是否在移动计算中使用了延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆