AAIController::BuildPathfindingQuery
#include "AIController.h"
Access: public
Description
Constructs an FPathFindingQuery from a move request and the current pawn's agent properties. Returns false if the query cannot be built (e.g., no valid nav data for this agent).
Caveats & Gotchas
- • Returns false — not an assert — when the navigation system cannot find nav data for the pawn. Always check the return value before passing OutQuery to FindPathForMoveRequest.
- • A second overload exists that accepts an explicit StartLocation: BuildPathfindingQuery(MoveRequest, StartLocation, OutQuery). Use it when pathfinding should start from a position other than the pawn's current location, such as during predictive look-ahead.
- • The query is built using the pawn's INavAgentInterface properties. If your pawn does not implement INavAgentInterface correctly, the query will use fallback agent settings.
Signature
bool BuildPathfindingQuery(const FAIMoveRequest& MoveRequest, FPathFindingQuery& OutQuery) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MoveRequest | const FAIMoveRequest& | The move request to build a query from. | — |
| OutQuery | FPathFindingQuery& | Output query populated with agent properties, nav filter, goal location, and start location derived from the pawn. | — |
Return Type
bool Example
Build a query to test reachability without moving C++
bool AMyAIController::CanReachLocation(FVector Target) const
{
FAIMoveRequest MoveReq(Target);
MoveReq.SetAcceptanceRadius(50.f);
FPathFindingQuery Query;
if (!BuildPathfindingQuery(MoveReq, Query))
{
return false; // No nav data for this agent
}
UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
return NavSys && NavSys->TestPathSync(Query);
} Tags
Version History
Introduced in: 4.13
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?