Mihaitron
(Mihaitron)
September 26, 2019, 6:25pm
1
Hello! Is there any way to reference the nav mesh bounds volume or the nav modifier in code? I’m quite new to UE4 and I haven’t found anything that would help.
silik1
(silik1)
September 26, 2019, 6:59pm
2
Hi!
I’m fair new also, especially about c++ (that’s the grain of salt).
There is a module to add in you build.cs if you wanna mess with navmesh : Epic Docs .
Then you should be able to grab a reference and to it using:
Here an example using it to find a random reachable spot
[TABLE=“class: highlight tab-size js-file-line-container”]
FVector ANpc_AIController::GetRandomSearchLocation(float Radius)
[TABLE=“class: highlight tab-size js-file-line-container”]
{
[TABLE=“class: highlight tab-size js-file-line-container”]
FVector Origin = AICharacter->GetActorLocation();
[TABLE=“class: highlight tab-size js-file-line-container”]
FNavLocation Result;
[TABLE=“class: highlight tab-size js-file-line-container”]
[TABLE=“class: highlight tab-size js-file-line-container”]
UWorld* World = GEngine->GetWorld();
[TABLE=“class: highlight tab-size js-file-line-container”]
if ensure(!World) { return Origin; }
[TABLE=“class: highlight tab-size js-file-line-container”]
[TABLE=“class: highlight tab-size js-file-line-container”]
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetCurrent(World);
[TABLE=“class: highlight tab-size js-file-line-container”]
if ensure(!NavSystem) { return Origin; }
[TABLE=“class: highlight tab-size js-file-line-container”]
[TABLE=“class: highlight tab-size js-file-line-container”]
bool bFoundPath = NavSystem->GetRandomReachablePointInRadius(Origin, Radius, Result);
[TABLE=“class: highlight tab-size js-file-line-container”]
[TABLE=“class: highlight tab-size js-file-line-container”]
return Result.Location;
}
Hope it helps.