Pointer to incomplete?

I keep getting this error and I am unsure how to fix it.

“Error: pointer to incomplete class type is not allowed.”

My Code is


void AMonster_AI::Possess(class APawn *InPawn){
	Super::Possess(InPawn);
	AMonster_Bot* bot = Cast<AMonster_Bot>(InPawn);

	if (bot  && bot->BotBehavior){ 
		BlackboardComp->InitializeBlackboard(bot->BotBehavior->BlackboardAsset);
	}
}


class AROUNDTHECORNERC_API AMonster_Bot : public ACharacter
{

	GENERATED_BODY()
public:
	// Sets default values for this character's properties
	AMonster_Bot();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

	UPROPERTY(EditAnywhere, Category = Behavior)
	class UBehaviorTree* BotBehavior;
	
	
};

Try to include your Monster_Bot class header (: The class you are working in has no knowledge about the class -> incomplete.

See, that was my first thought, however every line works apart from
“BlackboardComp->InitializeBlackboard(bot->BotBehavior->BlackboardAsset);”

“bot && bot->BotBehavior” works fine. If I do “bot->BotBehavior;” it works fine as well. Its just when trying to expand from BotBehavior. I also have it public.

Its also included. Also just to confirm I do include the .h file right?

Make sure you have all header files included that are necessary. I have a header file that contains all my headers, so right now i don’t know which
headers are exactly needed. But i guess you are missing the BehaviorTree ones.

Inside your .h files from the Controller, add these includes:



#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/BehaviorTree.h"


As well as your Monster_Bot.h if haven’t already.

I think I was missing BehaviorTree.h
However, I have a new error now on the same line. "Error: a reference of type “UBlackboardData &” (not const-qualified) cannot be initialized with a value of type “UBlackboardData *” "

Yeah i guess they changed that and the tutorial you are following isn’t updated. Had the same problem. Here is my code version of that part:



UBehaviorTree* BHTree = Bot->GetBotBehavior();

BlackboardComp->InitializeBlackboard(*(BHTree->BlackboardAsset));



Do you know any up to date tutorials I could take a look at? Or example code or something.

): No sorry. At least not without searching for it myself. But normaly you should be able to fix errors like these yourself. Or you still need to learn basic c++ first.