Closest valid point on graph, to given Vector3?

Hello,

I have a situation with both Recast Graph and Grid Graph, that I am trying to find the best solution for.

  • I want to tell object A to move to object B.
  • The coordinate I give for B is it’s center position on the ground.
  • Object B is in a layer mask for the graph, and therefore inaccessible directly to object A.
  • I want object A to come as close as possible to the given waypoint and stop. Currently, it will walk into walls or start going in circles.

Do I just need to increase the collision detection size? I feel like this might have other unintended consequences, like messing up how it follows waypoints. Is there a way to perhaps query what a valid waypoint, on the graph, closest to the given Vector3, is?

Thank you.

Hi

This should be the default behavior if you just try to make the object move to a point assuming the Seeker → Start End Modifier → End Point is set to ‘ClosestOnNode’ (default) or ‘SnapToNode’.

Hard to say if this is an issue without seeing the graph in question.

Yes, that can be done. See A* Pathfinding Project
Note that this is already done internally when you request a path to a point.

1 Like