How it works...

This recipe takes all of the materials we've covered so far and compiles them all together. The ExecuteTask method will be called as long as the BehaviorTree is inside this state. This function requires us to return an EBTNodeResult, which should return Succeeded, Failed, or InProgress to let the BehaviorTree know whether we can change states or not.

In our case, we first obtain the EnemyController and the Target objects so that we can figure out who we want to move and where we want to move to. As long as those properties are valid, we can call the MoveToActor function.

There are a lot of other properties that the MoveToActor function offers that may be useful so that you can customize your movement. For more information, check out the following link: https://api.unrealengine.com/INT/API/Runtime/AIModule/AAIController/MoveToActor/index.html.
For those of you who are interested in exploring additional AI concepts with UE4, I highly suggest checking out Orfeas Eleftheriou's UE4 AI Tutorials: https://orfeasel.com/category/ue_tuts/ai-programming/.