在多人游戏中同步 AI NPC

发布于 2024-10-06 13:33:01 字数 386 浏览 5 评论 0原文

我已经开始开发一款小型多人赛车游戏,显然我们正在使用《半条命》、《雷神之锤》和《虚幻》中使用的所有玩家预测、航位推算和滞后补偿技术 - 但我们也计划在游戏中拥有数十辆人工智能汽车。

最初,我们决定简单地向所有客户端发送随机种子,他们将计算 AI 位置等 - 然而,我们遇到了以下问题:

  1. 所有客户端都会收到运行 AI 汽车的种子
  2. 客户端仅收到其行内玩家的移动更新 现在
  3. 玩家 A 击中 NPC 汽车
  4. 玩家 B 进入玩家 A 的视野

,由于玩家 B 没有接收到玩家 A 的移动,他会假设 AI 汽车仍在按其应有的方式移动,并且不会计算玩家 A 的事实其中一辆撞车...

长话短说 - 如何同步受玩家影响的 AI 单位?

I've started developing a small multiplayer racing game, obviously we're using all the player prediction, dead reckoninng and lag compensation techniques that Half Life, Quake and Unreal use - however we plan on having dozens of AI cars in the game as well.

Initially we decided to simply send a random seed to all clients and they will calculate AI positions, etc - however, we've reached the following problem:

  1. All clients receive a seed to run AI cars
  2. Clients only receive movement updates for players within their line of sight
  3. Player A hits an NPC car
  4. Player B enters player A's frame

Now since player B didn't receive player A's movement, he'll assume the AI car is still moving as it should, and wouldn't calculate in the fact that player A hit one of those cars...

So long story short - how can you synchronize AI units that were affected by players?

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

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

发布评论

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

评论(1

酒几许 2024-10-13 13:33:01

据推测,您的服务器知道任何冲突。在这种情况下,只需将碰撞结果通知给所有客户端即可——本质上是在碰撞点用新的方向、速度、RNG 种子等在客户端上重新植入 AI。

Presumably, your server is aware of any collisions. In that case, simply notify all your clients of collision results--essentially re-seeding the AI on the clients, at the point of the collision, with the new directions, velocities, RNG seeds, etc.

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