Imagine that an archer needs to be at least 3m away to be able to shoot his target, but he cannot be further away than 10m. So he must find a valid location inside this radius (in 3d of course).
So, what I need is a method that returns me the nearest (reachable) point on my nav mesh with a clear line of sight that is inside the radius.
I was thinking about always using the cirlce edge as an starting point for my calculations. Since this should always be the closest point. But this does not work in this example:
Since there is no direct line of sight at the cirle edge I cannot take it as an starting point.
I was also thinking about just picking random points (like 5000), checking if they have line of sight and checking the distance to the archer. But this is of course a horrible solution.
How can I find this magical point?
(I don't need a script but an idea :D)
Edit: It is not required to have a valid path to the target. If e.g. a river is in the way the archer wont be able to pathfind to his target. But he can still shoot over the river. Meaning he can find a valid spot.