Active NavMeshAgent Avoidance - Run Away From or Around a Target | Unity Tutorial

3,453
0
Published 2024-04-30
AI pathfinding avoidance can be tricky. In this video you'll learn the basics of enhancing the built-in NavMeshAgent avoidance to have them walk around some targets or even run completely away from them!

👨‍💻 The full project for the Chicken Defense Microgame is available on GitHub for FREE: github.com/llamacademy/chicken-defense

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

📚 Resources:
⚫ NavMeshAgent Docs: docs.unity3d.com/2023.1/Documentation/Manual/nav-I… & docs.unity3d.com/2023.1/Documentation/ScriptRefere…
⚫ RVO2 Docs: gamma.cs.unc.edu/RVO2/
⚫ Chicken Defense on Itch.io: llamacademy.itch.io/chicken-defense

🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:
📚 Take my Unity ShaderGraph Course:
www.gamedev.tv/p/unity-shader-graph?affcode=45216_…

👕 Get yourself some LlamAcademy merch: llamacademy.myspreadshop.com/

Become a Supporter:
🌟 Patreon: www.patreon.com/llamacademy
🌟 YouTube Member: youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video
🌟 GitHub Sponsor: github.com/sponsors/llamacademy

Use these affiliate links to do your Asset Store / Humble Bundle Shopping!
💸 Check out the latest Humble Bundles www.humblebundle.com/software?partner=llamasoftwar…
💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! assetstore.unity.com/publisher-sale?aid=1101l9QvC
💸 Save up to 50% on NEW Assets: assetstore.unity.com/?new_sale=true&orderBy=1&aid=…

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

#unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment

Chapters:
00:00 Topic Introduction
00:22 NavMeshAgent Avoidance
01:07 How We'll Do It
01:44 Demo of the functionality
02:34 Active Avoidance - EnemyMoveState.cs
05:04 Run Away Configs
05:28 A Closer Look
06:08 Understanding Which Llama(s) to Run Away From
06:46 More Complex Considerations
07:32 How to Suppor

All Comments (17)
  • Searched the whole evening for this solution. Simple, good explanation, nice visuals, great video!
  • @Qornv
    Absolute king with these in-depth tutorials
  • @user-ij6el8gw5y
    I honestly don't understand why don't you have million subscribers.... Hope you will!!
  • @andaoking
    can you maybe make a tutorial on enemie formations😊
  • @dico3557
    Had to tear it up for my own use, but works pretty good. Not perfect, but really good.
  • @Hazzel31337
    nice video gave me an idea for a game, i used your unity asset store referal link to buy rayfire, hope it helps as a little thanks
  • @bokuwa_Tobi_0210
    Bro I have got an issue. I have created an ai script which wander along random wander points over the navmesh. However, sometimes the wander points are invalid and the ai does not move to the wander point and remains stationary at his position unless I manually move it to the wander point's position from the scene view. I would be very glad if you can help me...
  • @vatyunga
    So it's possible to make a boids like avoidance on top of desiredVelocity? And it's probably possible to completely disable acceleration using agent.velocity = desiredVelocity.normalized * _speed?
  • @silchasruin4487
    Who ME? Haha, I've been kicking myself trying to figure out a more performant way to use pathfinding to avoid the jostling and overlapping of Unitys navmesh agents. I'm trying to see if I can't figure out a way to implement RVO2 type of avoidance and collision detection while piggybacking off of Unitys default NavMesh Component.
  • @syedahmedmalik
    Your tutorial is Amazing, EVERY ON IS!!! Great Work and keep it up man! Suggestion : There seems to be background music but it's volume is very low. Your voice was overpowering it. I like tutorials with interesting music and maybe more sounds when you say something important or stuff. That way it will be more engaging like look at Dani or Thomas Brush. Cheers,
  • @dkordy
    Can you please please dont be like others, when displaying code enlarge little bit, please. Its to dificult to see what is writhen. 😊❤