The AI itself does work (they walk around and such). It has a BehaviorTree, a Blackboard, my AIController and the BrainComponent of my AIController is properly assigned. Everything seems proper. Why can I not debug the BehaviorTree? I tried both PIE editor and simulate.
In OnPossess() I call RunBehaviorTree() and I stepped through the function but it seems just fine. I’ll post the code here just in case but I think the problem is somewhere else:
bool AAIController_Enemy::RunBehaviorTree(UBehaviorTree * BTAsset)
{
if (BTAsset == NULL)
{
LOG_ERROR("RunBehaviorTree: Unable to run NULL behavior tree.")
return false;
}
bool bSuccess = true;
bool bShouldInitializeBlackboard = false;
// see if need a blackboard component at all
UBlackboardComponent* BlackboardComp = NULL;
if (BTAsset->BlackboardAsset)
{
bSuccess = UseBlackboard(BTAsset->BlackboardAsset, BlackboardComp);
}
if (bSuccess)
{
UBehaviorTreeComponent* BTComp = Cast<UBehaviorTreeComponent>(BrainComponent);
if (BTComp == NULL)
{
BTComp = NewObject<UBehaviorTreeComponent>(this, TEXT("BTComponent"));
BTComp->RegisterComponent();
}
else
{
BTComp->StopTree();
}
// make sure BrainComponent points at the newly created BT component
BrainComponent = BTComp;
check(BTComp != NULL);
OwningEnemy->BlackboardComp = Blackboard;
if (OwningEnemy->BlackboardComp == nullptr) { LOG_ERROR("Failed to get blackboardComp for %s.", *GetName()) }
BTComp->StartTree(*BTAsset, EBTExecutionMode::Looped);
}
return bSuccess;
}