Skip to content

liwei-cd/LGoapDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: GOAP (Goal-Oriented Action Planning) is a decision-making and planning method used for game AI and agent control. This plugin can execute complex behavior logic, customize goal sorting, and dynamically calculate the costs of actions.

Common functions

//Initialization
InitData
//Set preconditions (add or override)
void SetAgentState(FName ID, const FLUniValue& Val, bool bAddition);
//Get preconditions
bool GetAgentState(FName ID, FLUniValue& Val);
//Set goal factorvoid
void SetGoalFactor(FName GoalId, int32 Factor);
//Get goal factor
bool GetGoalFactor(FName GoalId, int32& Factor);
//execute
void RunGoap();
//Force execute
void ForceRun(FName GoalId);
//Interrupt, stop (whether to clear previous actions)
void StopGoap(bool bClearPlan);
//Complete current action
void FinishCurrAction(bool bSuccess=true);
//Get current action
FName GetCurrActionID() const;
//Get all current actions
TArray<FDataBase> GetCurrActions() const;

//Set preconditions
static bool GetWorldState(FName ID, FLUniValue& Val);
//设置前置条件(叠加)
static void SetWorldState(FName ID, const FLUniValue& Val, bool bAddition);
//Clean up
static void CleanState();

Special functions

Objects must inherit the 'LGoapInterface' interface

//Execute action (returns the number of actions)
void RunGoapAction(const FLGoapAction& Action, int32 ActionNum);
virtual void RunGoapAction_Implementation(const FLGoapAction& Action, int32 ActionNum){}
//Action completion (achieving effect)
void OnActionFinish(bool bSuccess, const FLGoapAction& Action);
virtual void OnActionFinish_Implementation(bool bSuccess, const FLGoapAction& Action) {}
//Action failure (can forcedly idle)
void OnGoapFailed();
virtual void OnGoapFailed_Implementation(){}
//Calculate the action cost
int32 CalcActionCost(const FLGoapAction& Action);
virtual int32 CalcActionCost_Implementation(const FLGoapAction& Action){ return Action.Cost;}
//Calculate the goal cost (0 means cancel target, the lower the priority)
int32 CalcGoalCost(const FLGoapGoal& Goal, int32 Factor);
virtual int32 CalcGoalCost_Implementation(const FLGoapGoal& Goal, int32 Factor){ return Goal.Cost;}
//Check condition 
bool CheckGoapCondition(const FLGoapCondition& Condition);
virtual bool CheckGoapCondition_Implementation(const FLGoapCondition& Condition){ return false; }
};

Copyright © 2025 liwei email:289423619@qq.com

About

Goal Oriented Action Planning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published