Path node is not same as GetNearstNode when moving on the path

In some points they are not same. It may because of using modifiers ?

How can I get exact node of the path in AI position ? (The AI is following the path)

Hi

Unless you are using the AILerp movement script then the ai will follow the path smoothly and may not move over exactly the nodes in the calculated path.

You can get the closest walkable node to a point using

var info = AstarPath.active.GetNearest(somePoint, NNConstraint.Default);
GraphNode node = info.node;
Vector3 closestPointOnNavmesh = info.position;

somePoint could for example be ai.position

@aron_granberg I have my custom movement script and I use modifiers, It is really annoying I can’t find out when I reach the NodeLink. What should I do ? Also I know by RichAI we can find out NodeLinks but I don’t use it.

I tried to tag nodes which have intersection with start and end of NodeLink, then by GetNearest find node with that tag and make a boolean true then store the next node on the path (Which is definitely end of link) and whenever AI reach that node make that boolean false. With this I can figure out start and end of NodeLink but sometimes GetNearest doesn’t return exactly same node of path.

Tag start and end point:

public class GraphUpdateLink : MonoBehaviour {
        [SerializeField] private Transform EndPoint;

        // Start is called before the first frame update
        void Start() {
            AstarPath.active.AddWorkItem(_ => {
                AstarPath.active.GetNearest(transform.position).node.Tag = 2;
                AstarPath.active.GetNearest(EndPoint.position).node.Tag = 2;
            });
        }
    }

In each frame check node tags and perform that stuff which I already talked about:

private void CheckLinkNodes() {
            if (Path == null)
                return;

            var node = AstarPath.active.GetNearest(transform.position).node;

            if (NextLinkNode == null && node.Tag == 2) {
                var nextNode = Path.path[Path.path.IndexOf(node) + 1];
                if (nextNode.Tag == 2) {
                    NextLinkNode = nextNode;
                    IsLinkNode = true;
                }
            }

            if (NextLinkNode != null && node == NextLinkNode) {
                NextLinkNode = null;
                IsLinkNode = false;
            }
        }

What is the solution ? I’m really stuck.