Support Forum

GridGraph edges and GetNearest question

In the screenshot below, I have a NPC standing at point X. I’d like him to path toward point A, which is outside of the graph. Using the GetNearest function on point A will result in point B being returned. However, the NPC is not capable of pathing to point B, since it’s inaccessible. Ideally I’d want him to path to either of the point Cs. I’ve been wracking my brain on this, and I’m curious if there is any sort of relatively simple way to make this happen?

GridQuestion

Never mind – I found my answer in the form of the “maxNearestNodeDistance” property, as described in the post linked below. This negates the need for GetNearest, since increasing maxNearestNodeDistance allows me to find a path directly toward A.

1 Like

As it turns out, I actually do have a question here. The method that I used doesn’t always work as well as expected. In the below screenshot, I have an NPC standing at point X. I’d like him to path toward point A, which is outside of the graph. Ideally, he would path to point C, which is the closest point within the graph to point A to which he can walk. Instead, he paths to point B, as if he is attempting to path through a non-walkable area. Any ideas on this one?

Hi

I would argue that point B is the closest point inside the graph that the agent can reach. C is a bit further away using euclidean distance.