Late Answer:
You can use FNavMeshPath::OffsetFromCorners for this. But it is now available in blueprints.
There is an example in ANavigationTestingActor::SearchPathTo function.
FPathFindingResult Result = NavSys->FindPathSync(NavAgentProps, Query, Mode);
const double EndTime = FPlatformTime::Seconds();
const float Duration = (EndTime - StartTime);
PathfindingTime = Duration * 1000000.0f; // in micro seconds [us]
bPathIsPartial = Result.IsPartial();
bPathExist = Result.IsSuccessful();
bPathSearchOutOfNodes = bPathExist ? Result.Path->DidSearchReachedLimit() : false;
LastPath = Result.Path;
PathCost = bPathExist ? Result.Path->GetCost() : 0.0f;
if (bPathExist)
{
LastPath->AddObserver(PathObserver);
** if (OffsetFromCornersDistance > 0.0f)
{
((FNavMeshPath*)LastPath.Get())->OffsetFromCorners(OffsetFromCornersDistance);
}**
}
You can also find variable **bUseBetterOffsetsFromCorners (**use it by changing BaseEngine.ini) - but i don’t know what it does exacly.
/** TODO: switch to disable new code from OffsetFromCorners if necessary - remove it later */
UPROPERTY(config)
uint32 bUseBetterOffsetsFromCorners : 1;
But 2 warnings:
- It’s not cheap (you can use STAT_Navigation to see how exepnsive it is)
- In 4.17 (i was using it then) version there was a bug - not sure if it’s fixed. In 99.9% OffsetFromCorners worked as expected but in very rare occasions when there was long path to change, after using this function the path was broken - it could lead pawn in areas without navmesh.