DoN's 3D Pathfinding for Flying A.I. [Support Thread]

Invoke from C++

I am trying to invoke the HotPursuit behavior from C++. I have a Don Navigation Manager placed in my map with appropriate sizing.

Here is my enemy pawn controller source:


#include "Ascentroid.h"
#include "AscEnemyController.h"

AAscEnemyController::AAscEnemyController(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	BlackboardComponent = ObjectInitializer.CreateDefaultSubobject<UBlackboardComponent>(this, TEXT("BlackboardComponent"));
	BehaviorTreeComponent = ObjectInitializer.CreateDefaultSubobject<UBehaviorTreeComponent>(this, TEXT("BehaviorTreeComponent"));

	FString Path = "/Game/DonNavigationSamples/BehaviorTree/HotPursuit";
	BehaviorTree = Cast<UBehaviorTree>(StaticLoadObject(UBehaviorTree::StaticClass(), nullptr, *Path));
}

void AAscEnemyController::Possess(APawn* InPawn)
{
	Super::Possess(InPawn);

	if (BehaviorTree)
	{
		if (GetWorld() != nullptr)
		{
			auto TimerDelegate = FTimerDelegate::CreateUObject(this, &AAscEnemyController::InitAI, InPawn);
			GetWorldTimerManager().SetTimer(AITimer, TimerDelegate, 1.f, true, 0.f);
			//GetWorld()->GetTimerManager().SetTimer(AITimer, this, &AAscEnemyController::InitAI, 1.f, true, 0.f);
		}
	}
}

void AAscEnemyController::InitAI(APawn* InPawn)
{
	if (GetWorld() == nullptr)
	{
		UAscUtil::Debug(TEXT("GetWorld() is null!"));
		return;
	}

	auto CurrentPlayer = static_cast<AAscPlayerCharacter*>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));

	if (CurrentPlayer == nullptr)
	{
		UAscUtil::Debug(TEXT("CurrentPlayer is null!"));
		return;
	}

	BlackboardComponent->InitializeBlackboard(*BehaviorTree->BlackboardAsset);

	auto Target = Cast<AAscEnemy>(InPawn);

	BlackboardComponent->SetValueAsObject("Target", Target);
	BlackboardComponent->SetValueAsObject("SelfActor", Target);
	BlackboardComponent->SetValueAsVector("TargetLocationKey", CurrentPlayer->GetActorLocation());
	BlackboardComponent->SetValueAsVector("FlightGoal", CurrentPlayer->GetActorLocation());

	BehaviorTreeComponent->StartTree(*BehaviorTree, EBTExecutionMode::Looped);

	UAscUtil::Debug(TEXT("InitAI started!"));

	GetWorld()->GetTimerManager().ClearTimer(AITimer);
}

When I enter the map, however, I get the following error(s):


[2017.05.30-00.03.39:187][264]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:200][265]LogCoherentUIGT:Error: ConsoleAPI coui://UIResources/Gui/static/js/coherent.js:652:16: TypeError: undefined is not an object (evaluating 'n("#asc-hud-content-player-placement-"+t+"-name").css("visibility").indexOf')
	coui://UIResources/Gui/static/js/app.17eabe89d9f670abddf3.js:1:30009
[2017.05.30-00.03.39:210][266]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:225][268]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:244][270]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:266][272]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:288][274]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:308][276]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:329][278]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:350][280]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:372][282]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:392][284]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:413][286]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:435][288]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:454][290]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:474][292]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:495][294]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:495][294]LogScript:Warning: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn
	Service_Pursuit_Helper_C /Game/Ascentroid/Maps/UEDPIE_0_MAP_Scale_Testing.MAP_Scale_Testing:PersistentLevel.AscEnemyController_0.BehaviorTreeComponent.Service_Pursuit_Helper_C_0
	Function /Game/DonNavigationSamples/BehaviorTree/Service_Pursuit_Helper.Service_Pursuit_Helper_C:ExecuteUbergraph_Service_Pursuit_Helper:00AA
[2017.05.30-00.03.39:495][294]PIE:Error: Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn from function: 'ExecuteUbergraph_Service_Pursuit_Helper' from node: Branch in graph: EventGraph in object: Service_Pursuit_Helper with description: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn
[2017.05.30-00.03.39:496][294]LogBlueprintUserMessages: [Service_Pursuit_Helper_C_0] RESTARTING PURSUIT (Player has gotten way ahead of this bot!)
[2017.05.30-00.03.39:517][296]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:537][298]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:557][300]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:579][302]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:599][304]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:619][306]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:640][308]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:661][310]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:682][312]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:718][314]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:736][316]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:758][318]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:786][320]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:805][322]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:826][324]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:848][326]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:868][328]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:888][330]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:910][332]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:930][334]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:950][336]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:971][338]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.39:991][340]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:002][341]LogScript:Warning: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn
	Service_Pursuit_Helper_C /Game/Ascentroid/Maps/UEDPIE_0_MAP_Scale_Testing.MAP_Scale_Testing:PersistentLevel.AscEnemyController_0.BehaviorTreeComponent.Service_Pursuit_Helper_C_0
	Function /Game/DonNavigationSamples/BehaviorTree/Service_Pursuit_Helper.Service_Pursuit_Helper_C:ExecuteUbergraph_Service_Pursuit_Helper:00AA
[2017.05.30-00.03.40:003][341]PIE:Error: Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn from function: 'ExecuteUbergraph_Service_Pursuit_Helper' from node: Branch in graph: EventGraph in object: Service_Pursuit_Helper with description: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn
[2017.05.30-00.03.40:003][341]LogBlueprintUserMessages: [Service_Pursuit_Helper_C_0] RESTARTING PURSUIT (Player has gotten way ahead of this bot!)
[2017.05.30-00.03.40:012][342]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:033][344]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:053][346]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:073][348]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:092][350]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:112][352]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:132][354]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:151][356]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:171][358]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:190][360]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:210][362]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:229][364]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:249][366]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:268][368]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:287][370]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:307][372]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:326][374]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:345][376]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:364][378]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:383][380]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:402][382]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:421][384]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:440][386]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:459][388]LogBlueprintUserMessages: [PickBot_C_0] Invalid Goal
[2017.05.30-00.03.40:468][389]LogScript:Warning: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn
	Service_Pursuit_Helper_C /Game/Ascentroid/Maps/UEDPIE_0_MAP_Scale_Testing.MAP_Scale_Testing:PersistentLevel.AscEnemyController_0.BehaviorTreeComponent.Service_Pursuit_Helper_C_0
	Function /Game/DonNavigationSamples/BehaviorTree/Service_Pursuit_Helper.Service_Pursuit_Helper_C:ExecuteUbergraph_Service_Pursuit_Helper:00AA
[2017.05.30-00.03.40:468][389]PIE:Error: Error Blueprint Runtime Error: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn from function: 'ExecuteUbergraph_Service_Pursuit_Helper' from node: Branch in graph: EventGraph in object: Service_Pursuit_Helper with description: Accessed None trying to read property CallFunc_Get_Goal_Bot_Pawn
[2017.05.30-00.03.40:468][389]LogBlueprintUserMessages: [Service_Pursuit_Helper_C_0] RESTARTING PURSUIT (Player has gotten way ahead of this bot!)

It seems like the “Get Goal Bot” function call in “Service_Pursuit_Helper” is returning ‘None’. I can’t figure out why. Any ideas? It feels like I am missing something obvious. You can see I try setting the target/pawn with SetValueAsObject, but I have no idea if this is the right way to do it.

Thanks!