- Unreal Engine 4 AI Programming Essentials
- Peter L. Newton Jie Feng
- 466字
- 2021-07-16 12:48:40
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:
- Pull the Return Value pin from GetActorLocation and drop it. Then, search for Vector + Vector.
- 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.
- 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.
- 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:
- 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:
- Once more, we will pull from the Get Controlled Pawn node and search for Get Actor Right Vector.
- From this node, we will pull the vector and multiply it by 512.
- 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:
- Right-click on the EventGraph section and search for Select Vector.
- From the LineTraceByChannel node, pull Return Value and connect it to the Select Vector node. Then, select A.
- Now, pull from the right location to A of the Select Vector node.
- Then, pull from the forward location to B of the Select Vector node.
- Select the Select Vector node and pull from Return Value into the Dest pin of Move to Location.
- 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.
- Aftershot Pro:Non-destructive photo editing and management
- Intel FPGA/CPLD設計(基礎篇)
- 極簡Spring Cloud實戰
- 計算機組裝與系統配置
- 基于ARM的嵌入式系統和物聯網開發
- Hands-On Artificial Intelligence for Banking
- 微型計算機系統原理及應用:國產龍芯處理器的軟件和硬件集成(基礎篇)
- STM32自學筆記
- IP網絡視頻傳輸:技術、標準和應用
- 計算機組裝與維護(慕課版)
- 筆記本電腦維修技能實訓
- 微服務實戰
- Advanced Machine Learning with R
- 多媒體應用技術(第2版)
- 快·易·通:2天學會電腦組裝·系統安裝·日常維護與故障排除