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

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.

主站蜘蛛池模板: 新疆| 衡阳县| 南汇区| 密山市| 芦山县| 宣化县| 东山县| 博乐市| 绥棱县| 烟台市| 九寨沟县| 建平县| 锦州市| 光山县| 丁青县| 东丽区| 万荣县| 普洱| 专栏| 沽源县| 贵南县| 防城港市| 昌宁县| 噶尔县| 忻城县| 宁乡县| 常州市| 汉川市| 全南县| 昌黎县| 罗甸县| 长宁县| 长沙县| 邢台市| 龙川县| 正蓝旗| 合阳县| 东宁县| 祁连县| 海阳市| 华阴市|