GOAP System Now Integrated

Deniz TrakaDeniz Traka
3 min read

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! ๐Ÿš€

0
Subscribe to my newsletter

Read articles from Deniz Traka directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Deniz Traka
Deniz Traka