GOAP Enemy AI FULL IMPLEMENTATION | AI Series 50 | Unity Tutorial

9,511
0
Published 2023-12-12
Go to this video's Sponsor: snhu.edu/llamacademy to see what the current average annual salary for a game developer programmer is and learn how you can get started!

See a full implementation of an enemy AI with GOAP (Goal Oriented Action Planning). This enemy AI will have 3 goals: Wander, Kill Player, and Eat. You'll learn how to set up Actions, Goals, Behaviors and have them work together with a GOAP system to formulate plans to achieve their goals.

Special shout out to CrashKonijn for his awesome work on the GOAP system used in this video: github.com/crashkonijn/GOAP

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

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

đź“š Resources:
âš« FREE Unity GOAP System used here: github.com/crashkonijn/GOAP
âš« GOAP System Documentation: goap.crashkonijn.com/
⚫ Introduction to GOAP:    • Introduction to GOAP | AI Series 49 |...  
⚫ Factory Pattern: en.wikipedia.org/wiki/Factory_(object-oriented_pro…)
âš« Builder Pattern: en.wikipedia.org/wiki/Builder_pattern
⚫ AI Series 4 Runtime Agent Spawning:    • Spawn and Place NavMeshAgents on a Na...  
âš« Dependency Injection: en.wikipedia.org/wiki/Dependency_injection
⚫ Which AI Behavior Framework Should You Use?    • Which AI Behavior Framework Should Yo...  

đź’¸ Ongoing sales đź’¸
⚫ 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=…

❤ Believe in LlamAcademy's mission and have received value from the videos? 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

----
I also have some Unity Assets: 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 #tutorial #unity #llamacademy #gamedevelopment #ai

Chapters:
00:00:00 Topic Introduction
00:02:25 Installing Unity GOAP & Project Structure
00:03:20 Wander Goal
00:15:35 Sponsor: Southern New Hampshire University
00:17:13 Wander Goal continued
00:22:40 Kill Player Goal (Melee Action)
00:39:02 Eat Goal
00:52:22 Kill Player Goal (Spit Action)
01:06:44 Final Demo & Support LlamA

All Comments (21)
  • @LlamAcademy
    Go to this video's Sponsor: snhu.edu/llamacademy to see what the current average annual salary for a game developer programmer is and learn how you can get started! Special thanks to @CrashKonijn for all his work on the GOAP system used in this video! ⚫ FREE Unity GOAP System used here: github.com/crashkonijn/GOAP ⚫ GOAP System Documentation: goap.crashkonijn.com/ ⚫ Introduction to GOAP: https://youtu.be/3PLDIEjmQsI ⚫ Factory Pattern: en.wikipedia.org/wiki/Factory_(object-oriented_pro… ⚫ Builder Pattern: en.wikipedia.org/wiki/Builder_pattern ⚫ AI Series 4 Runtime Agent Spawning: https://youtu.be/5uO0dXYbL-s ⚫ Dependency Injection: en.wikipedia.org/wiki/Dependency_injection ⚫ Which AI Behavior Framework Should You Use? https://youtu.be/CZvfuNfdc1M
  • @CrashKonijn
    Amazing job Chris! Thank you for creating this tutorial! ❤
  • @evanciao
    Finally! Thank you so much for creating this tutorial!
  • @kronusbr17
    Amazing channel!!! The best unity tutorials in the internet ❤❤❤
  • @Colo629
    Very helpful. Never thought I'd be implementing GOAP AI any time soon, but this crash course has got me on my way. Thank you.
  • @alec_almartson
    Great content 🔥🎮💯👏🏻🤟🏻 I can't wait to try this AI Setup on my Game Demo. Thank You
  • @Hazzel31337
    thanks verry complex, reminds me of the DOTS tutorial
  • @O2Dev
    Amazing job! Just finished it. What a great tutorial and library! I noticed when the Llama wants to eat, if no grass is in range, it gets stuck in place doing the EatAction anyway. To fix this, should I add a condition like PlayerDistance (GrassDistance) to the EatAction, so it keeps Wandering if no food is around? Or is there another way? Anyway, thanks a lot!
  • @Damian_h
    Llam bro i have a question. I have a character that has animations for all directions forward, backward, strafe left and right but i also wanna implement jogs stop animations for every direction to make the movement feels a bit more smooth. The thing is i set up the blend tree 2d and the movement is looking good the problem is i dont know where should or how should I add the jogs stop animations i dont know if it should be individuals transitions from the motion blend to those stop animation or i should make another blend tree whats the best way to implement stop animations and which conditions should trigger these kind of animations that are pretty much executing almost when there is no speed value left.
  • @rbr0319
    Hello there, i just found out about your channel and im loving the ai series, i would like to know if you think about making a video on HTN (hierarchical task network), wich as far as i understood is a upgrade to goap.
  • @user-ws7ub3kt4r
    Thank you very much for your tutorial, but I have a few questions. If a character can learn skills, how do I dynamically modify the GOAP (Goal Oriented Action Planning) set, and each skill has its own range? Do I need to write multiple sensors, or is one sensor for enemy range sufficient? Also, it seems that the GOAP system includes a planner component. So far, in the tutorial, I've seen the use of FSM (Finite State Machine) and hard-coded methods. Does this GOAP framework provide a planner similar to priority planning?
  • @maximdaigle
    Would I need another GoapSetConfigFactory with its specific dependency injector if I wanted to support multiple types of enemies/NPCs ? I'd guess I could rewrite the GoapSetBinder to take in a SetName. What if I want the same enemy type to have different Configs? Also using the ScriptableObjects configs could lead to errors no? In the sense that you could put two different configs one on the GOAP system and another wrong one on the behaviours. What if the same action is used by different enemies? Maybe these values could come from the CommonData? thoughts?
  • @hunterfox6230
    Hey! Great video! So a@30:25 with the line bool shouldAttack = data.Target != null && Vector3.Distance(a: data.Target.Position, b: agent.transform.position) <= AttackConfig.MeleeAttackRadius; I am getting a red line under "AttackConfig.MeleeAttackRadius" that reads An object reference is required for the non-static field, method or property 'AttackConfig.MeleeAttackRadius'". How do I fix that?
  • @LupoNoBrain
    Hi @LlamAcademy, Thank you for this great entry into the topic. I am facing a rather embarrassing issue: I have followed your instructions precisely, but I keep getting this error: "KeyNotFoundException: No goapSet with id TestSet found" Now even if I manually call the Creation on my GoapSetConfigFactory and make sure the Set is created, it is never finding it for me. Any suggestions would be appreciated. Thanks again for your awesome video.
  • @ZangJM
    Hello I'm new to the series, In which video the CommonData.cs script is?
  • @hunterfox6230
    What exactly is the difference between PlayerTargetSensor and PlayerSensor? Each one is in a different folder? Should I be naming them differently so as not to confuse a GOAP sensor with something else?