BehaviorTree: Can't find matching actors

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;
}

Solved it. Looks like another UE4 bug.

Fix:

  • Restart UE4
  • Close the behaviorTree window (or at least make sure it’s not open)
  • Start the game (simulation or PIE, doesn’t matter)
  • Do NOT pause the game
  • Open the BehaviorTree window. It will now work. You can also now pause the game if you like.

Steps to reproduce the bug:

  • Start UE4 (through VS2017 if it matters, using UE4.18.1)
  • Start the game
  • Pause the game
  • Open the Behavior tree. It will now bug (always be inactive and it will show “can’t find any matching actors”.

I reported the bug here: https://answers.unrealengine.com/questions/726306/behaviortree-is-inactive.html

IF you can’t see your actor in BT, try save it… yeah i get stuck on that for 1 hour, save it and it will work