Hi guys!
I just want to know if the API (for a PointGraph) is capable of getting the nearest node from another node instead of the nearest node from a position.
Sorry for my english, not my primary language.
Thanks!
Hi guys!
I just want to know if the API (for a PointGraph) is capable of getting the nearest node from another node instead of the nearest node from a position.
Sorry for my english, not my primary language.
Thanks!
Hi
The nearest node to a node is always that node, which is probably not what you want. So you can make an NNConstraint that specifically excludes that node.
public class NNConstraintExclude : NNConstraint {
public GraphNode node;
public override bool Suitable (GraphNode node) {
return node != this.node && base.Suitable(node);
}
}
NNConstraintExclude nn = new NNConstraintExclude();
nn.node = someNode;
var closestOtherNode = AstarPath.active.GetNearest((Vector3)someNode.position, nn).node;
Sorry I was not at my home, I just tested all your stuff, work very well!
Thanks mate, awesome support!