- Create a controller based on the
AGOAPController
to let pawns execute a plan. - use
bExecuteEveryTick
to control if your controller will execute the plan on every tick - Create either a c++ class or a blueprint based on
GOAPAction
.
I highly recommend creating those mostly in blueprints because then you have the easiest way to access all your assets - Create a Blueprint based on your controller and add as many actions as you want
- Use
UpdateGoals
,SetGoals
,UpdateReachedGoals
&SetReachedGoals
to start your pawn doing some actions
use this command from your project folder:
git submodule add -b 4.26 https://github.com/Acinex/GOAP.git Plugins/GOAP
Discord
Tell me your Secret
Acinex
Patreon
An action is used to perform a single piece of a complete workflow.
You can create as complex actions as you want.
Actions are created just once per controller.
For now there are 2 events, which can be overridden. Execute and Tick. Both of them will get the pawn controlled currently by the pawn.
The controller is the owner of the action, so you can get access to it by calling GetOwner or getting the controller from the pawn.
optionally to the basic preconditions you can check with this function, if your pawn is able to fullfill this action.
The default implementation returns true
.
Every action has a cost, which by default returns the Property Cost
. The system wil try to find the next cheapest action.
Every action will tick with the FIntervalCountdown
.
Cost will set the return value for the default implementation of the function Get Cost
.
Every precondition has to be met to eventually execute this action.
Give the precondition a unique name. We selected a FText to allow you to select from a StringTable to minimize mistakes from typos.
Give the precondition a value. We wanted to give more freedom to the developers/designers which will set those values to have more varities of a goal for example. So you can reuse a name but set different "priorities" to it. For example you could add a goal to the value of 1 and with a timer you will raise this value so the pawn tries to execute a different action which is for example mor drastic since the goal wasn't reached yet.
Every of the effects will be applied once this action is markes as successfully finished. When an action is finished unsuccessfully, none of the effects are applied.
Every controller will add its own Planner which creates its own instances of actions.
Is used to alter existing goals and add new goals if not existing.
removes all the existing goals and inserts the goals from the input.
Basically the same as Update Goals
but for reached goals which will be used as preconditions.
Basically the same as Set Goals
but for reached goals which will be used as preconditions.
Will create a plan, if no action is currently active and if the plan contains any actions it will start to execute them one after another
set the starting reached goals for this controller
set the starting goals, this controller wants to reach
Decide which actions can be executed with this controller
To prevent endless chains of actions and maybe you've created a loop by accident (if this is possible), you can set a max depth the plan can have bevor the creation of this plan will be stopped
You decide, if you want to execute the generation of a plan by yourself or if the controller should handle that for you. If you experience some performance problems when you have tons of actions which will be completed in a tick, you might want to set this to false
You can change some settings for the whole project.
Whenever the system determines the next action it will select a random action of the available once instead of selecting the first which will represent the order of your action-classes in the controller
Every controller will add those actions before it will add the actions you set inside that controller.