简体   繁体   English

使用unity的A *寻路插件,但AI不会移动或方向错误

[英]Using unity's A* pathfinding plugin but the AI doesn't move or moves in a wrong direction

I'm learning to use the A* pathfinding plugin . 我正在学习使用A *寻路插件 I've successfully made a demo on an X/Z plane. 我已经成功地在X / Z平面上进行了演示。 As the project I'm working on is actually a 2D game, I want to use the plugin on the X/Y plane. 由于我正在从事的项目实际上是2D游戏,因此我想在X / Y平面上使用该插件。 However, while it works perfectly on an X/Z plane, it doesn't work well on the X/Y plane. 但是,尽管它在X / Z平面上可以完美工作,但在X / Y平面上却不能很好地工作。

All the scripts used, AstarPath.cs , Seeker.cs , AIPath.cs , are the original scripts from the A* pathfinding project and the version is v3.7 . 使用的所有脚本AstarPath.csSeeker.csAIPath.cs都是A* pathfinding project的原始脚本,版本为v3.7

Then I followed these instructions . 然后我按照这些指示进行

When I click Run to run the game, the AI does calculate a correct path: 当我单击Run以运行游戏时,AI会计算正确的路径: 在此处输入图片说明

but then the AI moves in the wrong direction: 但是AI却朝错误的方向前进:

在此处输入图片说明

When it moves, it also keeps calculating its path. 移动时,它还会继续计算其路径。 What should I change to fix the problem? 我应该改变些什么来解决这个问题?

AIPath.cs is hard-coded for the XZ plane. AIPath.cs被硬编码为XZ平面。 You will need to either make your game on the XZ plane, modify AIPath.cs, or create your own path-following script. 您将需要在XZ平面上制作游戏,修改AIPath.cs或创建自己的路径跟踪脚本。 Tell me if you would like guidance on how to do this. 告诉我您是否需要有关操作方法的指导。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM