I would like to find a way to shoot a target from potential points around the target.

What I do is:

- First, I check on the navmesh if there points I’m looking for are walkable.
- If they are walkable, I calculate a path to the point.
- If the path can be completed and walked on (no holes, walls blocking the way): I save the point as a valid option.

Finally, I create a path from the starting point to the end point and make the NavMeshAgent use that path.

This is what I did using the navmesh system. It seems quite brute force so if anyone has a better idea I’m all ears, because I plan on using this sort of movement for almost any shooter.

What I like about this algorithm, is that I can pick the distance I want from the target.

With Unity’s NavMesh system I used 2 functions and everything was calculated during one frame:

```
// 1) find a valid point on the navmesh
NavMesh.SamplePosition(testPosition, out var navMeshHit, maxDistance, NavMeshConstants.WalkableArea);
// 2) can we reach that point of the navmesh
if (found)
{
var navMeshPoint = navMeshHit.position;
Agent.CalculatePath(navMeshPoint, path);
if (path.status == NavMeshPathStatus.PathComplete)
{
}
}
```

My question is two-fold:

- Is there a smarter/more optimized way to achieve something similar?
- How do I do this the Astar way? (which functions do I use?.. How can I calculate this in one frame?)