Character simple move to location Completed event

Hi,
is there a way to determine if a character has finished the SimpleMoveToLocation Action?
I thought it was the output node but that’s executed when player starts walking.

Thanks!

What comes first to my mind would be to spawn a trigger where and when you first click to make your character move (do Once) and then when he enters the trigger you make the event completed?
May not be the best way but it’s an easy one I think !

A slightly alternative way would be: Add a box to your character and do this:
Simple Move to Location > Set Box World Location (Both at the same location) > Set “CheckForCollision” (Bool) > When collides (Set HasFinishedMoving, Turn off CheckForCollision) .etc

This makes it easier for debugging and repeating multiple times. This way you can change your mind while the Actor is moving and not have boxes stuck in your scene (If you forget to destroy them!)

This seems like a better idea :smiley:

If you have your current location, and the location you’re going, you can simply check the distance between the 2 Vectors by subtracting them from each other and using “Vector Length”. Compare that number to an acceptable radius around where you want to be (say 25), then you can tell your Pawn what to do next or simply broadcast it has arrived:

If you’re actually using a Character Blueprint, you can actually use the “Get Velocity” node and run a check on the speed of the character to see if it has stopped so you don’t have to spam a distance calculation.


I’m sure there’s a way to move this out of Tick and fire it as a delegate, but I’m not really up to date on them.

For AI Controllers you have “Get Move Status” that is set to Idle, Waiting, Paused, or Moving (it’s an Enum), which you can check against. When the AI is moving, the status is moving, when it reaches the destination, it’s idle.

Behavior Trees also have this functionality already built in their “Move To” nodes.

Hope this helps! =)

2 Likes

Checked this thread to help but found a new little trick instead, thanks . :slight_smile:

Well I be damned; I wish I knew about this sooner! Thanks!

I have an issue with the approach of using GetMoveStatus. In most cases it returns correctly with “Idle” state when the target location has been reached. However, in some situations (same actor and map, can’t see any obvious difference) after the actor has reached the target location, its state is still “Moving” for a while, even if visually the actor is not moving any more. Then, after about 1-2 seconds, it becomes idle.

Any ideas what could be wrong here?

Can you fill us in on what the “Little Trick” was??

I think he was responding to the trick in the post he quoted

I had this same problem and it was because in my MoveToLocation I had the AcceptanceParameter at 0.f. I wanted the actor to go to the exact location. I tried 0.1f and the problem disappeared.

In addition to what Shaddon said, I also wanted to point out that, for AI controllers, you can override the OnMoveCompleted function. There is a great article about that here with code examples:

You actually can set and compare 2 vector variables, say - current location and target location, if vectors near equal - shoot some exec. But that method need some event tick or any sort of constant exec for constantly setting current location variable when character are moving.

A simple solution I found:

  • Set Simple Move to Location
  • Each tick call GetCurrentPath.
  • If that path IsValid then you’re still moving. If it’s not, then you’ve reached your destination.

Since GetCurrentPath just returns a copy of your path, it should be a pretty cheap call.

2 Likes

Thanks for sharing the great article. For future readers this might speed you up.

In C++ we can override the following method, AAIController::OnMoveCompleted | Unreal Engine Documentation

For Blueprints we can use the bind node and connect a custom event to it,

Everything was taken from this great article,

Thanks dude thats perfect!