Hi everyone, I’m stuck in trying to visualize the navigation points and I can’t figure out why this error is happening:
I get an Exception when executing this code:
I write the following code in the beginPlay function of my character class:
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 double checked I have a nav mesh: