RealDocs

AAIController::MoveTo

function AIModule Since 4.0
#include "AIController.h"
Access: public Specifiers: virtual

Description

The core move dispatch function — builds a path and passes it to the PathFollowingComponent. MoveToActor and MoveToLocation both call this internally after packaging their parameters into an FAIMoveRequest.

Caveats & Gotchas

  • Override this in a subclass (not MoveToActor/MoveToLocation) when you need to intercept or modify every move request, regardless of which Blueprint or C++ function triggered it.
  • The returned FPathFollowingRequestResult contains both a MoveId (FAIRequestID) and an enum Code — always check Code before using the MoveId, as an invalid request still returns an object.
  • OutPath is filled synchronously only when pathfinding is not async. With async pathfinding enabled, the pointer may be empty immediately after the call.

Signature

virtual FPathFollowingRequestResult MoveTo(const FAIMoveRequest& MoveRequest, FNavPathSharedPtr* OutPath = nullptr)

Parameters

Name Type Description Default
MoveRequest const FAIMoveRequest& Fully populated move request struct describing the goal, filter, acceptance radius, and all other movement parameters.
OutPath FNavPathSharedPtr* Optional output pointer filled with the generated nav path for inspection or caching. nullptr

Return Type

FPathFollowingRequestResult

Example

Override MoveTo to log every request C++
FPathFollowingRequestResult AMyAIController::MoveTo(const FAIMoveRequest& MoveRequest, FNavPathSharedPtr* OutPath)
{
	UE_LOG(LogAI, Log, TEXT("MoveTo called: GoalActor=%s"),
		MoveRequest.GetGoalActor() ? *MoveRequest.GetGoalActor()->GetName() : TEXT("none"));
	return Super::MoveTo(MoveRequest, OutPath);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.