I am trying to make a function that gets the edge data of the navmesh in my level. The function is supposed to have an output of TArray, however, when I try to compile my C++ File, my header file has an error. My UFUNCTION declaration:
UFUNCTION(BlueprintCallable, Category = “CoverGenerator”) TArray<FNavigationPortalEdge> ReturnNavMeshEdges();
My header file includes ‘include “AI/Navigation/NavigationTypes.h”’ as the documentation instructs.
But when I try to compile, the header file says it cannot find a struct of type FNavigationPortalEdge, even though I have the include in my file.
In my actual .cpp file, I have this logic for my function:
TArray<FNavigationPortalEdge> AC_Class_CoverGenerator::ReturnNavMeshEdges()
{
TArray<FNavigationPortalEdge> Edges;
UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent(GetWorld());
ARecastNavMesh* Navmesh = Cast(NavSys->GetDefaultNavDataInstance());
if (Navmesh == nullptr) return Edges;
TArray<FNavTileRef> Tiles;
NumOfTiles = Navmesh->GetNavMeshTilesCount();
for (int32 PolyIdx = 0; PolyIdx < NumOfTiles + 1; ++PolyIdx)
{
TArray<FNavPoly> Polys;
Navmesh->GetPolysInTile(PolyIdx, Polys);
for (int32 PolyIdx = 0; PolyIdx < Polys.Num(); PolyIdx++)
{
TArray<FNavigationPortalEdge> PolyEdges;
Navmesh->GetPolyEdges(PolyIdx, PolyEdges);
Edges.Append(PolyEdges);
}
}
return Edges;
}
To test if the same error occurred in my .cpp file, I tried switching the output of the function to an int32, and if I do that, the header file obviously has no errors, but neither does the .cpp file. It seems the .cpp file can find a struct of type FNavigationPortalEdge, but the header file can’t, and I don’t understand why. Any knowledge would be appreciated.