PushInstance is protected in UBehaviorTreeComponent

Hi,

I want to execute dynamically behavior trees. I wanted to use the function PushInstance like its done in UBTTask_RunBehavior. But I can’t access the function since its protected. Is there a reason it is protected or is there another way to execute behavior trees dynamically?

AAIController::RunBehaviorTree is the way to go. If you encounter any issues while using it please let me know.

Cheers,

–mieszko

Hi,

sorry I meant like executing a subtree from my behavior tree. I wanted to write my own RunBehavior-Task to change the executed behavior tree during runtime because the RunBehavior-Task can only be set up once in the behavior tree and its not changable during runtime. But when I use AAIController::RunBehaviorTree it it will be executed in a loop and I don’t get back to the parent behavior tree, also if the execution failed.

I hope now it is better to understand what I want.

I suggest you derived from UBTTask_RunBehavior and override UBTTask_RunBehavior::ExecuteTask to set BehaviorAsset to whatever you want before calling Super::ExecuteTask. That should work :smiley:

Hi,

sorry for being annoying. I tried that before and tried it again but I get an unresolved external symbol error if I try to override the ExecuteTask function from RunBehavior.

Error 1 error LNK2019: unresolved external symbol “public: virtual enum EBTNodeResult::Type __cdecl UBTTask_RunBehavior::ExecuteTask(class UBehaviorTreeComponent *,unsigned char *)” (?ExecuteTask@UBTTask_RunBehavior@@UEAA?AW4Type@EBTNodeResult@@PEAVUBehaviorTreeComponent@@PEAE@Z) referenced in function “public: virtual enum EBTNodeResult::Type __cdecl UMyBTTask_RunBehavior::ExecuteTask(class UBehaviorTreeComponent *,unsigned char *)” (?ExecuteTask@UMyBTTask_RunBehavior@@UEAA?AW4Type@EBTNodeResult@@PEAVUBehaviorTreeComponent@@PEAE@Z) E:\Unreal Projects\NSTopDownCameraTask\Intermediate\ProjectFiles\MyBTTask_RunBehavior.cpp.obj NSTopDownCameraTask

Adjust BTTask_RunBehavior's class so that it’s fully exported, like so:

class AIMODULE_API UBTTask_RunBehavior : public UBTTaskNode
{
...

I’ll make the same change on our side so that it’s official :slight_smile:

Will it come with the 4.5 version?