AAIController::MoveToLocation
#include "AIController.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Commands the AI to navigate to a fixed world-space location. Unlike MoveToActor, the destination does not update after the move starts.
Caveats & Gotchas
- • If Dest is off the nav mesh and bProjectDestinationToNavigation is false, pathfinding will fail immediately — you'll get EPathFollowingRequestResult::Failed. Enable bProjectDestinationToNavigation or snap the position yourself first.
- • The move is aborted silently if the NavSystem cannot build a query (e.g., no RecastNavMesh in the level). Always check the return value.
- • Calling this every tick to chase a moving point causes constant path invalidation and is expensive — use MoveToActor for dynamic targets instead.
Signature
EPathFollowingRequestResult::Type MoveToLocation(const FVector& Dest, float AcceptanceRadius = -1, bool bStopOnOverlap = true, bool bUsePathfinding = true, bool bProjectDestinationToNavigation = false, bool bCanStrafe = true, TSubclassOf<UNavigationQueryFilter> FilterClass = {}, bool bAllowPartialPath = true) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Dest | const FVector& | World-space target position to navigate to. | — |
| AcceptanceRadius | float | Distance in cm at which the move is considered complete. -1 uses the default. | -1 |
| bStopOnOverlap | bool | Adds the pawn's radius to AcceptanceRadius when true. | true |
| bUsePathfinding | bool | When false, pawn moves in a straight line. | true |
| bProjectDestinationToNavigation | bool | Projects the destination onto the nav mesh before pathfinding. Useful when the target location is slightly off-mesh. | false |
| bCanStrafe | bool | Allows strafing during movement. | true |
| FilterClass | TSubclassOf<UNavigationQueryFilter> | Navigation query filter override. | {} |
| bAllowPartialPath | bool | Follow a partial path if the destination is unreachable. | true |
Return Type
EPathFollowingRequestResult::Type Examples
Navigate the AI to a patrol point location with 50-unit acceptance radius
Blueprint
Navigate to a patrol point C++
void AMyAIController::MoveToPatrolPoint(FVector PatrolLocation)
{
EPathFollowingRequestResult::Type Result = MoveToLocation(PatrolLocation, 50.f);
if (Result == EPathFollowingRequestResult::Failed)
{
UE_LOG(LogAI, Warning, TEXT("MoveToLocation failed: destination may be off nav mesh"));
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?