SimpleMoveToLocation Events

I’m using SimpleMoveToLocation with my Player Character. I need to know when the character is finished moving to the goal destination, regardless if the goal destination was reached successfully or it failed. In either case, I need to be notified when the character has stopped moving. I didn’t see events like this in the API docs.

I’m on UE4.6.

I’d also like to know.

Me three.

I’m using the same click navigation from the topdown demo, but restricting the movement to single click pathfinding. As such, I’m adding a Decal marker to show the movement destination, but then need to remove/hide it once the Player has reached the destination.

If you’re working from an AI Controller, there’s already a default callback being called automatically. It’s virtual so you can add your own logic to it: OnMoveCompleted. It’s also called when a move is finished, fails, or is interrupted. On your derived controller, simple override it.

If you’re not working from a controller:

Set the callback:

if (!MyPathHandle.IsValid())
{
	MyPathHandle = MyAIController->GetPathFollowingComponent()->OnMoveFinished.AddUObject(this, &AMyGameObject::OnMyAIMoveCompleted);
}

In the .h file:

void OnMyAIMoveCompleted(FAIRequestID RequestID, EPathFollowingResult::Type Result);

The callback will happen whether it succeeds, fails, or is canceled (like if you call another SimpleMoveTo while the current one is running or you cancel the navigation (eg, call StopMovement)).

If you need to clean up:

	MyAIController->GetPathFollowingComponent()->OnMoveFinished.Remove(MyPathHandle);
	MyPathHandle.Reset();