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: th-cam.com/video/3PLDIEjmQsI/w-d-xo.html ⚫ Factory Pattern: en.wikipedia.org/wiki/Factory_(object-oriented_programming) ⚫ Builder Pattern: en.wikipedia.org/wiki/Builder_pattern ⚫ AI Series 4 Runtime Agent Spawning: th-cam.com/video/5uO0dXYbL-s/w-d-xo.html ⚫ Dependency Injection: en.wikipedia.org/wiki/Dependency_injection ⚫ Which AI Behavior Framework Should You Use? th-cam.com/video/CZvfuNfdc1M/w-d-xo.html
Thanks for makeing that GOAP System. My last time i tried makeing a game i wanted. It failed cause my AI just didnt feel right. I'm barely starting to use this approach and its already so much more what i wanted. Gonna look up that sponsor thingy, that's new.
Have fun! Once you have all the concepts down it ends up being pretty straightforward, but there's a lot to get into your head before that moment happens 😋
@@LlamAcademy That would be great! I think there would be value in covering the TransformTarget type that is part of v2.1 as well. It's used in the complex example, and once I discovered it it made a huge difference on what I needed to do in order to handle orientations of characters when they reached a position.
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.
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!
That's a great question. I made the assumption there would always be some kind of grass in range since we didn't make it a depletable resource. In the event that there is no grass and you cannot perform the action, you can assign a NoActionFound delegate to handle this case on the "AgentBehaviour.Events" in the LlamaBrain
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.
I think you can create another blend tree and use the same direction condition as the regular movement, It might help to just call an animator trigger to transition to the stop blend tree when the character is stopped
Question, is GOAP a cpu intensive system that will impact performance? If i want to make a game like Let's School, and there could be more than 200-500 ai at the same time, is GOAP a good choice?
Hi there! Yes, resolving a graph using A* is considered expensive. However it all depends on how large the graph is that needs to be resolved. As for running 500 agents; resolving a new action for 500 agents in a single frame is probably too much. Luckily that's probably not needed, since they won't have to resolve anything wile running their actions.
As CrashKonijn mentioned here, having 200-500 AI evaluating their goals every frame would not perform very well. Most likely you will not have all 200-500 picking goals and sensing every frame though because they would be performing some actions that would take time. This system makes use of the jobs system to make it highly efficient. In any game with large quantities of AI you have to evaluate performance and see what can be done to meet your requirements on your target hardware. In many games AI that are "far away" are just disabled, or have a reduced update frequency to make it more performant.
@@user-ws7ub3kt4r Hi there! You mean the planner taking multiple frames to calculate what the best action would be? No it doesn't support that currently.
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?
PlayerSensor senses the player (monobehavior) so the brain can tell the GOAP System to change the goal. You can change the name if it is confusing between this and the GOAP Sensor.
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?
You can configure the GOAP set up front with all the possible skills and as part of the sensors detect if they’re unlocked or not at that moment. CrashKonjin is also considering implementing an ability to dynamically enable/disable actions. As far as I know that’s not implemented yet, but would be a little more convenient than the sensor method. As for the planner. The GOAP system does have a default planner that plans based on the cost and the actions (including distance traveling) available to achieve the current goal. You can even create your own custom planner if you’re super hardcore 🙂
Thank you. After considering it, I believe that using GOAP for skill casting decisions may not be suitable. This is because skill casting does not require too many actively fulfilled prerequisites; it only needs some passive conditions to be met for casting. @@LlamAcademy
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?
Regarding the DependencyInjector, it depends on how divergent your enemy types are. If you have them set up with pluggable behaviors and configurations like what we've set up here, you can likely use the same DependencyInjector. If your AI will have totally different goals, then you will probably need different GoapSets. That could be handled all in one GoapSetConfigFactory, or you could have multiple. Regarding the ScriptableObjects, because they're just data you can create as many as you'd like. I think we have it designed a little simplistically here because we only have the 1 enemy type. You'd probably need some kind of data model linking the configurations to the enemy type so we don't run into the problem you're describing.
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)
It is great tu great tutorial, there is one thing i don't understand. In "AttackData" script, how did you make link to Animator? How can I reference other objects there? I am changing animations from other script like "agentController" but I cannot get references to this one.
@@LlamAcademy Hi and thank you for the hint. I was actually playing with this system for a past few days and it is really cool. I am doing some small modifications to make it compatible with A* Project, and it looks very promising so far. :) One observation that I want to make, for actions and sensors it is not really necessary to have an Injection system. It is perfectly fine to grab a lot of info with [GetComponent] annotation.
@@LlamAcademy Hi again, I have to say this tool is amazing. Ever since I have seen your tutorial (two weeks ago) I have started to play with it. Maybe because I am not from IT world, so it took me some time to understand, but I am starting to get it now and having some nice results. :) Thanks for this tutorial. Cheers!
@ 33:12 my "Player" type in "if (other.TryGetComponent(out Player player))" is throwing an error. I see Player.cs in your folder structure, but you don't go over whats in it?
Good point. This is an almost- empty monobehavior I use to identify that this object is a player. You can find the full project code on GitHub if you ever want to see anything I may have skipped in the video: github.com/llamacademy/ai-series-part-50
@@LlamAcademy Thank you so much for sharing this! I can look into that script now. I see that we set up the Factory to look at PlayerHealth, but PlayerHealth is actually an empty scripp with no float? How do we actually read player health and affect it?
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.
I completely reinstall and found the issue I believe, might have been multiple, but I had a C# Dev kit active turning that off was the nail in the coffin. However I have another question and I greatly appreciate you taking the time to respond 5:13 how did you do that where it generated all the code you were going to need for the sensor.
The codegen is to “Implement Missing Members” on Rider the hotkey for quick actions is alt+enter. I think in visual studio it’s like… control + . Or something like that. You can right click to get the menu too.
Throwing errors when i try to load the git from you. Managed to get the goap system just fine from crahkojin... Maybe i am to stupid . Just wanted to to mess around with it before trying to do it for what i am planning. xD Guess i will just go straight into codeing and testing it out myself.
I pulled it fresh from the GitHub and it was working except the missing llama model (just had to import him from the Asset Store). What errors were you getting?
@@LlamAcademy [Package Manager Window] Error adding package: Unable to add package : does not point to a valid package. No package manifest was found.
@@LlamAcademy Doesnt wanna let me copy paste it into comments here xD... "no package manifest found". So i guess it cant see the package when i try loading it over the git hub link
nvm ....there it is. Showed up ... after i posted something else. TH-cam... doesnt like it if theres links in comments. So i had to get rid of the github link.. xD Couldnt poste the error before...
Hi! The ITarget is populated by the GOAP system based on your Sensor. Around 06:00 you can see where we created the ITarget. This is the same value that is passed over to this AgentMoveBehavior
Array inside array? like a 2 dimensional array? You can simply do int[][] twoDimensionalArray = new int[5][5]; Here's Microsoft's C# documentation on the subject: learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/arrays
Man all this AI playlist is incredible. I followed and made projects with many of the examples you show. Truly appreciated! If i wanted to make a everyone vs everyone king of the hill type of game, where we had the player and 9 AI agents, all fighting and pushing each other to stay on top of the hill for the longest time, could i simply modify this GOAP system? Here's an example of the desired end result: th-cam.com/video/oDGgwKKGIpg/w-d-xo.html
You can absolutely use GOAP for the AI Agents on a King of the Hill game. It's all about setting up the goals, potential actions, and knowledge the world! :)
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: th-cam.com/video/3PLDIEjmQsI/w-d-xo.html
⚫ Factory Pattern: en.wikipedia.org/wiki/Factory_(object-oriented_programming)
⚫ Builder Pattern: en.wikipedia.org/wiki/Builder_pattern
⚫ AI Series 4 Runtime Agent Spawning: th-cam.com/video/5uO0dXYbL-s/w-d-xo.html
⚫ Dependency Injection: en.wikipedia.org/wiki/Dependency_injection
⚫ Which AI Behavior Framework Should You Use? th-cam.com/video/CZvfuNfdc1M/w-d-xo.html
Amazing job Chris! Thank you for creating this tutorial! ❤
Thanks for all your work on the system 🧡!
I downloaded your GOAP system some time ago, and now there is also a TH-cam tutorial for it! Amazing, this just made my day 🥹
Thanks for makeing that GOAP System.
My last time i tried makeing a game i wanted. It failed cause my AI just didnt feel right.
I'm barely starting to use this approach and its already so much more what i wanted.
Gonna look up that sponsor thingy, that's new.
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.
Have fun! Once you have all the concepts down it ends up being pretty straightforward, but there's a lot to get into your head before that moment happens 😋
Finally! Thank you so much for creating this tutorial!
It took me over a month to put it together but I think it will be really helpful for a lot of people!
Great content 🔥🎮💯👏🏻🤟🏻
I can't wait to try this AI Setup on my Game Demo. Thank You
Amazing channel!!! The best unity tutorials in the internet ❤❤❤
Like if you like his cringe signature move at the beginning of each video 😂❤
👍 at least one from me!
thanks verry complex, reminds me of the DOTS tutorial
Just discovered your channel and your AI series is top notch! 👍Do you plan on revisiting the GOAP system by CrashKonijn once V3 is out of Beta?
🙂 I think so
@@LlamAcademy That would be great! I think there would be value in covering the TransformTarget type that is part of v2.1 as well. It's used in the complex example, and once I discovered it it made a huge difference on what I needed to do in order to handle orientations of characters when they reached a position.
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.
I have not considered that yet. I'll give it some thought
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!
That's a great question. I made the assumption there would always be some kind of grass in range since we didn't make it a depletable resource. In the event that there is no grass and you cannot perform the action, you can assign a NoActionFound delegate to handle this case on the "AgentBehaviour.Events" in the LlamaBrain
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.
I think you can create another blend tree and use the same direction condition as the regular movement,
It might help to just call an animator trigger to transition to the stop blend tree when the character is stopped
Epic intro!
Thank you for explaining in details about GOAP!
💪 thanks 😊
Question, is GOAP a cpu intensive system that will impact performance?
If i want to make a game like Let's School, and there could be more than 200-500 ai at the same time, is GOAP a good choice?
Hi there!
Yes, resolving a graph using A* is considered expensive. However it all depends on how large the graph is that needs to be resolved. As for running 500 agents; resolving a new action for 500 agents in a single frame is probably too much. Luckily that's probably not needed, since they won't have to resolve anything wile running their actions.
As CrashKonijn mentioned here, having 200-500 AI evaluating their goals every frame would not perform very well. Most likely you will not have all 200-500 picking goals and sensing every frame though because they would be performing some actions that would take time.
This system makes use of the jobs system to make it highly efficient.
In any game with large quantities of AI you have to evaluate performance and see what can be done to meet your requirements on your target hardware. In many games AI that are "far away" are just disabled, or have a reduced update frequency to make it more performant.
Does the framework support agent's goal-based decision-making across frames?@@CrashKonijn
@@user-ws7ub3kt4r Hi there!
You mean the planner taking multiple frames to calculate what the best action would be? No it doesn't support that currently.
Okay, I understand, thanks
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?
PlayerSensor senses the player (monobehavior) so the brain can tell the GOAP System to change the goal. You can change the name if it is confusing between this and the GOAP Sensor.
Bravo Proud ......
amazing
🧡 thank you
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?
Perhaps you might also need to dynamically construct the goal set to reduce the number of A* computations.
You can configure the GOAP set up front with all the possible skills and as part of the sensors detect if they’re unlocked or not at that moment. CrashKonjin is also considering implementing an ability to dynamically enable/disable actions. As far as I know that’s not implemented yet, but would be a little more convenient than the sensor method.
As for the planner. The GOAP system does have a default planner that plans based on the cost and the actions (including distance traveling) available to achieve the current goal. You can even create your own custom planner if you’re super hardcore 🙂
Thank you. After considering it, I believe that using GOAP for skill casting decisions may not be suitable. This is because skill casting does not require too many actively fulfilled prerequisites; it only needs some passive conditions to be met for casting. @@LlamAcademy
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?
Regarding the DependencyInjector, it depends on how divergent your enemy types are. If you have them set up with pluggable behaviors and configurations like what we've set up here, you can likely use the same DependencyInjector.
If your AI will have totally different goals, then you will probably need different GoapSets. That could be handled all in one GoapSetConfigFactory, or you could have multiple.
Regarding the ScriptableObjects, because they're just data you can create as many as you'd like. I think we have it designed a little simplistically here because we only have the 1 enemy type. You'd probably need some kind of data model linking the configurations to the enemy type so we don't run into the problem you're describing.
@@LlamAcademy thank you so much for the answer! I managed a solution for multiple agent types :)
thanks
Hello I'm new to the series, In which video the CommonData.cs script is?
In this video around 08:09
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)
I think maybe you named your AttackConfigSO variable differently than me. This should be the variable that is of type AttackConfigSO
@@LlamAcademy I figured it out! I somehow missed the part where I needed to Inject into the MeleeAction script. Thank you for the help!
It is great tu great tutorial, there is one thing i don't understand. In "AttackData" script, how did you make link to Animator? How can I reference other objects there? I am changing animations from other script like "agentController" but I cannot get references to this one.
I did it with the [GetComponent] annotation from the GOAP system we’re using here. You can assign it manually with a standard GetComponent as well.
@@LlamAcademy Hi and thank you for the hint. I was actually playing with this system for a past few days and it is really cool. I am doing some small modifications to make it compatible with A* Project, and it looks very promising so far. :)
One observation that I want to make, for actions and sensors it is not really necessary to have an Injection system. It is perfectly fine to grab a lot of info with [GetComponent] annotation.
@@LlamAcademy Hi again, I have to say this tool is amazing. Ever since I have seen your tutorial (two weeks ago) I have started to play with it. Maybe because I am not from IT world, so it took me some time to understand, but I am starting to get it now and having some nice results. :) Thanks for this tutorial. Cheers!
@ 33:12 my "Player" type in "if (other.TryGetComponent(out Player player))" is throwing an error. I see Player.cs in your folder structure, but you don't go over whats in it?
Additionally, how are we tracking player health? The PlayerHealth script doesn't have a float to track health?
Good point. This is an almost- empty monobehavior I use to identify that this object is a player.
You can find the full project code on GitHub if you ever want to see anything I may have skipped in the video: github.com/llamacademy/ai-series-part-50
@@LlamAcademy Thank you so much for sharing this! I can look into that script now. I see that we set up the Factory to look at PlayerHealth, but PlayerHealth is actually an empty scripp with no float? How do we actually read player health and affect it?
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.
Nevermind, I tried to include my own naming conventions already and messed something up along the way. It works now, thanks again! :D
😁 Glad you got it up and running!
does it only work with navmesh agent. what if my ai moves with rgidbody instead
Yes of course you can use a Rigidbody as well 🙂
Is GOAP a good way to make 3D games similar to Vampire Survivors?
I do not think you need a system as sophisticated GOAP for the AI in a game like Vampire Survivors.
How do you get the unity intelisense to show for goap. Im hoping this is a simple question and im just overthinking it
After you import the package it should just show up for you automatically. At least it did for me.
@@LlamAcademy okay so maybe i messed up the set up of visual studio and unity integration
I completely reinstall and found the issue I believe, might have been multiple, but I had a C# Dev kit active turning that off was the nail in the coffin.
However I have another question and I greatly appreciate you taking the time to respond
5:13 how did you do that where it generated all the code you were going to need for the sensor.
The codegen is to “Implement Missing Members” on Rider the hotkey for quick actions is alt+enter. I think in visual studio it’s like… control + . Or something like that. You can right click to get the menu too.
@LlamAcademy thank you so much. It's small things like this that really get to me. You are a legend. I'll make sure to give you a share on my socials
I am again here can you make a video about how to give multiple tags to one gameobject🤚Please SIR
why would u want to do that?
Throwing errors when i try to load the git from you.
Managed to get the goap system just fine from crahkojin... Maybe i am to stupid .
Just wanted to to mess around with it before trying to do it for what i am planning. xD
Guess i will just go straight into codeing and testing it out myself.
I’m sure it’s not that you are stupid 🙂. Let me check the repo. I probably messed something up!
I pulled it fresh from the GitHub and it was working except the missing llama model (just had to import him from the Asset Store). What errors were you getting?
@@LlamAcademy [Package Manager Window] Error adding package:
Unable to add package :
does not point to a valid package. No package manifest was found.
@@LlamAcademy Doesnt wanna let me copy paste it into comments here xD... "no package manifest found". So i guess it cant see the package when i try loading it over the git hub link
nvm ....there it is. Showed up ... after i posted something else. TH-cam... doesnt like it if theres links in comments. So i had to get rid of the github link.. xD Couldnt poste the error before...
at 11:00 you are going WAY too fast. I have no idea where the Events or ITargets came from. You never specified to import GOAP interfaces
im confused about the itargets to. All it seems to do is pass a vector3 from... somehwere? presumably the target but i dont get how.
Hi! The ITarget is populated by the GOAP system based on your Sensor. Around 06:00 you can see where we created the ITarget. This is the same value that is passed over to this AgentMoveBehavior
can you make a video about how to give an array inside an array plaease
Array inside array? like a 2 dimensional array? You can simply do int[][] twoDimensionalArray = new int[5][5];
Here's Microsoft's C# documentation on the subject: learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/arrays
@@LlamAcademy 👋But make a video about it
You can also do array[x,y,z] if you are in C# unity
basically just add a comma to add another dimension
Man all this AI playlist is incredible. I followed and made projects with many of the examples you show. Truly appreciated!
If i wanted to make a everyone vs everyone king of the hill type of game, where we had the player and 9 AI agents, all fighting and pushing each other to stay on top of the hill for the longest time, could i simply modify this GOAP system?
Here's an example of the desired end result: th-cam.com/video/oDGgwKKGIpg/w-d-xo.html
You can absolutely use GOAP for the AI Agents on a King of the Hill game. It's all about setting up the goals, potential actions, and knowledge the world! :)
Hey man, i had some doubts about the implementation and would like to know if you have a group on discord that could help me ?
The only Discord I have is exclusive for TH-cam members / Patreon supporters.