Gte Nearest Node That has a Certain Tag

I am trying to find the nearest node that has a certain tag. But it’s not getting anything. Let me know what I am doing wrong. Can I also specify that the node needs to be walkable ?

var constraint = new NNConstraint();
constraint.constrainTags = true;
constraint.tags = 1 << 1; // node should be tagged 1

var strainNodeInfo = AstarPath.active.GetNearest(_transform.position, strainConstraint);
if (strainNodeInfo.constrainedNode != null)
{
Debug.Log(“Found constrained node”);
}

Also, what is an area ? Is it a region of nodes all tagged the same or something else ? I didn’t quite understand how areas work.

Hi

The constrainedNode field is an internal field (sort of), try checking the .node field instead. All NNConstraint constraints can be used at the same time.

Areas are automatically calculated connected components in the graph. Each connected component is assigned a unique index.
This can be useful if you want to find the closest node that can be reached from a specific node (their area values should be the same). See https://en.wikipedia.org/wiki/Connected_component_(graph_theory)