Hi everyone.
I’ve created a Level that contains several “Patches” (so called “Areas” i think) of meshes that are combined into one big navmesh.
Now, my AI does have a “Chase” behaviour. basically, when it sees the player, it chases the player. Now, it seems as if when the AI tries to generate a path towards a player that passed over multiple of those “Areas”, the Pathfinding drops this Error: “Couldn’t find a close node to the end point”.
That makes totally sense to me - i guess that the seeker tries to generate a path from one Area to another (which of course is not possible), and therefore generates this error. I’ve read in other threads that a possible solution to make an NPC stick to his area (and only use all avaiable nodes on the area he is on) is to use NNConstraints, yet i failed to implement them.
Could anybody shine some light on this mysterious NNConstraints and how to use them properly?
Or maybe name a different approach to solve my problem and make an NPC stick and only generate paths in one area?
Thanks a lot upfront!
Cheers
EDIT:
Here is a Code snippet of my current path-generation for the chase behaviour (at the moment not using the generated nnInfo.pos as target, because it dropped null ref. errors):
GraphNode node = AstarPath.active.GetNearest(transform.position, NNConstraint.Default).node;
uint areaID = node.Area;
//Then you want to configure the NNConstraint to only return nodes which can be reached from the start node:
NNConstraint nn = new NNConstraint();
nn.constrainArea = true;
nn.area = (int)areaID;
NNInfo info = AstarPath.active.GetNearest((target.GetValue() as Transform).position, nn);
m_generatePath = false;
pathSeeker.StartPath(transform.position, (target.GetValue() as Transform).position, OnPathComplete);
m_currentRepathCounter = 0;