Hi!!
I just started recently to use the free version of A* Pathfinder project, and it’s really awesome!! but i’ve a found aproblem that i can’t solve by myself.
I’ve 1 Grid Graph created on my map, the obstacles work fine, and the grid works nicely. I’ve setup an area with a tag with the Graph Update Scene Script; and the problem comes here.
I’ve an AI with the Seeker configured so it can’t pass through the tagged area, and it happens that when i place the target of this AI inside the tagged area, the console says: “Path Failed : Computation Time 2.00 ms Searched Nodes 48 Error: Searched whole area but could not find target”
Question: It’s there a way for the AI to approach the target as much as possible without entering the tagged area???
Here there are some pictures of my map:
Here you can see the grid graph, the capsule it’s the AI, the red line it’s the tasgged area with the GUS Script and the 3 arrows are the gameobject that represents the target i want the AI to approach. I know the AI can’t go to that point (because it’s in a tagged area), but it’s there a way so it can approach to the closest node of the target??
Here’s the code i use to see if it can reach the target:
// With this i select a random position as a target
Vector3 randomPosition = BarManager.instance.tavernCenter + Random.insideUnitSphere * 5;
randomPosition = new Vector3(randomPosition.x, 0, randomPosition.z);
Debug.Log("randomposition: " + randomPosition);
//Find the node the character is standing on
GraphNode node = AstarPath.active.GetNearest(transform.position, NNConstraint.Default).node;
// Configure an NNConstraint
// which makes sure the resulting node can be reached from your character
NNConstraint constraint = NNConstraint.Default;
constraint.constrainTags = true;
constraint.constrainArea = true;
//constraint.constrainWalkability = true;
constraint.tags = ~(1 << 2);
constraint.area = (int)node.Area;
NNInfo closestOnGraph = AstarPath.active.GetNearest(randomPosition, constraint);
Vector3 closestPoint = closestOnGraph.clampedPosition;
GraphNode closestNode = closestOnGraph.node;
Debug.Log("Node position: " + BarManager.instance.idleHelper.transform.position);
BarManager.instance.idleHelper.transform.position = (Vector3)closestNode.position;
myAstar.target = BarManager.instance.idleHelper.transform;
`
GUS setup , i’ve call the tag Bartenders, and it’s the second Tag.
Thanks!!