Hello Unrealers!
I am receiving an error when trying to get the DebugGEometry form my NavMeshData, I need the edges of the navmesh for a cover system. here is my code:
EnvQueryGenerator_NavMeshEdges.h:
#pragma once
#include "CoreMinimal.h"
#include "EnvironmentQuery/EnvQueryGenerator.h"
#include "DataProviders/AIDataProvider.h"
#include "NavMesh/RecastNavMesh.h"
#include "EnvQueryGenerator_NavMeshEdges.generated.h"
/**
* Gets all the vertex positions fro,
* the NavMesh Edges
*/
UCLASS(meta = (DisplayName = "Points: Nav Mesh Edges"))
class HARRISONPROJECT_API UEnvQueryGenerator_NavMeshEdges : public UEnvQueryGenerator
{
GENERATED_UCLASS_BODY()
/** search radius */
UPROPERTY(EditDefaultsOnly, Category = Generator)
FAIDataProviderFloatValue SearchRadius;
/** context */
UPROPERTY(EditDefaultsOnly, Category = Generator)
TSubclassOf<UEnvQueryContext> GenerateAround;
virtual void GenerateItems(FEnvQueryInstance& QueryInstance) const override;
// Return world navigation mesh data
static ARecastNavMesh* GetNavMeshData(UWorld* World);
};
EnvQueryGenerator_NavMeshEdges.cpp:
#include "EnvQueryGenerator_NavMeshEdges.h"
#include "EnvironmentQuery/Contexts/EnvQueryContext_Querier.h"
#include "Engine/World.h"
#include "AI/NavigationSystemBase.h"
#include "AI/Navigation/NavigationTypes.h"
UEnvQueryGenerator_NavMeshEdges::UEnvQueryGenerator_NavMeshEdges(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
SearchRadius.DefaultValue = 10000.0f;
GenerateAround = UEnvQueryContext_Querier::StaticClass();
}
void UEnvQueryGenerator_NavMeshEdges::GenerateItems(FEnvQueryInstance& QueryInstance) const
{
// Get Navigation Mesh Data
ARecastNavMesh* NavMeshData = GetNavMeshData(GetWorld());
if (NavMeshData == nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("%s: No navigation data available!"), *GetNameSafe(this));
return;
}
FRecastDebugGeometry NavMeshGeometry;
NavMeshGeometry.bGatherNavMeshEdges = true;
NavMeshData->BeginBatchQuery();
NavMeshData->GetDebugGeometry(NavMeshGeometry);
//here we could do sync or async shizzle for the cover generation
UE_LOG(LogTemp, Warning, TEXT("%s: Searching for Na"), *GetNameSafe(this));
}
ARecastNavMesh* UEnvQueryGenerator_NavMeshEdges::GetNavMeshData(UWorld* World)
{
const UNavigationSystemBase* NavSys = World->GetNavigationSystem();
if (NavSys == nullptr)
{
return nullptr;
}
return const_cast<ARecastNavMesh*>(static_cast<const ARecastNavMesh*>(NavSys->GetMainNavData()));
}
And my Error message after compile:
1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: HarrisonProject, Configuration: Development_Editor x64 ------
2>Parsing headers for HarrisonProjectEditor
2> Running UnrealHeaderTool "D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\HarrisonProject.uproject" "D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\Intermediate\Build\Win64\HarrisonProjectEditor\Development\HarrisonProjectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2>Reflection code generated for HarrisonProjectEditor in 7,1146155 seconds
2>Using Visual Studio 2017 14.16.27023 toolchain (D:\Programs\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023) and Windows 8.1 SDK (C:\Program Files (x86)\Windows Kits\8.1).
2>Building 5 actions with 8 processes...
2> [1/5] EnvQueryGenerator_NavMeshEdges.cpp
2> [2/5] EnvQueryGenerator_NavMeshEdges.gen.cpp
2> [3/5] UE4Editor-HarrisonProject.lib
2> Creating library D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\Intermediate\Build\Win64\UE4Editor\Development\HarrisonProject\UE4Editor-HarrisonProject.lib and object D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\Intermediate\Build\Win64\UE4Editor\Development\HarrisonProject\UE4Editor-HarrisonProject.exp
2> [4/5] UE4Editor-HarrisonProject.dll
2> Creating library D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\Intermediate\Build\Win64\UE4Editor\Development\HarrisonProject\UE4Editor-HarrisonProject.suppressed.lib and object D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\Intermediate\Build\Win64\UE4Editor\Development\HarrisonProject\UE4Editor-HarrisonProject.suppressed.exp
2>EnvQueryGenerator_NavMeshEdges.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl ARecastNavMesh::GetDebugGeometry(struct FRecastDebugGeometry &,int)const " (__imp_?GetDebugGeometry@ARecastNavMesh@@QEBAXAEAUFRecastDebugGeometry@@H@Z) referenced in function "public: virtual void __cdecl UEnvQueryGenerator_NavMeshEdges::GenerateItems(struct FEnvQueryInstance &)const " (?GenerateItems@UEnvQueryGenerator_NavMeshEdges@@UEBAXAEAUFEnvQueryInstance@@@Z)
2>D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\Binaries\Win64\UE4Editor-HarrisonProject.dll : fatal error LNK1120: 1 unresolved externals
2>D:\Programs\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""D:\Programs\Epic Games\UE_4.22\Engine\Build\BatchFiles\Build.bat" HarrisonProjectEditor Win64 Development -Project="D:\Projects\HarrisonProject_FelixVoigt_BinaerBoy_01\HarrisonProject\HarrisonProject.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
2>Done building project "HarrisonProject.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========
I very much appreciate your time, thanks in advance!