Closest navigable point along line

Given a valid navigable point, I’m trying to find the closest point along a vector (dir + length) from the valid point. Any ideas?

Cheers,
Shane

There are a few functions for that in the project actually.
Try http://arongranberg.com/astar/docs/class_pathfinding_1_1_mathfx.php#a2926797ed93d260436300fda33d60875 or the other variations of the function in that class.

Hi,

Reading my initial post, I don’t think I articulated myself well. What I MEANT to say, was I want the closest reachable point along a vector, given a source navigable point.

The interior of the box is all walkable, the exterior isn’t.

p = valid walkable point
V = some collision vector/ray
p’ = closest walkable point along the ray.

If I get this, I can code formations.

Consider:
`

[---------------------]
| ]
| ]
| V ]
| p---------p’]------->
| ]
| ]
| ]
[---------------------]

`

If you own the pro version you could use graph raycasts.
http://arongranberg.com/astar/docs/class_pathfinding_1_1_grid_graph.php#ac4525554619119cb08d6f8ffad8b8c92
It requires that you specify an endpoint, but you could simply set the endpoint to a point some far distance along the ray.
The GraphHitInfo which can be got will have all the information you need. In this case the hit point.
Vector3 furthestPoint = ray.GetPoint(10); GridGraph graph = AstarPath.active.astarData.gridGraph; GraphHitInfo hit; if (!graph.Linecast (ray.origin, ray.GetPoint (10), null, out hit)) { furthestPoint = hit.point; }

Great, I do own the pro version, so I’ll check that our right away. :slight_smile: