流畅的多人游戏移动

发布于 2024-10-12 19:57:35 字数 412 浏览 4 评论 0原文

我正在开发一款多人角色扮演游戏,(不,它不是大型多人在线角色扮演游戏。;)

我当前的设置是这样的。

客户端告诉服务器“我想向前移动”/“我想向后移动”,服务器然后更新您的实体,并通知该区域中的所有客户端有关更改的信息。服务器还每 20 毫秒更新每个实体,并每 100 毫秒向客户端发送更新,这些更新包含位置、速度、旋转等。

到目前为止一切都很好,但是我没有任何存储来平滑客户端数据包之间的移动,我必须说,我无法让它工作。我一直在阅读有关预测、插值、航位推测的内容,但这对我来说都是一团糟。

所以现在我只是在做类似“Position = Packet.Position”的事情,这会导致非常口吃的运动。

所以,我需要帮助的是,如何获得更顺畅的运动?一直在查看 XNA 预测样本,但我无法得到正确的结果。

谢谢 //F

i am developing a multiplayer roleplaying game, (No, its not a mmorpg. ;)

My current setup is like this.

Client tells the server "I want to move forward"/"I want to move backwards", the server then updates your entity, and informs all clients in the area about the change. The server is also updating each entity every 20ms and sending updates every 100ms to the clients, these updates contains position, velocity, rotation etc.

So far so good, however i have nothing in store for smoothing the movement between the packets on the client side, and i must say, i can not get it working. I have been reading up on prediction, interpolation, deadreackoning but its all a big mess for me.

So right now i am just doing something like "Position = Packet.Position", which causes a very stuttering movement.

So, what i want help with is, how do i get a more smooth movement? Have been looking at the XNA Prediction Sample, but i could not get it right.

Thanks //F

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鸠魁 2024-10-19 19:57:35

阅读 Valve 对其多人协议的描述。它应该具有启发性,并给出了有关如何进行预测/插值的非常清晰的示例。

Read Valve's description of their multiplayer protocol. It should be instructive, and gives a very clear example on how you do the prediction/interpolation.

以可爱出名 2024-10-19 19:57:35

我建议从另一个问题中提出这个想法(请参阅接受的答案)

这里客户端自己计算其位置,就好像它不是网络游戏一样。客户端定期将其当前位置发送到服务器。如果客户端作弊或无法继续朝所选方向移动,服务器只会向客户端发送正确的位置。

《网络创世纪》也使用了同样的算法(至少在我 10 年前玩的时候)

I'd suggest the idea from another question (see the accepted answer)

Here the client calculates its position itself as if its not a network game. Client regularly sends his current position to the server. And if client cheats or can't continue moving in the chosen direction, server just sends the client his correct position.

The same algorithm was used in Ultima Online (at least when I was playing it 10 years ago)

给我一枪 2024-10-19 19:57:35

我通过在我的主要实体旁边运行一个幽灵实体来解决这个问题。
幽灵也会在每一帧进行更新,但每当有数据包进入时,他的值就会设置为数据包的值。

然后我逐渐将真实实体调整到鬼魂所在的位置。

I solved it by running a ghost entity alongside with my main one.
The ghost will get updated every frame aswell, but whenever a packet comes in, his values are set to the values of the packet.

I then gradually tweak the real entity to where the ghost is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文