Download

Behavior Tree usage in 4.3

Hey Guys

I’ve been playing around with 4.3 and would like to know how we should use Behavior Trees now in 4.3. The previous version’s code was like this


static ConstructorHelpers::FObjectFinder<UBehaviorTree> BehaviorTreeBP(TEXT("BehaviorTree'/Game/Blueprints/Behavior/MyAIBehaviorTree.MyAIBehaviorTree'"));
	if (BehaviorTreeBP.Succeeded())
	{
		MyAIBehaviorTree = BehaviorTreeBP.Object;
	}


UPROPERTY(VisibleAnywhere, Category = Behavior)
		TSubobjectPtr<class UBlackboardComponent> BlackboardComp;

	UPROPERTY(VisibleAnywhere, Category = Behavior)
		TSubobjectPtr<class UBehaviorTreeComponent> BehaviorComp;


BlackboardComp = PCIP.CreateDefaultSubobject<UBlackboardComponent>(this, TEXT("BlackBoardComp"));
	BehaviorComp = PCIP.CreateDefaultSubobject<UBehaviorTreeComponent>(this, TEXT("BehaviorComp"));

However, now it all generates errors as if an #include < … > in not included. Any ideas ??

You need to include BehaviorTree headers now.

#include “BehaviorTree/BlackboardComponent.h”
#include “BehaviorTree/BehaviorTreeComponent.h”
#include “BehaviorTree/BehaviorTree.h”

Also AIController.h is no longer in GameFramework so if you’re using an AAIController;

#include “AIController.h”

is all you need

Ahh great thanks, i’ll try it out.

Awesome. it worked, thanks !