I re-build the GOAP I build for my graduation project 6 years ago. After months of working in my spare time I can finally call it v2! Have a look on GitHub!
What is GOAP?
GOAP stands for Goal Oriented Action Planner. It is an AI architecture that simplifies the process of building complex Finite State Machines (FSMs) by allowing you to define goals and actions, and automatically figuring out which actions to take to achieve those goals. Most famous of powering the AI used in F.E.A.R.
How can it help you?
GOAP can help you building complex AI by defining simple actions which GOAP connects together. It also resolves the best action to take based on the game state. This should make managing a complex decision graph much easier!
Core features
The resolver is multithreaded (using jobs).
GOAP visualizer window.
Setup using two methods: ScriptableObject configuration in the editor, or by using code.
Two example scenes using both setup methods.
Support for data injection using your favorite IoC.
The past month has been very busy! A couple people joined the discord and it’s nice to see the project getting integrated, as well as people helping each other!
These are the latest changes:
Version 2.0.7
Fixed: IGoapSet containing implementation reference instead of interface
Version 2.0.8
Added GetComponentInChildren to Agent references
Version 2.0.9
Added OnGoalCompleted event
Version 2.0.10
Fixed collections > 2.1 breaking this package due to NativeMultiHashMap being renamed to NativeParallelMultiHashMap
Version 2.1.0
Added Unity 2021 support (tested with 2021.3)
Added GoapRunnerEditor
Improved performance of NodeViewer
Added states to AgentEditor
Breaking changes
Removed IAgentMover in favor of events on the agent. This setup is much more flexible and should fix issues with properly implementing the NavMeshAgent. Fixes Move events · Issue #28 · crashkonijn/GOAP · GitHub
The past weeks there’s been a couple updates, including three new contributors!
Version 2.1.1
Fixed: Issue where agent would deadlock in the complex example.
Version 2.1.2
IDataReferenceInjector.GetComponent becomes GetCachedComponent to better communicate purpose. For backward compatibility, previous versions retained but marked as obsolete.
Version 2.1.3
Major name refactor to change all derivatives of ‘Set’ to ‘GoapSet’. This should communicate it’s purpose more clearly.
Version 2.1.4
Added GetGoals() to the IGoapSet.
Version 2.1.5
Removed empty readme files that were generating warnings/errors
Fixed incorrect variable name
Fixed planned planning action for satisfied condition
Thank you for your kind words! For v2 I put a lot of time and effort in ‘marketing’ it and building a community. The project is gaining traction and staying in contact with actual users of the project helps a lot in staying motivated in the long term!
Does choosing between ScriptableObjects and Code have any impact? On performance or something?
Very stupid question: How can the resolver be multithread if it’s accessing things like the agent’s transform/Monobehaviours? I thought Unity Jobs cried quite a lot because of things like that.
It shouldn’t, both of these methods are ‘compiled’ into (the same) data that the resolver needs.
You’re right, you can’t access this information from within a job. During the update loop all required information is gathered from the main thread and transformed to information that works for the job system before triggering the job.
This is done in the GoapSetJobRunner, specifically in the Run and FillBuilders methods.
@w34edrtfg This is an overview of the FixHungerGoal, it’s not the WanderGoal that’s used in the getting started but is much more complete (and available in the ‘Simple Demo’). Is this what you had in mind?
@CrashKonijn another stupid question: Somewhere you’re getting the list of active agents (so you can iterate them). Do i have a method to get said list or i have to build it myself?
(I want to get the agents to look for targets)
I think I completely read over your question! It is possible to get all the agents that are present, but I don’t recommend relying on the GOAP to provide you this information. Making something of your own would indeed be better.
Thanks, I’ve updated that in the docs! The diagram is now in the getting started as well
I started testing this and so far I like how it is made.
I think you can add something that will help others. instead of relying on Time.deltaTime, add the option to override that with custom deltaTime.
thanks!
Could you add a tutorial video that shows the documentation and explains it step by step.
The explanations would be nice if you do it with multiple small examples inside unity.
This will be a fun way to uncover the whole framework and will answer all our questions and lets us discover all its capabilities.