导致这种Astar节点基本探索结果的可能错误是什么?

发布于 2025-02-03 11:40:41 字数 434 浏览 2 评论 0原文

我正在使用Unity使用Astar探索插件,并且在获得此结果之前,它以前很漂亮。

请参阅Unity编辑器视图的屏幕截图,蓝色节点是步行区域,黄点是起始位置,而目标节点是星形图标所在的位置。因此,所需的方式应该是绿线,但实际结果是红线。

我知道这不是插件的问题,但是我多次检查了我的代码,找不到任何问题,并且在其他情况下效果很好。

更奇怪的是,如果我删除紫色区域中的可步行节点,则插件可以找到正确的方法。

我想知道可能导致这一结果的可能发生的错误,任何线索都会被涉及。谢谢。

I'm using a AStar pathfinding plugin in Unity, and it works prety well previously until I got this result.

Please see the screen shot of Unity Editor view, the blue nodes are walkable area, the yellow point is the starting position, and the target node is where the Star icon is. So the desired way should be the green line, but the actual result is the red line.

I know it's very possible that it's not the problem of the plugin, but I checked my code many times and can't find any problem and it works well in other cases.

what is even more strange is that if I remove the walkable nodes in the purple area, the plugin finds the right way.

I'd like to know what is the possible mistake that could lead to this result, any clue would be appreicated. Thanks.

enter image description here

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

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

发布评论

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

评论(1

染火枫林 2025-02-10 11:40:41

可悲的是,我无法远程调试您的图形,但是我会逐渐检查您当前的开始位置的许多路径,在此过程中,它切换到正确的路径并诊断哪些节点是断开连接的。

也许有些节点升高或阻塞。

简而言之,请尝试调试游戏网格,以最小的可再现的越野车行为和一个工作的行为,并试图了解它们彼此之间的不同之处。

关于a*的内部工作的一些基本提示:

  • 如评论中所述,不能保证A*产生最佳路径(例如,当节点的重量负重时)
  • 它考虑了许多路径,并且可能会在奇怪的路线上进行计算行走(取决于奇怪的路线(取决于)在启发式上)

I sadly can't debug your graph remotely, but I would check many paths from your current start position gradually towards the goal, where it switches to a correct path and diagnose which nodes are disconnected.

Maybe some nodes are elevated or obstructed.

In a nutshell, try to debug your game grid to a minimal reproducible buggy behaviour and a working one and try to understand where they differ from each other.

Some basic hints on the inner workings of A*:

  • As mentioned in the comment, A* is not guaranteed to produce the optimal path (e.g. when nodes have negative weight)
  • It considers many paths and might amidst the calculation walk on strange routes (depending on the heuristic)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文