Support Forum

Get the on-grid position under/over a target point

I’m using a grid graph and want to set AIs towards some randomly picked scene objects (waypoints, areas to inspect, etc.)

I cannot guarantee that these objects are actually on the graph, and I’ve found that this leads to the AI going to the destination and then circling around it, because it can’t reach the actual target point some metres up in the air.

Is there a built-in function that I’m missing to say “go to this destination but ignore Y” or “here’s a point, give me the closest point that’s actually on the grid” ? Or should I just use reachedEndOfPath instead of reachedDestination?

I am using AIPath and Seeker components.

That you can do using

AstarPath.active.GetNearest(myPosition, NNConstraint.Default).position

See AstarPath - A* Pathfinding Project

1 Like