I get an Exception when executing this code:
void PaladinClass::BeginPlay(){
Super::BeginPlay();
this->PaladinAIController = Cast<AAIController>(GetController());
if(this->PaladinAIController && this->PaladinPatrolTarget)
{
FAIMoveRequest MoveRequest;
MoveRequest.SetGoalActor(PaladinPatrolTarget);
MoveRequest.SetAcceptanceRadius(15.f);
FNavPathSharedPtr NavPath;
this->PaladinAIController->MoveTo(MoveRequest, &NavPath);
TArray<FNavPathPoint>& PathPoints = NavPath->GetPathPoints();
for(auto& Point: PathPoints)
{
const FVector& Location = Point.Location;
DrawDebugSphere(GetWorld(), Location, 12.f, 12, FColor::Green, false, 10.f);
}
}
}
Using the debugger, I could see that the error was on
TArray<FNavPathPoint>& PathPoints = NavPath->GetPathPoints();
Where NavPath seemed to be null , but
The unreal engine crash states something like this:
Assertion failed: IsValid() [File:C:\Program Files\Epic Games\UE_5.3\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 1139]
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll
I have also confirmed that I have a Navigation Mesh in the scene. Hence, I cannot seem to find the source of the issue. Any insights would be greatly appreciated.