I have added the c++ service to my Behaviour tree and it never gets called.
I have C++ BT Tasks that get called just fine.
I have blueprint custom BT services that get called just fine.
But c++ BT services never get called, as you can see i have log message in it and also added break points that never get hit.
Any help much appreciated
I am using UE5
Everything i am doing with Behaviour Tree in BP and C++ works just fine except C++ BT Services
As mentioned BP Services work too.
UCLASS()
class UBTS_SetupNpcChase : public UBTService_BlackboardBase
{
GENERATED_BODY()
public:
//UBTS_SetupNpcChase(const FObjectInitializer& ObjectInitializer);
UBTS_SetupNpcChase();
//UFUNCTION(BlueprintCallable)
void OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "NPC Data", meta = (AllowPrivateAccess = "true"))
FBlackboardKeySelector mvo_PlayerCharKey;
};
UBTS_SetupNpcChase::UBTS_SetupNpcChase()
{
//verify(false);
bNotifyBecomeRelevant = true;
bNotifyTick = true;
bNotifyCeaseRelevant = true;
bNotifyOnSearch = true;
}
void UBTS_SetupNpcChase::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::OnBecomeRelevant(OwnerComp, NodeMemory);
M_LOG(g_AppLog, Display, true, "UBTS_SetupNpcChase::OnBecomeRelevant");
AAIController* pAiCtrl = Cast<AAIController>(OwnerComp.GetAIOwner());
ANpcCharacterBase* pNpcChar = Cast<ANpcCharacterBase>(pAiCtrl->GetCharacter());
UBlackboardComponent* pBlackBoardComp = OwnerComp.GetBlackboardComponent();
ACharacter* pPlayerChar = Cast<ACharacter>(pBlackBoardComp->GetValueAsObject(mvo_PlayerCharKey.SelectedKeyName));
verifyf(pPlayerChar != nullptr, TEXT("Invalid Player pointer"));
FRotator lc_lookRotation = UKismetMathLibrary::FindLookAtRotation(
pNpcChar->GetActorLocation(),
pPlayerChar->GetActorLocation()
);
pNpcChar->SetActorRotation(lc_lookRotation.Quaternion());
}