Shortest Path Considering Obstacles | AI Series Part 12
Published: 27 Apr 2021
In this video I show how to correctly choose a target to move to that is CLOSEST to the NavMeshAgent, checking the distance the NavMeshAgent would actually travel, not simply the Vector3.Distance between the two points. I also explain the crucial difference between the two and why, if you want the NavMeshAgent to travel the shortest distance, you have to do it this way. We'll utilize NavMesh.CalculatePath and NavMeshPaths to calculate the total distance a NavMeshAgent would travel to a given point, and compare which is closest.
Want to learn about the editor visualization? That’s covered here:
As usual with the AI Series, we're using the NavMesh Components: https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html not the built-in navigation system.
🔶 ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out 🙂
👨💻 Get the FULL FREE PROJECT on GitHub: https://github.com/llamacademy/ai-series-part-12
🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
Chapters
00:00 Intro
01:08 Scene Overview
02:21 MoveToClosestTarget.cs
06:46 Agent Setup
07:12 Demo and Distance Explanation