Surround AI - Circle a Target | AI Series Part 27




Published: 07 Sep 2021

Learn how to make your NavMeshAgents SURROUND their target, instead of just running to the center point of their target. In this tutorial we'll be implementing a simple solution to the "dumb AI" problem where your NavMeshAgents get bunched up and create a funnel or wedge when trying to follow a target.


We'll implement a simple AI Manager singleton that will set the destination of NavMeshAgents to specific points around the player at a defined radius. We'll learn a little bit of math about how the Unit Circle and Mathf.Sin (Sine) and Mathf.Cos (Cosine) trigonometric functions can help us solve this problem without a bunch of raycasting or list manipulation.


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.


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

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


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.