Detecting the Node Link

Hi, I’ve recently started using this and I was wondering if there a way to make a certain action play while the Ai is in a certain part of the map or performing a certain action.

I read in the script for Node Link 2 that you can detect if you are on this node. How would I be able to go about doing this? I would like to play a jump animation or be able to increase the movement speed while on the jump node for example. Thanks in advance.

Hi

If you are using the RichAI movement script (which is the only one that has some reasonable support for off mesh links I’m afraid) you can use the RichAI.onTraverseOffMeshLink callback.

Still it is not possible if it is not RichAI and it is custom one ?

@aron_granberg I really need your answer.

Hi

The movement scripts other than RichAI do not have support for detecting off mesh links at the moment.

If you have a node reference you can detect if it is part of a link by using the NodeLink2.GetNodeLink static method which will return null if it is not part of a link.

Also please do not spam the forum to bump the topic. As the forum banner clearly indicates I am currently on vacation and I am not able to answer forum posts as frequently as usual.

I use Link1 on grid graph.
What if I tag nodes which start and end points of links are on them ?
How did you implement it in RichAI and can’t have it in custom or other movement scripts ?

Hi

Link1 cannot be detected by any script. It is indistinguishable from the normal links in the pathfinding graph. NodeLink2 can be detected using the method I described above (and this is what RichAI does).
You can tag the start and end I suppose, but there may be cases where the path just moves across one of them but doesn’t go through the link.

@aron_granberg I get reference to node with GetNearest and then when I use it in NodeLink2.GetNodeLink, it always return null.

Could you explain more how to achieve what you did in RichAI in my custom movement script ?

Edit: As I noticed because it doesn’t get nearest one on point graph. How can I find out what is the current graph which ai is on it ?

You can get the closest node on a specific graph using

var nn = NNConstraint.Default;
// Search only the fourth graph (index 3)
nn.graphMask = 1 << 3;
AstarPath.active.GetNearest(point, nn);

You can find out which graph a node belongs to by accessing its node.Graph property.
See https://arongranberg.com/astar/docs/graphnode.html#Graph