官术网_书友最值得收藏!

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:
  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:

    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:

  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:
  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:

Let's see how this looks in-game:

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.

主站蜘蛛池模板: 平江县| 项城市| 正宁县| 肇州县| 玛曲县| 凌源市| 徐汇区| 察雅县| 衡东县| 芒康县| 抚远县| 偃师市| 广汉市| 手游| 武平县| 浦北县| 墨玉县| 双鸭山市| 进贤县| 章丘市| 峨眉山市| 沿河| 宜兰市| 通渭县| 江安县| 元阳县| 泾阳县| 曲靖市| 射洪县| 博爱县| 额敏县| 尼木县| 临沂市| 根河市| 疏附县| 凤城市| 奉节县| 乐陵市| 新晃| 翁源县| 乌海市|