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

AI Controller in Blueprint

We can create a Blueprint AI Controller by clicking on Add New | Blueprint Class | AI Controller. You will have to click All Classes and search for AI Controller to access it. You can see an example of this in the following screenshot:

For now, we will call our AI Controller BP_MyFirstAIController. Double-click on it to open the Blueprint Editor.

First, we need to create a variable so that we can store our Behavior Tree. Although it's not necessary to keep reference of the Behavior Tree, it's good practice to do so. To create a variable, we need to press the + Variable button in the My Blueprint panel, next to the Variables tab, as shown in the following screenshot (keep in mind that your cursor needs to be on the Variables tab for the button to show up):

Then, as a variable type, you need to select Behavior Tree and give it a name, such as BehaviorTreeReference. This is how what your variable should look like:

Then, in the Detail Panel, we will set the Default value (remember that to set the default value, the Blueprint needs to be compiled):

Then, we need to override the On Possess function, as shown in the following screenshot:

Finally, in the Event On Possess of the AI Controller, we need to start running/executing the Behavior Tree. We can achieve this by using the following simple node, named Run Behavior Tree:

As a result, your AI controller will be able to execute the Behavior Tree that's stored within the BehaviorTreeReference.

主站蜘蛛池模板: 广水市| 托里县| 聂荣县| 唐山市| 景谷| 睢宁县| 屯门区| 景东| 东乡| 炉霍县| 江孜县| 平凉市| 隆安县| 建德市| 常熟市| 昌吉市| 永登县| 依安县| 江油市| 上饶县| 无棣县| 奈曼旗| 赤壁市| 阳朔县| 阳春市| 巴彦淖尔市| 邮箱| 托里县| 富源县| 太仓市| 阿荣旗| 缙云县| 龙陵县| 米脂县| 内江市| 重庆市| 类乌齐县| 临夏县| 怀远县| 政和县| 哈尔滨市|