工作在一个统一2D自上而下的游戏与阿隆格兰伯格A*寻路资产。有人知道我怎样才能让探索者剧本的敌人互相回避吗?目前,他们将相互聚集,我想避免这种情况。
在下面的照片中,你可以看到绿色线,显示AI目标设置器目标。它正确地跟随着玩家,但是正确的立方体试图直接穿过红色立方体。我如何才能改变它,使寻求者彼此回避,但仍然跟随玩家?
public class AIDestinationSetterHyperius : VersionedMonoBehaviour {
/// <summary>The object that the AI should move to</summary>
public Transform target;
IAstarAI ai;
public void OnEnable () {
target = GameObject.FindWithTag("Player").transform;
ai = GetComponent<IAstarAI>();
if (ai != null) ai.onSearchPath += Update;
}
public void OnDisable () {
if (ai != null) ai.onSearchPath -= Update;
}
/// <summary>Updates the AI's destination every frame</summary>
public void Update () {
if (target != null && ai != null) ai.destination = target.position;
}
}
发布于 2022-08-05 02:56:19
如果我正确地理解了这一点,那么看起来您需要的是局部回避,它只在软件包的Pro版本中可用。
https://stackoverflow.com/questions/73243492
复制相似问题