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:
11 views
92
41
1 day ago 00:02:24 2
Charlie’s Angels BRAND NEW EPISODE (2025)!
1 day ago 00:02:43 2
Charlie’s Angels: MIND CONTROL (Episode 1)
1 day ago 00:01:42 2
Charlie’s Angels: Brand New Parody Series Teaser
1 day ago 00:30:28 2
Vadym Novynskyi: Zelensky’s Mission to End Christianity in Ukraine & Why America Is Still Funding It