Search Unity

NavMesh Tutorial Resources

Discussion in 'Navigation' started by ChrisKurhan, May 4, 2021.

  1. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    I was browsing this subforum and noticed a lot of questions, even recently around relatively basic NavMesh functionalities. Since January I've been publishing tutorials that traverse all kinds of AI and Navigation topics in Unity. It starts at the beginning - creating your first NavMesh in Unity, and dives into more complex topics like runtime NavMesh generation. All tutorials have corresponding GitHub repositories at the LlamAcademy github page. These tutorials are mostly based on what I had to learn to implement a top-down survival shooter on Android and iOS, Llama Survival.

    Feel free to ask questions or suggest topics here, or on YouTube and I'll be happy to answer them!
    I don't know when the series will end, but as of time of this first post I'm on part 13 and there's still a lot to cover!
    Provided admins have no problem with it and the community is getting value, I will keep post updates as they come out into this thread.

    1. Introduction to NavMesh in Unity. Setting Up Your First NavMesh | AI Series Part 1
    2. NavMeshLink in Unity - Adding Jumping to NavMeshAgents | AI Series Part 2
    3. Adding Animations to NavMeshAgents | AI Series Part 3
    4. How to Dynamically Spawn and Place NavMeshAgents at Runtime | AI Series Part 4
    5. How to Configure Different Enemy Types With ScriptableObjects | AI Series Part 5
    6. How to Make NavMeshAgents Attack Nearby NavMeshAgents | AI Series Part 6
    7. How to Make a Ranged Attacking Enemy | AI Series Part 7
    8. Making Projectiles More Interesting | AI Series Part 8 - maybe not AI-specific, but related to real-world implementation of Ranged Attacking Enemies
    9. How to Configure AI Attacks with Scriptable Objects | AI Series Part 9
    10. Creating Flying NavMeshAgents | AI Series Part 10
    11. Implementing a Basic State Machine For Our AI | AI Series Part 11
    12. How to Find the Closest Target on a NavMesh | AI Series Part 12
    13. Procedural Level and NavMesh Generation | AI Series Part 13 - Linear Level
    14. Baking a NavMesh Area Around the Player - Runtime Baking Part 2 | AI Series Part 14 - Notes about performance can be found here and in 14.5
      1. How to Optimize Runtime NavMesh Generation | AI Series Part 14.5 | Unity Tutorial
    15. Spawning and Managing Enemies on a Procedural NavMesh | AI Series Part 15
    16. Connecting Pre-Baked NavMeshes on Additively Loaded Scenes | AI Series Part 16
    17. Better NavMeshLink Traversal | AI Series Part 17
    18. Add Burst Spawning Enemies to NavMeshAgent Spawner | AI Series Part 18
    19. Round Spawning and Scaling up Enemies | AI Series Part 19
    20. Weighted Random Enemy Spawning | AI Series Part 20
    21. How to Implement Enemy Abilities/Skills Part 1 | AI Series Part 21
    22. How to Implement Enemy Skills/Abilities Part 2: Fire Breath | AI Series Part 22
    23. How to Implement Enemy Skills/Abilities Part 3: Ice Lance | AI Series Part 23
    24. How to Implement Enemy Skills/Abilities Part 4: Poison Gas | AI Series Part 24
    25. NavMeshModifier and NavMeshModifierVolume In Depth | AI Series Part 25
    26. RTS-Style Drag Select, Click to Select/Deselect, and Movement | AI Series Part 26
    27. Make Your NavMeshAgents Smarter by Surrounding Their Target | AI Series Part 27
    28. Yes You CAN Have Moving NavMesh Platforms! AI Series Part 28
    29. Make a NavMeshAgent Hide or Take Cover From Other Objects | AI Series Part 29
    30. Moving AND Rotating NavMesh Platforms | AI Series Part 30
    31. Show Path to a Target With Third or First Person Controller | AI Series Part 31
    32. NavMeshAgent Avoidance in Depth - 5 Key Takeaways for Optimal Avoidance | AI Series Part 32
    33. NavMeshObstacle and NavMeshAgent - Together! | AI Series Part 33
    34. NavMeshAgent Keyboard Movement | AI Series Part 34
    35. Curved NavMeshAgent Paths | AI Series Part 35
    36. Upgrade Your AI With Door-Opening Capabilities | AI Series Part 36
    37. Make Your NavMeshAgents Destroy or Avoid Obstructions | AI Series Part 37
    38. Companion AI | AI Series Part 38
    39. Ragdoll Zombie NavMeshAgents | AI Series Part 39
    40. Jobs System Line of Sight Checking | AI Series Part 40
    41. Make (Mostly) Accurate Projectile Throwing AI at Moving Targets | AI Series Part 41
    42. Animate Your NavMeshAgents with Root Motion | AI Series Part 42
    43. Here's How You Can Find the OffMeshLinks a NavMeshAgent Will Take | AI Series 43
    44. Better Enemy Chasing with Intercept Courses | AI Series 44
    45. Visualize a NavMesh, In Game! | AI Series 45
    46. Which AI Behavior Framework Should You Use? | AI Series 46
    47. Enemy State Machine AI FULL IMPLEMENTATION | AI Series 47
     
    Last edited: Aug 22, 2023
  2. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Edited: Moved all links to top post
     
    Last edited: May 12, 2021
  3. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Edited: Moved all links to top post
     
    Last edited: May 12, 2021
  4. Corchado

    Corchado

    Joined:
    May 31, 2018
    Posts:
    9
    Thanks!!
     
    ChrisKurhan likes this.
  5. Corchado

    Corchado

    Joined:
    May 31, 2018
    Posts:
    9
    is it possible to generate a navmesh in the air?
     
  6. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    What do you mean by "In the air"? You can have a NavMesh generated on a collider without a MeshRenderer to appear to be "in the air"
     
  7. Corchado

    Corchado

    Joined:
    May 31, 2018
    Posts:
    9
    To generate a navmesh for the route of my aircarft
     
  8. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Without providing more than 1 liners of information about your project there's no way to help you on this.
    AI Series Part 10 went into making a flying enemy for a top-down style game. If you're talking about a flight simulator style game, a Unity NavMesh will not work because it requires you have relatively planar surfaces.
     
  9. Corchado

    Corchado

    Joined:
    May 31, 2018
    Posts:
    9
    Thanks for the advice
     
  10. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
  11. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week I've added a tutorial on how to Burst Spawn AI Enemies with 3 possible options:
    1. Spawn across entire level
    2. Spawn within same area as player
    3. Spawn within an arbitrary area
     
  12. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week I've added a tutorial on how to implement Weighted Random Enemy Spawning with ScriptableObjects. Updated main post with this link as well.
     
  13. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    I've added a new pathing tutorial - NavMeshModifier and NavMeshModifierVolume In Depth where I go over how these components work together, or independently to impact the pathing of your NavMeshAgents in the world to completely, or just generally avoid specific areas.
     
  14. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week you can learn how to implement an RTS-style drag selection box, how to issue movement orders to all selected NavMeshAgents, SHIFT+Click to add to, or remove from selection, and a simple way to show which units are currently selected. All of the selection is controlled via a SelectionManager singleton with automatically self-registering units.
     
  15. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    A new tutorial on how to make your AI surround their target instead of all racing to the center-point of the thing they're following is available now!
     
  16. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
  17. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
  18. shaldar

    shaldar

    Joined:
    Dec 21, 2016
    Posts:
    9
    Hi Chris - I think your AI series tutorials are terrific. I have gone through quite a few of them, including the ones with moving and rotating platforms. I am scratching my head with a particular problem though,,,,

    I want to dynamically add AI navmesh surface to only certain (convex) faces of a mesh. Anybody have any ideas on how to do that ?... or point me to code examples that do that ?

    Also - it will be great if you can delve into the nitty gritty of NavMeshBuildMarkup, sources and layermasks in your series because their documentation is quite confusing to me..
     
    ChrisKurhan likes this.
  19. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    I'll definitely add a deep dive into building your own build markups to the list of topics to cover!

    Regarding the question about only applying to specific convex faces....not sure how to achieve that. What comes to mind is grouping the specific faces as a new mesh under a surface and bake that with on collect objects children. I guess that's where the question about the deep dive of build markups come from. I'll think about it some more and if I can find a nice solution, I'll make that video!
     
    shaldar likes this.
  20. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week you can learn all about obstacle avoidance with Unity's Navigation system!
    The #1 most common question I've gotten since starting the AI Series back in February is

    How do I make my NavMeshAgents avoid each other?

    or some variant of that question. And well, it's a complicated answer. In this week's tutorial we're diving in deep into the depths of the Navigation System to see what are the root causes of agents pushing each other instead of avoiding each other, how to make agents better avoid each other, and how the avoidance works!
     
  21. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week I posted a new video about how to combine a NavMeshAgent and NavMeshObstacle to allow your NavMeshAgents to path more intelligently around crowded narrow pathways. Having the Agent and Obstacle both on the same component is a little tricky because you can end up with some really undesirable results. Unfortunately the NavMeshObstacle isn't as user-friendly as it could be, so we'll look at how to combine these two components together to get the path-blocking effect we're looking for.
     
  22. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    Great video series. Keep up the great work! :)
     
    ChrisKurhan likes this.
  23. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    AI Series Part 34 is up! Learn how to move NavMeshAgents with the keyboard! No mouse required. Click-to-move is not the only way to move NavMeshAgents and have them respect the bounds of the NavMesh. Using this simple technique you can easily move a NavMeshAgent on a NavMesh with the keyboard!
     
  24. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Happy new year all! AI Series Part 35 and Part 36 are now up! You can now learn how to make NavMeshAgents follow curved paths and open doors!
     
  25. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    It's been a little bit since I did an AI Series video... This week AI Series Part 37 will show you how to enable your NavMeshAgents to modify their environment by considering paths with destructible obstructions, breaking those obstructions, and continuing on their path!
    This is a more advanced tutorial so if it's not clear, make sure to check out some of the previous ones like:
    11: State Machine
    25: NavMeshModifier and NavMeshModifierVolume
    13-14.5 Runtime NavMesh Baking!
     
    DwinTeimlon likes this.
  26. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week you can learn about how to create Companion AI!
    A very common mechanic in video games is to have AI that follows around the player. Some, like we're implementing today, are relatively simplistic and simply follow the player, maybe attack things, and provide guidance and a sounding board for the player throughout the game. Some are more complex with their own complex behavior trees to manage commands issued to them and responding to complex scenarios.
     
  27. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    I'm really excited for this week's video about how to transition your NavMeshAgents into a ragdoll state on death! It ends up feeling really satisfying to see the AI get shot and transition, then eventually fade out!
     
  28. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    It's been a minute since the last installment, but I finally got to showing how to integrate the Jobs System with your NavMeshAgents to check for line of sight to a target in AI Series Part 40!
     
  29. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    AI Series Part 41 is up with some really cool stuff like Projectile Motion, AI with movement prediction of the player, and hitting the moving target with a projectile!
     
  30. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    This week I'm revisiting a topic covered long ago in the series, Animation!
    Previously I covered how to animate a NavMeshAgent where the Agent is driving the Animation. Today in AI Series Part 42 we'll look at the inverse, where Root Motion will move the NavMeshAgent while keeping the pathing benefits of the NavMeshAgent!
     
  31. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Great morning Unity Developers!
    It's been a little bit since I've updated this post, so just wanted to let you all know, 2 new videos for the AI Series have been uploaded.
    Part 43 - How to detect an OffMeshLinks on a NavMeshAgent Path
    Part 44 - Plotting an Intercept Course to a moving target

    Both of these were really fun and interesting to put together. I hope you get value from them!
     
    DwinTeimlon likes this.
  32. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    I'm sorry. I have been neglecting the Unity Forums.
    There have been 3 new parts of the AI Series since I last updated this thread (and another one on the way!)

    You can now learn in
    Part 45 - How to visualize a NavMesh in game.
    Part 46 - Which AI behaviour framework you should use for your game.
    Part 47 - See an end-to-end implementation of an Enemy AI with a State Machine.

    I hope you get value out of these new tutorials.
     
    PhamNuwenKZ likes this.