在多人游戏中同步 AI NPC
我已经开始开发一款小型多人赛车游戏,显然我们正在使用《半条命》、《雷神之锤》和《虚幻》中使用的所有玩家预测、航位推算和滞后补偿技术 - 但我们也计划在游戏中拥有数十辆人工智能汽车。
最初,我们决定简单地向所有客户端发送随机种子,他们将计算 AI 位置等 - 然而,我们遇到了以下问题:
- 所有客户端都会收到运行 AI 汽车的种子
- 客户端仅收到其行内玩家的移动更新 现在
- 玩家 A 击中 NPC 汽车
- 玩家 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:
- All clients receive a seed to run AI cars
- Clients only receive movement updates for players within their line of sight
- Player A hits an NPC car
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据推测,您的服务器知道任何冲突。在这种情况下,只需将碰撞结果通知给所有客户端即可——本质上是在碰撞点用新的方向、速度、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.