State machines
Traditionally, we would default to the AI Behavior Tree, which is available to anyone using UE4. However, in our scenario, we will break the job of Behavior Tree into components directly written in blueprint. So, the next thing we need to create is a way to maintain a state. Then, we can essentially create a state machine by updating the variable, allowing our AI to transition into different states by controlling the execution flow.
We will establish this using an event that will update our state when the conditions we specify are met. To start this off, let's continue to the next step!
First, let's create a new Int variable in our AIController called State. This will maintain our current state within our state machine.
We now need a new event, and we will call it NextRoute. So, upon right-clicking on the event graph and going under Add Event, we will notice Add New Event. Let's name this new event
NextRoute
.Now, after our assigned event ReceiveMoveCompleted, we should call NextRoute...