Make a NavMeshAgent Hide or Take Cover From Other Objects | AI Series Part 29 | Unity Tutorial

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: 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:
Back to Top