我应该如何处理游戏开发中的延迟问题?

发布于 2024-10-19 01:22:38 字数 455 浏览 3 评论 0原文

我正在开发一个由多人网络浏览器游戏组成的业余爱好项目。 这是我的第一次,我刚刚遇到了延迟问题。

我正在努力让用户控制尽可能流畅,但延迟却成为了障碍。

我认为平均延迟可能在 80-200 毫秒左右,为了实现几乎平滑的控制,命令-操作延迟需要小于100ms。

我有几个问题:

  • 尝试在要求之前 100 毫秒发送用户操作是否是一个好的做法?例如用户保留“->”按下箭头键,我在需要将操作提交到服务器之前 100 毫秒提交右箭头键操作。

  • 开发人员如何保持在线服务器和客户端上发生的事情之间的一致性/同步?

  • 有什么提示或建议吗?


谢谢大家,非常有帮助赞赏。 :)

I'm working on a hobby project consisting of a multi-player web browser game.
It is my first and I have just stumbled into the latency issue.

I am trying to make user control as smooth as possible and latency is getting in the way.

I reckon that average latencies might be around 80-200ms and that for virtually-smooth control a command-action delay needs to be less than 100ms.

I have a few questions:

  • Would it be good practice to try and send user actions 100ms before required? e.g. User keeps the '->' arrow key pressed, I submit the right arrow key action 100ms before action needs to be submitted to a server.

  • How do developees keep consistency/synchonise between what is happening on the online server and on the client?

  • Any tips or recommendations?


Thanks guys, help would be very much appreciated. :)

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

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

发布评论

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

评论(2

要走干脆点 2024-10-26 01:22:38

问题1)是的,但是如果你正在进行这样的实时移动,我会考虑在本地渲染它(使用碰撞检测等),然后在服务器上进行验证以确保他们不会欺骗它(即更新位置)每秒在服务器上进行一次,并确保他们可以在一秒钟内从 A 转到 B,等等)

问题 2)每隔一段时间(四分之一秒、半秒、整秒)您会发送一个数据包,其中包含其他玩家所做的环境更新以及NPC做了什么之类的。

问题 3) 开发然后配置文件。让它按照你想要的逻辑方式进行。然后,如果您发现可玩性太滞后,请致力于优化界面和网络层。你可能会发现它很好!

Question 1) Yes, but if you're doing real time movement like that, I would consider rendering it locally (using collision detection and what not) and then validation on the server to ensure they didn't cheat it (i.e. update the position on the server every second, and make sure they could have gone from A to B in one second, etc.)

Question 2) Every so often (quarter, half, full second) you send a packet with environment updates of what other players did and what npcs did and the like.

Question 3) Develop then profile. Make it the way you want it to logically. Then, if you find the playability is too laggy, work on optimizing the interface and networking layer. You might find it to be just fine!

ι不睡觉的鱼゛ 2024-10-26 01:22:38

一件重要的事情是在需要时加载资源。也就是说,在大多数 3D“移动”游戏中,在接近需要资源的对象时加载资源。

One important thing is to load resources when needed. That is, in most 3D 'moving'-games, load resources as approaching the objects needing them.

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