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:

  1. 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.
  2. 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.
  3. Let's multiply Return Value by the Get Direction Vector node results. You must first convert Int to Float. Then, multiply ...

Get Unreal Engine 4 AI Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.