Introduction to GOAP | AI Series 49 | Unity Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
goal oriented action planning is a popular framework that allows designers to set up goals actions and sensors that let the AI plan how do they achieve these different goals in this video we're going to look at all of these things and talk about what are they what do you do in each one of these and how do they relate to one another when you're implementing your AI with goat hey Chris here from LOM Academy here to help you who me yes you make your Game Dev dream become Reality by helping you understand complex AI Behavior Frameworks I thought it was pertinent to start with this overview of this more complicated system than Behavior trees and state machines before we dived into the full implementation I'm still going to be talking about GOP in the context of Crash conin Unity GOP system which is licensed under the Apache 2.0 license which is very permissive but I think for this video it doesn't really matter what system we're talking about there are some nuances that are different between every system but for for the most part all of these things are pretty much the same and like I was saying earlier GOP is a little bit different from doing a behavior tree or a state machine we start instead of defining States and behaviors we start by defining goals then we Define actions that the AI could potentially take to reach those goals we can assign costs to each of these actions also preconditions and effects for what these actions do then the AI comes up with a plan based on the world state or their memory they get from the sensors all the words that I'm using right now and emphasizing a lot are keywords in the GOP system they're like specific things that you need to know and that you create classes for and we're going to talk about every one of those in this video when I'm working in a GOP system I like to start with the ended mind so I start with the goals and work my way backwards from what do we need to do to be able to get to those things so we might start with an enemy AI has a goal of kill the player but if you only have one goal GOP is kind of point pointless you probably better off using a state machine or maybe Behavior tree because the purpose of GOP is your AI can have several goals and it will plan out how do they get to different ones based on the available actions so maybe your AI ends up with kill the player goal wander goal maybe they get hungry so you'll give them an eat goal at least three maybe gives us a good starting point once we have our goals set up we can Define our actions what things can our AI do in our example that we're talking about here maybe our AI can do different forms of attacks like they can melee since we're using a llama maybe they can spit I was using bounce and roll before so maybe those would be available options as well if they're wandering they probably need a wander action and if they can eat as a goal probably they need an eat action as you can see from this code actions also have effects conditions and base costs the GOP system will consider these when building a a plan so an action that has a higher base cost will get chosen less frequently when there are lower cost options that are available the GOP system usually also considers the cost of traveling to achieve some action just because we have a low base cost if something is very far away we might not choose to do that and we may choose to do a more expensive action instead if we don't have to travel very far the effects tell the GOP system what effects an action has on the world state for example meleeing can make the player become dead which is a condition of success for having the Kill player goal actions also have conditions because you may not want to do a ranged attack if you are too close to the player we can add as many of these as we want the actions I think are relatively straightforward on what are they doing they're what can your AI do I get asked all the time Chris how do you know all this stuff and a lot of it comes from experience using unity and doing development in general but I had a really great start in college and that's where I'd like to talk to you about today's video sponsor Southern New Hampshire University or snhu snhu provides lowcost affordable game development and computer science degrees that can help you level up your Game Dev skills May of you may not know I have a software engineering degree and I feel like it's added a lot of value just going to college getting that degree help me understand how does software work how do things like State machines work for example and how do video games work which is why I'm partnering with snhu to bring you information about how you can get a college degree from an accredited University with two accredited degree programs that I want to talk to you about today one is a computer science degree which is very similar to the software engineering degree that I have and a game design and game development degree if you're more interested in specializing in game design and development in that degree program you'll learn things like what we talked about on this channel about how to implement things with gameplay AI physics all these things that we talk about on this channel you'll get structured lectures from University professors who have real World experience you can get either these degrees online through snhu at a really affordable price if you're interested in learning more about these degree programs you can go to snhu.edu LOM Academy fop the form there and a real person will contact you to help you understand how these degree programs can specifically help you again that's snhu.edu LOM Academy go there fill out the contact form and someone will contact you with more information about the specific degree program that you're interested in once we know what we can do I like to think of how do we get to those actions so what do we know about in the world this is the memory or the world state that your AI knows about in the GOP system so we can add all the different components like if we're hungry we probably need to have a how hungry we are we probably need to know where the player is you can add as many things as you need here but remember as you scale up all the number of actions all the different things in the memory it makes a go system go slower cuz we have more and more things to think about if you're just getting started don't worry too much about that don't pre- optimize just put in what you think your AI needs to know for example maybe if the Llama can have a spit attack maybe they have a limited amount of spit and they need to do something to get more spit so they can keep spitting realism so we've know our goals we know what we can do and we know about the world but we don't have a way to figure out how do we know these things about the world and that's handled with something called sensors if you've been watching AI series part 47 and 48 you've already seen these sensors it's just maybe collider so we can tell when something comes in range maybe we are pulling some mono Behavior that's updating every frame whatever it is the sensors are just a way to tell the GOP system here's your current world State this isn't a GOP specific concept basically all AI needs to know how do I know about the world and that's usually done with sensors all these are the core classes you need to use in implementing your AI using a GOP system how does your AI know which goal it should do well that's where depending on your GOP system it may change a little bit so using this specific GOP system we have the concept of a brain and I like this concept A Lot some other systems maybe just check based on the sensors they update the goals based on the available actions and create the plan automatically I like a little bit of control over the AI so I like the concept of the brain the brain sets the goal based on maybe some events that are going on nearby the brain can tell oh a player just came in range now we're sensing them let me set the goal to kill the player the brain gives us a centralized place kind of like our enemy class you've been watching 4748 it tells us here's all the stuff about how do I set my goal you have different brains for different AI or you can have a shared brain with different type arguments which is what in the samples of Crash conin samples show us is they have a mind ER A Smith a couple others they'll use basically the same brain and just have slightly different ways of setting the goals and what we're going to go through the full implementation on we're going to have one brain for the Llama AI CU we only have one AI one maybe gotcha with having a brain is using the system it's a littleit awkward to have your brain know about some State and have the GOP system know about another state but you can have it where they're both referencing the same state and we'll talk about how you can do that when we do the full implementation having a shared state that the GOP system uses in your brain uses reduces you from having to duplicate a bunch of effort with the brain concept we just Define a clear set of rules of when we should change from one goal to another goal based on our world state or our memory and we can very easily see those rules in one area once we've set a new goal the GOP system says okay hey let me re-evaluate the plan to get that goal achieved based on the current world State and finally we have behaviors and behaviors aren't anything super special they're just mono behaviors that we use in conjunction with the rest of these classes we've already talked about these ones are a little bit tricky because you might be tempted to make maybe an action that's like Melee action and then make a behavior melee Behavior because you want access to the mono Behavior stuff like start update whatever but in most cases you don't need a behavior with an action the action should Define what do you do and the behavior is just for things like let's use an example if you want the Llama to have hunger the GP system doesn't trigger the hunger action there's not really a hunger action right it's just something that happens every frame maybe get more and more hungry every frame that's something just happens in the world so you'd have a behavior for maybe Hunger behavior that has a hunger float that increases over time unless the AI is eating a melee action would do all of the things like look at the player play the animation whatever and you don't need a melee Behavior because it's all you're only doing the melee stuff when you're in the melee action so these are basically just mono behaviors that influence maybe something that's going on in the world whatever you need that will maybe influence how the agent behaves by updating something about their memory or some variable that they need to know about another example might be if you need an event to be raised whenever you have like on trigger enter you would need a behavior for that to catch that event give it to the brain so then the brain knows oh the player just entered in my sensor radius I should maybe set my goal to kill the player if you want to be really reactive you need to do something like that I hope this overview of the key components of a GOP system help you better understand how do you design an AI using GOP stay tuned for AI series part 50 50 I can't believe there's already 50 episodes or about to be 50 episodes of the AI Series in that video I'll show the full implementation of Alama AI much like what we we did in part 4748 using GOP but because what we did in 4748 are very straightforward just kill the player and maybe wander type AI Ram a little bit extra Nuance to this implementation to make it a little bit more fun that one will be coming out in a couple weeks so make sure that you've liked and subscribed to stay up to date whenever that one comes out and if you want to support this channel you can go to the affiliate links down in the description that really helps a lot there's no additional charge to you and it helps me a lot got the Black Friday sales coming up on Unity asset store I'm sure there's going to be some awesome humble bundles coming out as well so before you do your shopping if you can click on one of those helps me out a ton you want to show your support directly you can go to awesome tier there's Ivan rulin iy obelis and Perry there's also all of these great supporters as well thank you all for your support I am so incredibly grateful
Info
Channel: LlamAcademy
Views: 6,359
Rating: undefined out of 5
Keywords: Unity, Tutorial, How to, How to unity, unity how to, llamacademy, llama academy, video game development, development, goap, unity goap, goal oriented action planning, goal, oriented, action, planning, plan, goal oriented action plan, introduction, introduction to goap, what is goap, intro to goap, goal oriented, action planning
Id: 3PLDIEjmQsI
Channel Id: undefined
Length: 12min 15sec (735 seconds)
Published: Tue Nov 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.