For anyone wanting to build better AI systems in their projects, this video is for you! I hope this video will give you the insights you need to implement GOAP in your project! 😁
My God, man... Always so advanced, sometimes very complex and yet easy to understand. I'm constantly in awe watching your videos. Where have you been all theese years, man? I missed you and didn't even know it... This channel is a gold mine for Unity devs. Please, never stop!
Actually my first comment for the decades of watching different Unity/dev/code videos. I’m a game designer in the core but learnt Unity up to middle+ level for eventual making pet projects. Your work and videos are for sure invaluable and grant a lot of specific details to maintain well-architected projects. Thanks ;)
This is a great tutorial. Thanks for making it! I'm definitely not at the level where I understand fully how everything that you implemented worked together to create this kind of a system, but it's good to know of this method of programming AI. I'll definitely be re-watching when I've improved my knowledge and skills some more to really get a good understanding! Thanks again! 😄
I knew this was going to be an awesome implementation of GOAP, but it's awesome how you incorporated Factory, Strategy and Injection patterns into this... I'm currently doing some dialogue editor tools and would love to see you create some editor tools for this. Everything you do is impressive!
Thank you for the kind words! It's truly an honor to receive feedback from the creator of such an amazing project. Your project is fantastic, and I'm glad to share it with others. Looking forward to seeing how you continue to develop it!
Bro for someone not good at coding and thinking of building complex things, your videos are the perfect thing. I not only learn game development but also C#. Thank you so much for the time and efforts you put in the making of these tutorials l.
Been aware of GOAP for a while now but never looked into it very much. This seems like such a useful method for creating intelligent and modular AI. Will definintely have to give it a try. Keep up the good work.
I can't believe that you actually took the time to go through GOAP! With your teaching style, it makes so much more sense and it's made it so easy! You've actually given me some ideas on the implementation, I'll have to experiment with more. Thank you again
@@git-amend I'm working on a game with enemies that require the complexity of the intelligence behind GOAP but once I have something to show off, I'll make a video to show you what I've made.
I am 25 min in. Just started the DFS part. Lot of new concepts. As a self taught programming newb, it is a lot to take in at the same time as learning about goap. Patterns, lamba expressions, delegates, node search algorithms. My head is hurting but I like it! I appreciate you covering these more advanced topics compared to most other channels. Thanks
You're killin it man. Great stuff. This video was fascinating. Loved the suggestions at the end. Would be interesting to see how you turn this into something more editable for the designers to use and so new beliefs/goals/etc wouldn't be created in code but rather in the editor. Keep up the great work, you're doing so well.
Hey, great work, I m happy to see an work like this. I would propose that, if you have time, you could try using Utility-Based Planning. Then community can compare both approaches, maybe even try a hybrid algorithm 😁
Thanks for the great tutorial. Is there any chance of this being expanded to show us more low-medium level devs how to use scriptable objects and / or Node Canvas?
I might do some videos on those topics in the future. Node Canvas might be a tough one because it's expensive and not everyone has access to it, but maybe we could build something similar from scratch. Regarding the gFactory, I can't recall exactly what I did in the video. You can put a GOAP Factory component on a GameObject and provide a reference through a public field if you don't want to use Injection or another method of inversion of control.
Thank you for the great video. I am actually working on my own AI system right now for a platformer game. I am unsure if it makes sense for my needs to add this type of logic, but it is cool regardless.
Thanks again, I would really like to see an advanced interaction system which there is no tutorial about that. For example dual-interactions that both effect player and the object, Interaction that need require different parameters, like one is inventory, and other is simple transform. Like a portal and chest. making them de-coupled with interfaces but with different params
Nice tutorial, thanks a lot! How about you make a video about parkour system (climbing, overcoming obstacles and so on) or procedural 3D level generation?
I like that idea. Along those lines, I've been also thinking about a 'credibility' score... so the longer it's been since an agent verified something was true, the less true it might become.
Programming question (around 4:20) Why use Func condition instead of just bool condition? I can't seem to find an answer online anywhere. It seems to me like they essentially do the same thing...? Lambda notation in general is crazy to me 😅
Using Func instead of a bool allows for dynamic, lazy evaluation of conditions, enabling them to be checked in real-time as game state changes, rather than at a single point in time. This approach is particularly useful in scenarios like state machines or conditional updates, where the condition depends on current game state or player actions. By using Func, you can pass a lambda or delegate that is evaluated at the time it is needed.
@@git-amend Please Do, Garry Newman is my God. his Transport is For everyone! as well i can only find a couple videos on how to implement it, so there is a spot there for you. (Edit: Steam actually tells you to use the Facepunch transport if you are using unity)
You mention updating this to use scriptable objects. Can you give an overview of what that would look like. I've been trying to do that myself and want to compare notes. Full disclosure, I've been failing to think of what would break off into SOs.
Well, it's a bit much to describe in a YT comment, but essentially the Scriptable Objects would be flyweights that have their own factory method which creates actual Actions, Beliefs and Goals you can use when starting the system. This way you can setup a nice editor tool that will allow you to configure all the setup in Unity using SOs and when the game starts you run some logic that puts it all together into something useable in the system by calling all the factory methods you need to get C# representations for the live system.
Great guide as always. Do you also use Unreal Engine or you are planning to continue your journey in Unity? What are your thought about UE? I have been using Unity +6 years and even though i feel i am a good developer myself but i still cant tell myself a game developer since all the games i have played from childhood was developed in c++. I feel like real game devs are on c++ side bu its a corrupted thought i know. :D Still, i want to continue my journey in UE side to develop high-end games or with c++. Even though i work as a full time game developer in unity side, i would love to develop in UE too.
It might be tempting to attach skill level to a particular language, but the reality is that you will reach a point in your game dev (or engineering) career where you become language agnostic. For example, at work this week I wrote code in 4 different programming languages. The syntax and some particularities of each language are different, but the best practices, patterns and principles of engineering remain the same. I have used Unreal, but I enjoy using Unity more, and the channel will for the most part remain a C#/Unity channel for the future as far as I can tell. I think if you have been using C# for 6 years, you will not have a difficult time using C++ or Unreal.
Thank you for the advanced tutorial. I'm working on a psychological horror game set in a castle where players solve puzzles and hide from enemies. I'm unsure about which type of enemy AI would be best suited for this game. The enemy should be able to search for the player within the castle. Additionally, I'm undecided whether to use a navmesh or A* pathfinding. Any advice on this would be greatly appreciated❤❤ .
If you don't need the full power of GOAP, you might want to consider behavior trees. They offer a balance between the adaptability of GOAP and the clarity of state machines, allowing for complex behaviors like searching and patrolling to be broken down into manageable tasks. This modular approach can make your AI's decision-making processes more nuanced and unpredictable, enhancing the suspense and horror elements. Regarding pathfinding, I would first try the nav mesh approach since it's already integrated with Unity, especially if you need a nav mesh already for the player. If you need more customization, then look into A*. The tool I mentioned in the video is excellent.
This is actually really interesting setup, I do have a question and havent really looked to much into GOAP. How would this handle dynamic goals, for example: Heal Friendly Target. But to heal this target we need to have a specific item. Do we just go and create all the actions for all the items? Do we do a Dynamic Action of sort that is UseItem , and create it on the fly on the plan? That means that now we have a ton of other actions to create - assuming a action factory exists for them for the character - , for example (findItemA, PickItemA) etc, that are derived from the state, is this the approach on this sort of systems?
You're on the right track. Generally speaking you try to build goals in such a way that they are as loose as possible. Without diving into a ton of detail, instead of an Action that is Use Health potion, you have an Action that is either Use Item that implements IHeal interface or Use Item that has an IHealStrategy, and then you aren't programming for every eventuality, and the Agent has options.
Would it make more sense to have the belief's location be a nullable Vector3 since Vector3.zero could be a potentially valid location for something to occur?
Using a nullable Vector3 for indicating an uninitialized position is a valid solution if that was a concern you had. Another approach might be to use the Null Object pattern and define a distinct 'NullLocation' object to be a clear, type-safe alternative to signify the absence of a position without resorting to nulls. Then all locations could be represented by a specific type, and potentially include even more information.
Would such a system be appropriate for a game director (think L4D's game director) i.e. an AI overlord that tries to shape the experience of the player(s), or would you use something different? If something different, could you recommend a topic? Even if you haven't covered it, for my own research. Thank you.
For a complex and dynamic system like L4D's Game Director, GOAP can be a good choice due to its flexibility and ability to handle complex decision-making processes. However, Utility AI might be a more practical choice if you are looking for a balance between complexity and performance. Utility systems can provide a dynamic and responsive AI without the overhead of GOAP. This will be the topic of a future video.
A very minor thing, 6:03 but you don't want to be using distance for in range comparisons like this where you don't need to know the exact distance, just it is within the range, since it is needlessly costly calculation that includes an expensive squareroot operation that isn't needed. You can use the much faster square magnitude for the in range comparison
Hi! Hope you are doing good, i have little bit issue with my self i really love your content but things always goes up from head i really want to get all of this how i can do that? i know the OOp data structures but in real life i really don't follow as much because of small dead lines we create games just for 1 or 2 weeks............ i really want to start can you guide me pls..................your content is love.....
@@git-amend Nothing in particular, GMTK did a good overview on The Sims (ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9gf2MT-IOsg.html) and I'd love to see your unity take on the system.
I would favor GOAP for complex, dynamic environments where adaptive AI behavior is required, and choose state machines for simpler contexts with predictable, easily manageable states for clearer behavior logic.
One step at a time, I suppose. You might want to join others on Discord (link in description) - people of all programming levels are there helping each other, and there is a recommended reading list pinned in the #programming section you might be interested in.
@@git-amend in general, I would say. There is no “horizontal” understanding of architecture, namely the beginning of the project. I studied a lot of theory and text and videos, saw examples of use (leoess, etc.). but at the beginning of planning my own architecture for a large and small project, there is simply no starting point in my head. It’s a bit of a strange feeling after I started to understand OOP well. :)
@@git-amend There's quite a lot of things that can be discussed that feel glossed over, or is outdated since most tutorial videos are based on version 0.51. Here are some ECS videos I'd like to see-- - How to understand ECS Physics collisions, and how to get the same behavior as OnCollision/OnTrigger Enter/Stay/Exit in an ECS context - How to use Animation Curves with ECS - When to use BlobAssets versus NativeArrays and NativeLists in ECS - How to use ScriptableObjects with ECS - How to communicate between ECS and GameObjects (Systembase, events, etc) - How to Bake a proper GameObject heirarchy to ECS, and how to interpret/visualize it in an ECS context I know some of these topics are intermingled with each other, but figured I'd state them anyways. I could go on, but ECS just feels half-baked and half-explained.
Evaluating the effects ensures that the planner dynamically adjusts the sequence of actions based on the current state and the satisfaction of required effects. By removing any effects that have already been satisfied, either directly or indirectly through performing an action, the planner avoids redundant actions and focuses only on unmet requirements. This optimization helps in efficiently progressing towards the goal.
@@git-amendYeah, but what you meant is happening in the planner and in the planning functions, and I asked about evaluate in the Action class, in the update function, at the button of the function, in the loop of the effect, In the section you comment with "Apply effects". What is the purpose of evaluating? if it only meant to return a bool and nothing else, it isn't changing any value, it only returning a bool.
@@songerk7102 The Evaluate method executes whatever callback effect methods belongs to that Action. It could be anything you want, even a complex method that changes state.
Hey man, thanks for this great post! I have a question regarding the "AgentAction" script, specificly the "Update" function. In the script you evaluate the effects on the action when it is complete. My question, WHY would this be needed? Is this to ensure that, if the evaluate function would store state somehow, it would update that state? (see example) Inside the GoapAgent: "factory.AddBelief(new Belief("CakeTasteGood", () => { CakeSlice pieceOfCake = fridge.cake.TakeAPiece(); return pieceOfCake.IsTasteGood; }" With: "class Cake { private Stack _slices = new (8); public CakeSlice TakeAPiece() => _slice.Pop(); }" Keep up the good work!