5

Consider the following situation.

There is a predefined area inside NavMesh that AI agent must reach. For convenience - it is circular area.

To find the closest point of the area is pretty straightforward task. No, I need to find the shortest path to an area.

In the picture example the closest point obviously requires from an agent to travel further than optimal distance is.

So, how to calculate desired destination point in such situation?

Do I have to implement a wave propagation algorithm myself? Use the A* instead of built-in NavMesh? Are there any simple solutions involving Unity3D tools?

Note: desired area is just an abstraction defined by (Vector3) position and (float) radius, not an actual object in game scene.

Xamtos
  • 173
  • 9
  • 2
    Maybe some heuristic: 1. Divide your circle into for example 8 parts like a pizza 2. Calculate the centre point of the circle edge of each part. 3. Calculate 8 paths to these points and choose the shortest. You can try to combine `NavMesh.CalculatePath` and `NavMeshPathStatus` to calculate the path distance. The more parts the more accurate the result. – Panda Strong Jul 08 '20 at 09:23
  • 1
    @PandaStrong, It is definitely an option, however, I'm concerned about performance of this solution. Calculating 8 paths at once looks not very friendly performance-wise. And if I'd need to improve accuracy - paths count could increase substantially. – Xamtos Jul 08 '20 at 09:45

0 Answers0