I am trying to use the existing navigation path finding to get a list of points for my AI to travel through, I have the nav mesh generated as the regular AIMoveTo function works flawlessly, so that means it must be with my code. I have not found anything in reguards to the proper up to date way of interacting with the navigation system as I am on 5.4.1
This is the code that I have cobbled together and pathResult is always unsuccessful, it claims an error of 1, which according to documentation is just “Error”. I know for a fact that Start and End are valid locations that have worked when using AIMoveTo.
Hi there! I’ve just migrated from UE5.2 to UE5.3 and suddenly my FindPathSync returns always false (but NavMesh is Ok and character moves using MoveTo). To solve it I had to specify PathQuery.QueryFilter additionally to my previously specified parameters (seems that since EU5.3 it’s turned to null or whatever) Here is the code:
// Use the Navigation System to find the path
UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent(GetWorld());
AActor* OwnerChar = this; // Assuming this is a valid actor like a Pawn
if (!OwnerChar)
{
UE_LOG(LogTemp, Error, TEXT(“Owner is null!”));
return;
}
// Use the default query filter class
TSubclassOf QueryFilterClass = UNavigationQueryFilter::StaticClass();
FSharedConstNavQueryFilter QueryFilter = UNavigationQueryFilter::GetQueryFilter(*NavSys->GetDefaultNavDataInstance(), OwnerChar, QueryFilterClass);
// Now use QueryFilter in your pathfinding query
FPathFindingQuery PathQuery;
PathQuery.StartLocation = StartLocation;
PathQuery.EndLocation = PathDestination;
PathQuery.NavData = NavSys->GetDefaultNavDataInstance();
PathQuery.Owner = OwnerChar;
PathQuery.QueryFilter = QueryFilter;