But you can calculate the length of the generated path and if it’s “much” longer than the sum of paths to the closest wall + path from closest wall to final destination, then attack said wall.
sorry not reply soon, i was busy on something else
so . for now i try to calculate a path before RichAI.SetDestation. (so that if the path is to long then ignore the target).
but i can’t get the right path.
what i do is:
//Call for path calucalte
var p = ABPath.Construct(startPos, endPos, OnPathComplete);
AstarPath.StartPath(p, true);
Debug.DrawLine(startPos, endPos, Color.white, 2f);
private void OnPathComplete(Path p)
{
GameFunnelModifier.Instance.Apply(p); //Global GameObject with FunnelModifier attach
for (int i = 0; i < p.vectorPath.Count - 1; i++)
{
var s = p.vectorPath[i];
var e = p.vectorPath[i + 1];
s.y = e.y = 2f;
Debug.DrawLine(s, e, Color.green, 2f);
}
}
the white line is showing the start and end pos i was request for path calculate.
the green line the path result with FunnelModifier.