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
👨💻 As always, all code from this video is available 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.
🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:
🌟 Patreon: https://www.patreon.com/llamacademy
🌟 YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video
📚 Take my Unity ShaderGraph Course:
https://www.gamedev.tv/p/unity-shader-graph?affcode=45216_kuvg0bp7
👕 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/publisher-sale?aid=1101l9QvC (affiliate)
💸 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC (affiliate)
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.