No instance of overloaded function

having a problem with my code createdefaultsubobject because i keep getting no instance of overloaded function

.h #pragma once

#include "CoreMinimal.h"
#include "AIController.h"
#include "AI_Controller.generated.h"

/**
 * 
 */
UCLASS()
class PROJECTX_API AAI_Controller : public AAIController
{
	GENERATED_BODY()
	
		virtual void Possess(class APawn* InPawn) override;
	
	UPROPERTY(transient)
	class UBehaviorTreeComponent* BehaviorComp;
	
	UPROPERTY(transient)
	class UBlackboardComponent* BlackboardComp;

	AAI_Controller();


	
};



.cpp
#include "AI_Controller.h"
#include "BehaviorTree/BehaviorTree.h"
#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "AI_Character.h"
#include "UObject/UObjectGlobals.h"



void AAI_Controller::Possess(APawn * InPawn)
{
	
}

AAI_Controller::AAI_Controller()
{
	BehaviorComp = CreateDefaultSubobject<UBehaviorTreeComponent>(this, TEXT("BehaviorComp"));
}

You need to call it this way:

BehaviorComp = CreateDefaultSubobject<UBehaviorTreeComponent>(TEXT("BehaviorComp"));

Also, since you are overriding the Possess function you need to call its Super implementation first:

void AAI_Controller::Possess(APawn * InPawn)
 {
     Super::Possess(InPawn);
 }

Otherwise, your possessing won’t work properly. (Credits to Daxter154 for the catch)

1 Like

Unrelated, But shouldn’t he also be calling Super::APawn in his stub possess function since he is overriding?

Indeed, didn’t notice that the 1st time, ye nothing is going to work otherwise, I will edit my answer.