Resetting the state

Now, this next part will allow us to use our ChaseTime Float variable in a Retriggerable Delay node. Basically, when they're in the line of sight, the Retriggerable Delay node will continue to be reset. Once we lose the line of sight, the other execution path will execute DoOnce, attempting to reset our AI's State variable. Once the Retriggerable Delay node finishes delaying by the designated Chase Time value, it will reset DoOnce, allowing our bot to reset its state. Perform the following steps:

  1. Now let's look at the Branch node we just created and pull from False and create a new DoOnce node. We can leave Start Closed as default.
  2. If we track back to True from the previous Branch node, we can pull from True then create a Sequence node.
  3. Pull from the first Then 0 exec pin and create a Retriggerable Delay node. Next, let's plug in our Chase Time variable into the Duration variable. Lastly, let's plug in Completed into the Reset input execution of the DoOnce node we created earlier:
    Resetting the state
  4. Back to the Sequence node, we need to route Then 1 to our previous Move To Actor node, as we did in State transition section.

    So, while we see our enemy, we will continue to move toward them until we lose our Enemy, in which case it will switch to the other execution line. Now, if you want the AI to move toward the positions that the enemy was located at, you would need to get the actor's location and do so. This would result in having the AI move toward the last known position of its enemy before ultimately being reset.

  5. Now, focusing on the DoOnce node, let's pull from the getAiController node we created earlier in the chain. Then, create a new node after the DoOnce node called Stop Movement. This will cancel any movement toward our enemy.
  6. Next, we need to set the Enemy Actor variable to null. We will set our State variable to 0. We will lastly call our Next Route event. Forcing the AI to return the routing between our waypoint once again, we will wait for an enemy to come in sight.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset