GOAP System Now Integrated


Smarter AI for the 2D RPG Project Accelerator
Hey devs ๐
Iโm excited to share a big step forward in the AI system of the 2D RPG Project Accelerator: the first working version of GOAP (Goal-Oriented Action Planning) is now live and integrated into the core framework!
If you've ever wanted to build AI that thinks for itself, makes decisions dynamically, and feels truly alive โ GOAP is where the magic happens.
โจ What is GOAP?
GOAP stands for Goal-Oriented Action Planning, and itโs a flexible AI approach that lets agents figure out their own way to reach a goal. Rather than scripting every behavior, you give the AI a set of goals and actions with preconditions and effects โ and it handles the planning on its own.
This means instead of hardcoding logic like:
if (IsHungry)
GoEat();
...you define actions like "FindFood" and "EatFood", and a goal like IsFed: true
, and the AI connects the dots. ๐
๐น How It Works in the Project
Here's a breakdown of how GOAP is implemented inside the 2D RPG Project Accelerator:
โ World State
A list of key-value facts about the game world or the agent's internal state.
worldState = {
"HasAxe": false,
"IsHungry": true,
"HasWood": false,
"EnemyNearby": true
};
โ๏ธ Actions
Each action has:
Preconditions: What must be true to perform this action
Effects: What will be true after this action
Cost: Used to determine the most efficient plan
public class ChopTreeAction : GoapAction
{
public ChopTreeAction()
{
AddPrecondition("HasAxe", true);
AddEffect("HasWood", true);
cost = 2f;
}
public override bool Perform(GameObject agent)
{
Debug.Log("Chopping tree...");
return true;
}
}
๐ Goals
Agents evaluate which goal to pursue, like:
{ "HasWood": true }
๐ Planning
The planner finds the best sequence of actions to get from the current world state to the goal. It's similar to pathfinding, using a search algorithm to navigate action dependencies.
Example:
If the goal is HasWood = true
, and the agent doesnโt have an axe, the AI will automatically plan:
CraftAxe
ChopTree
And execute them in that order. Fully dynamic.
๐ Goap system in place with every agent has itโs own debug data
Here's where you can see the GOAP debug view
๐ Why GOAP Matters
This system is a huge win for building more immersive gameplay:
โ AI feels alive and reactive
โ Modular โ new actions can be dropped in and everything just works
โ Easier to manage than giant state machines or behavior trees
With GOAP, your NPCs can plan and act based on whatโs happening in the world โ not what you told them to do step-by-step.
๐น GOAP AI Combat In Action
๐ Whatโs Next?
Now that the base GOAP system is live, Iโm looking at some exciting expansions:
โ๏ธ Better combat AI (plan escape, flank, call for backup)
๐ณ Resource gathering and trading
๐งณ Multi-agent collaboration
๐ค Emotional states (fear, anger, etc.) that affect decision-making
๐ Try It Now
GOAP is now part of version 1.2.0 of the 2D RPG Project Accelerator. Update your Unity project and start building smarter agents today!
https://assetstore.unity.com/packages/2d/2d-rpg-project-accelerator-296300
Got feedback, questions, or ideas? Drop them below. Always happy to chat AI.
Stay tuned for more updates โ and keep building! ๐
Subscribe to my newsletter
Read articles from Deniz Traka directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
