Fleeing and attacking
So, we will take from our old bit and add a small change, which will make the character run away from the Target instead of towards it. This will basically demonstrate the probability that you can give your AI reactions to various stimuli. Perform the following:
We will get our State variable. Then, we want to subtract 1 from this, getting a 0 or 1 index. Next, we want to create a Select node and plug the results of the subtraction into the node.
From there, we want Option 0 to be 1 and Option 1 to be -1. This will make the character either Run or Flee from Target. Now, zoom in to the Get Direction Vector node.
Let's multiply Return Value by the Get Direction Vector node results. You must first convert Int to Float. Then, multiply this by the vector. Then, pull the vector back into Make Rot from X:
Back to the action
Let's focus back on Enemy EventGraph at the bottom. We want to implement a way for our AI to wander. Perform the following steps:
Start by searching for Get...