How can I tell when an AI has reached it's destination in blueprints?

I’m using a ‘move to location’ node, but is there an elegant way to query if the agent has reached it’s destination? Without calculating the path to the destination again or working out a simple distance.

1 Like

Whats Up SirYakalot,(Awesome name)

I’m Peter L. Newton, and the most elegant way I’ve found to do this is by using an Event. Now you set it up how you like but this is how I would go about it.

Setup the composite in your branch or sub-tree of this task to be a Sequence node. This way the branch waits for each node to execute successfully. Next within the task node which will execute the Move To Location, setup everything accordingly but do not link anything to the Finish Execute node. Next, pull from your AIController within the task, and assign the event Move Completed.

Now with your newly created Move Completed event, you can do one of 2 things. You can check the results of the move or just finish the execution. I suggest the former, but the latter works just as well for now. So for now just pull from the execution node of the Move Completed event, and link this to your Finish Execute and setting Success to true .

This will now prevent the bot from doing any other actions within the tree until they’ve completed the move, successfully or not. Of course I suggest using the results of the move as information to either retry the move or the appropriate action for your game.

One thing I should note that by using the Sequence composite, each node within the branch needs to have the Finish Execute set Success to true. This way the nodes in the branch execute in order, returning false would return resetting the tree.

I can show you a simple setup of this if need be! Good luck!

1 Like

haha, thanks! my dad used to call me it when I was a kid because I used to talk a lot - ‘yak’ meaning talk.

Ah that’s a really neat solution, thanks! I didn’t realize they had all these in-built events. really useful. is there a good way of getting a complete list?

BTW I watched your youtube tutorials to get me going with this stuff, so thanks a lot for those too!

You can turn Context Sensitive off when searching for events.

You can also create Event Dispatchers on one blueprint and Assign them to other blueprints allowing for what is termed in programming as a Callback . This is the what we’ve done here, and it’s efficient when the executing task requires waiting for another task to return a payload. Though we don’t have to explicitly state when that is.

Haha glad you found those, more coming today!

Hi there SilentX, I’ve actually implemented what you suggested and the event doesn’t fire. Do you know why this would be? they move to the correct location and stop but the event bound to move completed never fires. It fires if put inside the AIController with a reference to self.

26527-capture.png

assigning the event later seemed to fix it. odd though.