I’m trying to use a function that gets the UNavigationPath towards a player pawn, but the first point in the path array is always the origin of the level. I’m relatively new to UE4, so I have no idea what to do to fix this. This is the code for the function I’m trying to use:
ACharacter* playerPawn = UGameplayStatics::GetPlayerCharacter(this, 0);
UNavigationPath* navPath = UNavigationSystemV1::FindPathToActorSynchronously(this, GetActorLocation(), playerPawn);
if (navPath && navPath->PathPoints.Num() > 1) {
// return next point
return navPath->PathPoints[1];
}
// no path
return GetActorLocation();
The overall project compiles and works fine, it’s just the first point the AI goes to appears to be the origin of the level.