AAIController::MoveToActor
#include "AIController.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Commands the AI to move toward a specified actor, continuously updating the destination as the goal moves. Aborts any currently active path following request.
Caveats & Gotchas
- • Only exists on the server in networked games — AAIController itself is server-only. Calling this on a client has no effect.
- • AcceptanceRadius defaults to -1, not 0. The engine maps -1 to UPathFollowingComponent::DefaultAcceptanceRadius (typically the pawn's radius). Passing 0 means 'stop exactly at the nav point', which can cause jitter.
- • The delegate ReceiveMoveCompleted fires when the move finishes or is aborted — check the EPathFollowingResult to distinguish success from failure.
Signature
EPathFollowingRequestResult::Type MoveToActor(AActor* Goal, float AcceptanceRadius = -1, bool bStopOnOverlap = true, bool bUsePathfinding = true, bool bCanStrafe = true, TSubclassOf<UNavigationQueryFilter> FilterClass = {}, bool bAllowPartialPath = true) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Goal | AActor* | The actor to move toward. Destination is updated continuously as the actor moves. | — |
| AcceptanceRadius | float | Distance in cm at which the move is considered complete. Pass -1 to use the default (UPathFollowingComponent::DefaultAcceptanceRadius). | -1 |
| bStopOnOverlap | bool | When true, adds the pawn's radius to AcceptanceRadius so the move stops when capsules overlap. | true |
| bUsePathfinding | bool | When false the pawn moves in a straight line ignoring nav mesh. | true |
| bCanStrafe | bool | Sets bAllowStrafe on the controller, allowing the pawn to strafe while moving. | true |
| FilterClass | TSubclassOf<UNavigationQueryFilter> | Navigation query filter to use. Defaults to DefaultNavigationFilterClass if not specified. | {} |
| bAllowPartialPath | bool | When true, the pawn will follow a partial path if the goal is unreachable. | true |
Return Type
EPathFollowingRequestResult::Type Examples
Command the AI to move to a target actor with 100-unit acceptance radius
Blueprint
Move to a target actor C++
void AMyAIController::ChaseTarget(AActor* Target)
{
EPathFollowingRequestResult::Type Result = MoveToActor(Target, 100.f);
if (Result == EPathFollowingRequestResult::RequestSuccessful)
{
// Move started; wait for ReceiveMoveCompleted delegate
}
else if (Result == EPathFollowingRequestResult::AlreadyAtGoal)
{
// Already within acceptance radius
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?