We have an issue in our game where units will think they’re on the node layer above them - causing incorrect paths, and causing the unit to try and get to the first point of the path above itself.
Upgrading to the latest version and hoping for a fix isn’t viable right now - but regardless first off I’d like to know if there are any basic things to sidestep if this issue is happening. Any ideas?
Where is the pivot point of that character (or rather, the point from which the paths are searched). I would recommend that you put it near the character’s feet to avoid these issues.
Included are the Seeker settings and the node graph settings it’s using. I’m paused in the scene here and can provide other details if you’re online now
In my implementation I’d been using custom node blockers to remove nodes within a bounds around an enemy - resulting in enemies having no very close nodes within reach. I’ve discovered that GetNearest seems to jump to a higher layer if there aren’t any nodes very close by. So I’ve scratched that implementation.
I’m now trying to use the tag system to add a tag volume around enemies, and allow the current enemy to traverse that tag, while disallowing other enemies. This seems like a better idea.
However currently I’m struggling to get the nodes to update and take into account the tag volumes that are being created. I’m doing it the same way I was previously cutting nodes, like so;
Setting the tag to basic ground, reapplying, and then moving it - seems to do the trick. Thanks. Will report back on if this helps with my Layer issue.
The issue is, Seekers will prioritize the layer above themselves for the nearest node if they don’t have any immediately close nodes next to them (they even ignore nodes 1-2 Unity units right next to them)
As you can see in the picture, ideally the Seeker should be weighted to grab the nodes that are 1-2 Unity units away on the same layer as themselves.
Is there some sort of value to change that allows Seekers to increase the size of the nearest node check? Or perhaps some more nuanced get nearest node code?
Hm… Ok so it might be that the layered grid graph is giving up after it has found a valid node. As a performance optimization it only searches outwards for 2 more nodes (radius) after it has found a good node.
You can increase this value in the GridGraph class, but a better solution in your case might be to use a custom NNConstraint to make sure this doesn’t happen.
public class MyNNConstraint : PathNNConstraint {
public float yCoord;
public float someThreshold = 2;
public override bool Suitable (GraphNode node) {
return base.Suitable(node) && Mathf.Abs(((Vector3)node.position).y - yCoord) < someThreshold;
}
}
Where you would set this like
var path = ABPath.Construct(...);
path.nnConstraint = new MyNNConstraint {
yCoord = transform.position.y;
constrainArea = true;
};
This will make sure it will not pick any nodes that are further away on the y axis than “someThreshold” world units.