DoSomething every time I hit a node?

Hey all, just looking to see of there’s a simple way to call functions and whatnot every time my player reaches a node. I’m using the lerp pathing to hit the center of every node as I walk, and I want to call some functions every node that is traveled. So if I am targeting a node that is 5 nodes away, and every node I pass along the eay I am calling a function, so that function should be called 5 times.

I imagine there’s a super simple way to do this that I’m not finding. Any help?

Hi

Sorry for the late reply.

There’s no built-in event for this, however you could add a script and do something like this:

GraphNode lastNode;
void Update () {
    var node = AstarPath.active.GetNearest(transform.position, NNConstraint.Default).node;
    if (node != lastNode) {
        lastNode = node;
        OnEnterNewNode(node);
    }
}

Might be good enough, I’ll give it a try! Thanks!