Shortest Path Considering Obstacles | AI Series Part 12

Опубликовано: 04 Август 2026
на канале: LlamAcademy
9,153
276

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:
   • Handles API - Scene View Text & Lines | Un...  

As usual with the AI Series, we're using the NavMesh Components: https://docs.unity3d.com/Manual/NavMe... not the built-in navigation system.

👨‍💻 As always, all code from this video is available on GitHub: https://github.com/llamacademy/ai-ser...

🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?sect...

🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:
🌟 Patreon:   / llamacademy  
🌟 YouTube Member:    / @llamacademy   or click the Join button on any video
📚 Take my Unity ShaderGraph Course:
https://www.gamedev.tv/p/unity-shader...
👕 Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/
💸 Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4
💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publishe... (affiliate)
💸 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sal... (affiliate)

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
09:21 Closing