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.
asked Dec 18 '14 at 11:57 AM in Blueprint Scripting
Asher S Einhorn
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!
Follow this question
Once you sign in you will be able to subscribe for any updates here