Hiding AI - Take Cover Behind World Geometry | AI Series Part 29




Published: 21 Sep 2021

Learn how to make NavMeshAgents find valid cover spots from another target object. In this video we'll specifically use a Player, but this can be applied to hide from any object - a grenade for example. Together we'll create a configurable script that allows us to refine which objects are valid to hide behind and exclude those that are not.


We'll add the following possible configurations:

⚫ Layers of objects to consider for cover, and to hide FROM

⚫ Radius to check for objects to hide behind, and FROM

⚫ Size of objects to hide behind

⚫ Distance from object cover must be

⚫ How good of a hiding spot it must be to take cover

⚫ How frequently to check for new hiding/cover spots


🔶 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-29

🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


📚 Resources:

🟠 You can also check out AI Series Part 11 where we used the Dot Product to control enemy gaining line of sight of the player: https://youtu.be/3hXkdARwREo

🟠 C# Comparison Delegate reference: https://docs.microsoft.com/en-us/dotnet/api/system.comparison-1?view=net-5.0

🟠 C# CompareTo reference: https://docs.microsoft.com/en-us/dotnet/api/system.single.compareto?view=net-5.0


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.


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.