Traces

We will use this to trace from the player's location to 255 units in front of the character. If anything collides with the trace, we will face the pawn to the right based on the pawn's rotation. This simple check will be enough to make our bot run along the walls indefinitely; so, perform the following steps:

  1. Pull the Return Value pin from GetActorLocation and drop it. Then, search for Vector + Vector.
  2. We now need to select Get Controlled Pawn and pull Get Actor Forward Vector from it. This contains vector information going in the direction that is in front of our pawn.
  3. So we will multiply Return Value by 255. This is the vector we want to add to the actor's location. This results in adding 255 units in the direction ahead of the pawn's current location.
  4. Now, we need to take the results of the addition of the End pin for the LineTraceByChannel node. This will trace directly in front of our pawn:
    Traces
  5. Pull from the Vector + Vector node again, and this time we will plug it into the Dest pin for the Move to Location node. This will move the character forward indefinitely:
    Traces

    Let's try this out! Hit Simulate and look at your character move forward indefinitely! The only problem is that it can't avoid the walls just yet. We will change this by introducing a Select Vector node that chooses a different direction when a collision is detected by Line Trace:

    Traces
  6. Once more, we will pull from the Get Controlled Pawn node and search for Get Actor Right Vector.
  7. From this node, we will pull the vector and multiply it by 512.
  8. We will add this to the pawn's current location. So, similar to what we did before going forward, we will add 512 units to the right of the pawn's current location:
    Traces
  9. Right-click on the EventGraph section and search for Select Vector.
  10. From the LineTraceByChannel node, pull Return Value and connect it to the Select Vector node. Then, select A.
  11. Now, pull from the right location to A of the Select Vector node.
  12. Then, pull from the forward location to B of the Select Vector node.
  13. Select the Select Vector node and pull from Return Value into the Dest pin of Move to Location.
  14. Select the nodes and create a comment:
    Traces

Let's see how this looks in-game:

Traces

It seems to work perfectly! This will create the chase for the next addition to this project.

Reviewing the current progress

So now, we've created our Hero character, who isn't much of a hero as he runs indefinitely, but that is another story. Here is the current round of the changes:

  • We've updated the AI instructions
  • We've demonstrated a basic sensory component

Now, let's move on to creating the Enemy AI.

..................Content has been hidden....................

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