NavMeshObstacle and NavMeshAgent - Together! | AI Series Part 33 | Unity Tutorial

11,002
0
Published 2021-11-16
Learn how to control NavMeshAgents and NavMeshObstacles on the same GameObject! Sometimes the NavMeshAgent obstacle avoidance isn't enough, and you need an Agent to fully block the path so other Agents will find a new path. In this tutorial we'll look at how to combine the NavMeshAgent and NavMeshObstacle components so they work together without teleporting issues.

💸 Ongoing sales 💸
⚫ See all active asset sales on the Asset Store: assetstore.unity.com/?on_sale=true&orderBy=0&rows=…
⚫ Save 25% off your first Asset Store Order: prf.hn/click/camref:1101l9QvC/creativeref:1011l783…
⚫ Save up to 50% on NEW Assets: assetstore.unity.com/?new_sale=true&orderBy=1&aid=…

👨‍💻 As always, all code from this video is available on GitHub: github.com/llamacademy/ai-series-part-33

❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Patreon Supporter or YouTube Member:
⚫ Patreon: www.patreon.com/llamacademy
⚫ YouTube Member: youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video

As usual with the AI Series, we're using the NavMesh Components: docs.unity3d.com/Manual/NavMesh-BuildingComponents… not the built-in navigation system.

----

Believe in LlamAcademy's mission and have received value from the videos? Consider becoming a Patreon supporter: www.patreon.com/llamacademy

----
Most tutorials come from knowledge gained making survival.llama.software/ Llama Survival - a top-down zombie survival shooter for Android and iOS.
I also have some Unity Assets (affiliate link): assetstore.unity.com/publishers/22409?_aid=1101l9Q…
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.

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

Chapters:
00:00 The NavMeshObstacle & Interaction with NavMeshAgents
02:45 Scene Overview
03:45 ObstacleAgent.cs - Mixing NavMeshObstacle and NavMeshAgent
06:45 PlayerMovement.cs - Use ObstacleAgent
07:10 SimpleAgentPatrol.cs - Use ObstacleAgent
07:31 Hooking it up & Demo
09:10 Options to Re-enable NavMeshAg

All Comments (13)
  • Thank you man, I had this snapping issue with my agents and activating navAgent a frame after you disable obstacle really fixed the issue.
  • Now in addition to watching the video, i can also understand what you say, thanks to the automatic subtitles i got a way to translate in real time. Congratulations and thanks for sharing your knowledge with us.
  • @longo9021
    Love your videos. Keep up the good work !!!
  • There is RVO Simulator in A* Pathfinding asset which allows agents to avoid each other while moving. Great vid tho!
  • @TheRoarer
    Hey Chris, do you happen to know if there is a performance cost associated with stationary NavMeshObstacle?
  • @avstract3085
    3:36 The project Browser just dock in just like Unreal Engine 5, what is the name of that asset?
  • @worldkho
    I watched your how to make AI surround the player video. Would this be a better method for something like zombies walking near the player then finding the closest open spot to get in melee range of the player?
  • @prosealien
    Thanks for these tutorials. Is there a simple way to reset destination of nav agent. Say if the enemy follows player then the player switches to another charater. I tried nav reset and cancel methods but enemy will follow the players previous characters destination.
  • @KrAyOnS1
    I have a char that shoot and a Nasmesh but when I shoot the names it goes backwards and doesn't follow me anymore. Now how to fix?
  • @prosource7067
    why Vector3.Distance and notnavMeshAgent.remainingDistance?