Unreal Engine 5 RPG Tutorial Series - #20: AI Behavior Trees Patrolling

Gorka Games
15 Apr 202322:31

Summary

TLDR本视频教程介绍了如何在Unreal Engine 5中为角色扮演游戏(RPG)系列创建一个高级AI系统。视频从设置角色和载具树开始,然后教观众如何让敌人在场景中巡逻。接着,视频展示了如何修复装备系统中的一个小问题,即在打开装备菜单时防止攻击。随后,详细介绍了创建AI控制器和行为树的过程,包括创建一个通用的黑板(Blackboard)数据和行为树(Behavioral Tree)。此外,还展示了如何为AI设置自动巡逻的序列,并使用随机点来模拟巡逻行为。最后,视频还涉及了如何为AI添加动画,使其移动更加自然,并解决了一些常见的AI移动问题。视频以预告下一集内容结束,届时将介绍如何让AI检测玩家并开始追逐。

Takeaways

  • 🎮 开始了一个新的Unreal Engine 5教程,专注于RPG系列的高级AI系统设置。
  • 🔄 解决了装备系统中的一个小问题,确保在打开装备菜单时不能攻击。
  • 📦 创建了一个新的AI文件夹,并开始设置角色和行为树。
  • 🤖 为AI创建了一个名为BD_AI的Blackboard,用于存储AI相关的数据。
  • 🌳 使用行为树(Behavioral Trees)来定义AI的行为逻辑,如巡逻等。
  • 🚀 创建了一个AI控制器类,用于控制AI的行为。
  • 🏃 设计了一个基础的AI角色蓝图,用于实现AI的移动和行为。
  • 🛠️ 通过设置自动处理AI的选项,确保AI能够在世界中正确地生成和控制。
  • 🔄 实现了一个巡逻序列,让AI能够在场景中随机移动。
  • 🎭 为AI添加了动画,使其移动更加平滑,并且添加了停止动画。
  • 🧩 遇到了一些错误,计划在下一集中修复并进一步完善AI系统。
  • ➡️ 下一步计划为AI添加检测玩家和追逐玩家的功能。

Q & A

  • 在Unreal Engine 5中,如何开始设置高级AI系统?

    -在Unreal Engine 5中,开始设置高级AI系统首先需要创建一个名为AI的文件夹,然后设置角色和行为树。接着创建一个Blackboard,用于存储AI相关的数据,之后创建一个行为树(Behavioral Tree),并为AI创建一个专门的AI Controller类。

  • 在RPG系列教程中,如何修复装备系统在攻击时的问题?

    -为了修复装备系统在攻击时的问题,需要在装备系统的UI界面中,当打开装备菜单时,将攻击系统设置为不可攻击(can attack to false)。这样,在打开装备菜单的时候玩家将无法进行攻击。

  • 如何让AI在场景中进行巡逻?

    -为了让AI在场景中进行巡逻,需要在行为树中设置一个巡逻序列(Patrol Sequence),并在序列中添加一个任务,该任务会随机选择一个点让AI移动到那里。在到达随机点后,AI会等待几秒钟,然后再次选择另一个随机点继续巡逻。

  • 在Unreal Engine中,如何确保AI能够移动?

    -为了确保AI能够在场景中移动,需要确保场景中有一个有效的NavMesh。如果没有NavMesh或者NavMesh标记为未加载(unloaded),AI将无法计算路径和移动。可以通过保存并重新加载关卡来解决这个问题。

  • 如何让AI在移动时拥有更平滑的旋转动画?

    -为了让AI在移动时拥有更平滑的旋转动画,需要在AI的蓝图(BP_AI)中启用“Orient Rotation to Movement”选项。此外,可以通过创建一个新的动画蓝图(Animation Blueprint),并复制角色蓝图中的移动相关动画状态机来实现。

  • 在设置AI巡逻行为时,如何确定AI停止的距离?

    -在设置AI巡逻行为时,可以通过在行为树的任务中设置一个名为“Acceptance Radius”(接受半径)的变量来确定AI停止的距离。这个值定义了AI在接近目的地时应该停止的具体距离。

  • 在Unreal Engine 5中,如何为AI添加攻击能力?

    -在Unreal Engine 5中,为AI添加攻击能力需要在AI的行为树中添加相应的任务和条件。此外,还需要确保AI控制器与攻击系统相关联,并且在AI的蓝图中设置适当的逻辑来处理攻击行为。

  • 在RPG系列教程中,如何解决装备武器时的动画展示问题?

    -为了解决装备武器时的动画展示问题,需要在装备系统的UI界面中添加逻辑,以便在装备武器时触发相应的动画。这通常涉及到在装备系统的蓝图中编写脚本来控制动画的播放。

  • 如何调整AI的巡逻半径和停止距离?

    -AI的巡逻半径和停止距离可以通过在行为树中的任务设置中找到对应的变量进行调整。巡逻半径决定了AI选择巡逻点的范围,而停止距离决定了AI在接近目的地时停止的具体位置。

  • 在Unreal Engine 5中,如何创建一个新的行为树?

    -在Unreal Engine 5中,创建一个新的行为树可以通过在内容浏览器中右键点击并选择“Artificial Intelligence” -> “Behavioral Tree”来完成。创建后,可以为其分配一个Blackboard以便存储和使用AI的数据。

  • 如何确保AI在场景中的导航是有效的?

    -为了确保AI在场景中的导航是有效的,需要在场景中创建并使用NavMesh。NavMesh是AI导航的基础,它允许AI计算并找到移动到不同位置的路径。如果NavMesh未正确设置或未加载,AI将无法导航。

  • 在RPG系列教程中,AI的行为树是如何控制AI行为的?

    -在RPG系列教程中,AI的行为树通过一系列节点和任务来控制AI的行为。行为树从上到下、从左到右执行,使用选择器(Selector)和序列(Sequence)节点来决定执行哪些任务。每个任务可以包含特定的行为,如巡逻、攻击等。

Outlines

00:00

🎮 Unreal Engine 5 RPG系列教程:AI系统与装备系统优化

本段落介绍了Unreal Engine 5 RPG系列教程的继续,重点在于设置高级AI系统,包括角色和载具树的构建,以及敌人在场景中的巡逻行为。同时,还解决了前一集中遗留的装备系统问题,确保装备武器时能够正常攻击,并对装备界面进行了改进,使其在打开时无法攻击,关闭后恢复攻击能力。

05:03

🤖 创建AI控制器和行为树:基础设定与行为逻辑

详细说明了如何创建AI控制器和行为树,首先创建了一个名为BD_AI的Blackboard数据,然后创建了名为BT_AI的行为树。接着,创建了一个AI控制器类,并为其分配了刚创建的行为树。此外,还设置了AI的自动处理方式,并开始设置AI的基类蓝图,包括为AI敌人选择正确的AI控制器。

10:03

🚶‍♂️ AI巡逻行为的实现:随机点移动与等待

本段讲述了如何实现AI的巡逻行为。首先创建了一个名为Patrol Sequence的序列,然后在任务文件夹中创建了一个新的任务BT_Task_PatrolRandomPoint,该任务使AI能够在一定半径内随机选择点进行移动。同时,设置了AI到达随机点后等待两秒的逻辑。此外,还强调了在场景中添加NavMesh的重要性,因为AI的路径计算依赖于此。

15:04

🕹️ AI动画与移动优化:平滑旋转与动画播放

为了提升AI的移动体验,本段介绍了如何为AI添加动画并优化其移动和旋转。通过修改BP_AI蓝图中的设置,使得AI能够平滑地旋转,而不是生硬地停止。此外,还创建了一个新的动画蓝图ABP_AI,并将其应用到AI上,以确保AI能够在移动时播放动画。最后,解决了AI不播放动画的问题,通过检查和重新加载NavMesh来确保AI的移动和动画能够正常工作。

20:04

🔄 AI系统调试与未来规划:当前问题与后续教程预告

在本段中,提到了AI在移动时可能出现的一些问题,例如AI移动速度的调整和动画的平滑性。同时,作者预告了下一集的内容,将会继续AI系统的构建,包括让AI能够通过视觉检测玩家并开始追逐。最后,鼓励观众如果视频有帮助可以点赞和订阅频道,并在评论区或视频描述中提出问题或分享进度。

Mindmap

Keywords

💡Unreal Engine 5

Unreal Engine 5是一款由Epic Games开发的游戏引擎,广泛用于创建和开发3D视频游戏。在视频中,它被用作制作RPG(角色扮演游戏)系列教程的平台,展示了如何利用这个引擎开发高级AI系统。

💡RPG系列

RPG是角色扮演游戏的缩写,这是一种游戏类型,玩家在虚拟世界中扮演一个或多个角色,并在游戏世界中进行探索、战斗和完成任务。视频中的RPG系列教程专注于使用Unreal Engine 5开发RPG游戏的进阶技术。

💡AI系统

AI系统指的是游戏中的人工智能,它控制着非玩家角色(NPC)的行为。在视频中,AI系统用于创建能够巡逻和响应玩家行为的敌人,是游戏互动性的核心部分。

💡行为树(Behavioral Trees)

行为树是Unreal Engine中用于定义AI行为的一种工具,它通过树状结构组织AI的行为逻辑。视频中,行为树被用来设置AI的巡逻行为,是AI决策过程的基础。

💡黑板(Blackboard)

黑板在Unreal Engine的AI系统中用作数据存储,可以保存AI使用的各种变量和数据。视频中创建了一个名为BD_AI的黑板,用于存储和管理AI相关的数据。

💡AI控制器(AI Controller)

AI控制器是Unreal Engine中用于控制AI行为的蓝图类。视频中创建了一个名为BP_AI_Controller_Generic的AI控制器,用于管理AI的行为树和行为。

💡巡逻(Patrol)

巡逻是AI敌人在游戏世界中按照特定路径或区域进行的循环移动。视频中通过创建一个巡逻序列,让AI在场景中随机选择点进行移动,模拟巡逻行为。

💡导航网格(Navmesh)

导航网格是Unreal Engine中用于AI路径规划的一种数据结构,它定义了AI可以行走的区域。视频中提到了确保场景中有Navmesh,以便AI能够计算出移动路径。

💡动画蓝图(Animation Blueprint)

动画蓝图是Unreal Engine中用于创建和控制角色动画的一种工具。视频中创建了一个新的动画蓝图,用于给AI敌人添加动画,使其动作更加自然和流畅。

💡状态机(State Machine)

状态机是一种计算模型,用于在有限的状态集合中根据输入进行状态转换。在视频中,状态机被用于控制AI的移动和行为,如巡逻、等待和响应玩家的攻击。

💡角色移动组件(Character Movement Component)

角色移动组件是Unreal Engine中用于控制角色移动和物理交互的组件。视频中通过修改该组件的设置,实现了AI敌人的平滑旋转和动画同步。

Highlights

开始新的Unreal Engine 5教程,继续RPG系列,将开始设置高级AI系统

设置角色和载具树,让敌人能够在场景中巡逻

解决装备系统中的遗留问题,确保装备武器时能够攻击

创建AI文件夹并开始设置角色和行为树

创建Blackboard数据,用于存储AI相关的数据

创建行为树(BT),并确保Blackboard数据被分配

创建AI控制器类,用于控制AI的行为

设置AI控制器以运行行为树

创建AI角色蓝图,基于已有的Dummy蓝图进行修改

设置AI角色的自动处理方式,确保能够正确地生成和控制AI

在行为树中创建巡逻序列,让AI能够在随机点之间巡逻

创建任务蓝图,实现AI巡逻到随机点的功能

设置AI巡逻的半径和停止距离,调整巡逻行为

确保场景中有NavMesh,以便AI能够计算路径

调整AI的旋转设置,使其能够平滑旋转而非瞬间转动

创建新的动画蓝图,为AI添加动画以使其动作更加自然

解决AI不移动的问题,通过重新加载关卡来恢复NavMesh

调整AI的速度设置,确保动画和移动同步

教程结束时,AI已经能够进行基本的巡逻和动画播放

Transcripts

play00:00

what's up guys welcome to a new Unreal

play00:02

Engine 5 tutorial and today we are

play00:04

continuing with the RPG series it will

play00:06

finally begin with the advanced AI

play00:08

system it will basically start to set up

play00:10

the character and the vehicle trees and

play00:12

we'll set up that the enemy will be able

play00:14

to patrol around our scene it's going to

play00:17

be a very easy route to follow so let's

play00:19

get started

play00:22

alright so right before we start with

play00:24

the AI I just want to do something that

play00:26

I just got left over from the last

play00:27

episode and is that if you can open the

play00:31

equipment system you can basically if

play00:33

you click you will attack I just want to

play00:34

quickly solve that and also add up when

play00:37

you equip a weapon let me just quickly

play00:38

showcase that go here equip a weapon it

play00:42

will be in range because of rainbow when

play00:44

I selected the menu listen close so I

play00:46

just want to also do the real quick so

play00:49

quickly let's go into the equipment

play00:50

system and open up the BBC equipment

play00:52

system here and then we're going to do

play00:54

is go into the equipment menu panel and

play00:57

when we go ahead and open up the panel

play01:00

so in here is panel opened at true what

play01:03

we are going to do is basically get the

play01:07

if we go on to blueprints we already

play01:09

control this in the attack system and

play01:11

instead can attack to false so we will

play01:14

not be able to attack so let me quickly

play01:16

go and in the Start begin play get a

play01:18

reference into the

play01:20

um attack system and BBC it's right

play01:23

click promote to variable

play01:25

and then put it in here uh go back here

play01:28

get this VPC attack system when I get it

play01:32

and I'm gonna go ahead and set can

play01:34

attack in this case it will be false and

play01:39

copy and paste this and in this case it

play01:41

will be back through because we have

play01:43

basically closed the panel and let's

play01:45

plug in the attack system back here

play01:47

let's put the comment here and this here

play01:50

so great now we should not be able to

play01:51

attack when we open the this but when we

play01:54

close it we're back able to attack great

play01:56

that's working and then I just weekly

play01:59

one to go

play02:01

into the equipment system and go into UI

play02:04

and I'm going to go into the uh W item

play02:07

slot okay and basically we're gonna go

play02:09

into the graph and when we click the

play02:11

button when I assign this a lot and

play02:13

stuff and we're going to do also is get

play02:15

the equipment a widget and then I get

play02:19

the item list and box

play02:23

actually there's a canvas panel maybe

play02:26

that would work let me quickly open this

play02:28

up go into graph uh sorry designer so we

play02:32

have the scale box and list canvas panel

play02:36

which has the background and this

play02:37

particle and probably that's what we

play02:39

want to

play02:41

um to take off I believe because when we

play02:44

yeah let's get my spanner we set the

play02:46

visibility so I'm gonna copy this go by

play02:48

here paste it put it here and then uh

play02:53

well we have to get it from here so get

play02:54

a list canvas panel and plug in and

play02:58

Target

play02:59

delete this one so we want to just

play03:00

hidden it so now

play03:03

let's quickly test that real quick and

play03:04

we can move on to AI open this go to

play03:07

Range one bow once selected it's out and

play03:10

we can open again of course great so

play03:12

that's it sorted out and that was you

play03:15

know little things that I wanted to

play03:16

finish up but now great if we can move

play03:18

on let's begin with the AI system so

play03:20

let's go ahead and start creating a

play03:22

folder so let me right click new folder

play03:24

and just call this Ai and let's open

play03:27

this up so let's begin by setting up a

play03:29

bit of the character and the behavioral

play03:31

trees and so on so the first thing I

play03:34

want to do is go and right click I'm

play03:36

going to go into artificial intelligence

play03:38

and the first thing is going to be a

play03:39

Blackboard now you'll see what a

play03:41

Blackboard will be

play03:42

in a second but basically let's change

play03:45

the name into BD for Blackboard data and

play03:49

we're going to make it something generic

play03:51

for now okay because we'll have

play03:53

different

play03:54

um uh AI Styles okay well we have a

play03:57

three wheel in the future so we'll have

play03:59

basically as you know we're based on

play04:02

this series in Assassin's Creed Origins

play04:05

so we'll have him basically soldiers

play04:07

that will be patrolling when you see you

play04:09

attack you different bosses maybe

play04:11

civilians and so on so in this case it's

play04:14

going to be something general generic

play04:16

and then later on we'll have this as a

play04:18

parent and then children and we'll have

play04:19

variation so on if you get the idea

play04:23

um so for now I'm just gonna go ahead

play04:24

ahead and put this as BD underscore AI

play04:28

and now that we have the Blackboard

play04:29

created we're going to do this right

play04:30

click go into artificial intelligence

play04:33

and create the behavioral trees and we

play04:35

hold three in single so now it's going

play04:38

to be BT underscore and again it will

play04:40

but uh just be AI so let's go ahead and

play04:42

quickly save this and open this up and

play04:46

you will see that we have the behavior 3

play04:48

here now I do have

play04:50

um a tutorials where I cover behavioral

play04:52

trees in really detail or in depth so I

play04:54

want to check them out go ahead but

play04:57

basically we just have to make sure that

play04:59

if we open up here this uh tack board

play05:02

that we just created is assigned so just

play05:04

make sure that we have BD underscore AI

play05:07

assigned into the we have three great so

play05:09

now we can close this and now we have to

play05:11

create a new thing so let's go into

play05:12

blueprint class and search for AI

play05:15

controller and what to do is create an

play05:17

AI controller basically this one you

play05:20

selected it's going to be b b underscore

play05:22

a i a controller

play05:26

and we're gonna make another score and

play05:29

then just put generic

play05:31

dinner Rick there we go so we like the

play05:34

general one uh so now what we want to do

play05:36

is open up this AI controller and what

play05:40

we want to do is in the bank graph we

play05:43

can delete the event tick and in the

play05:45

begin play what we can do is basically

play05:47

run a behavior 3. in this case what we

play05:51

want to do is run that behavioral tree

play05:53

that we have just created so now we can

play05:56

save a compound and close so now what

play06:00

we'll have to do is to create the actual

play06:02

character a blueprint itself

play06:05

so what I'm going to do is actually get

play06:08

a base from our dummy which we already

play06:11

have a lot of things set up so we can do

play06:13

is just go ahead and duplicate it and

play06:14

start changing things so let's go into

play06:16

Blueprints and we have here the dummy so

play06:19

we're going to do is drag it into the AI

play06:21

folder and then when this panel appears

play06:24

we're going to say copy here and then in

play06:26

here we're going to do is change the

play06:28

name into BP underscore and again gonna

play06:31

make it generic so it's gonna be just a

play06:34

i

play06:35

and now let's open this one over here

play06:37

now in this case this one doesn't move

play06:40

whatsoever right it just has the black

play06:42

doors headed up the radius for the

play06:45

um stealth assassination uh yes Health

play06:48

again and so on right uh in the

play06:52

basically health bar and these things

play06:54

that we you know with time with it in

play06:56

the series so we want to do now is set

play06:58

up the AI on here so we'll need to do is

play07:00

go into class defaults and search for AI

play07:03

and then you will see that we go a bit

play07:05

down we'll see pawn and then AI

play07:07

controller clasp and here we want to

play07:10

sign the one that we have just created

play07:11

which is BP AI controller underscore

play07:13

generic let's place it another thing

play07:16

that I always like to do in my app is

play07:18

for my AI enemies or whatever

play07:20

is go into autoprocess Ai and change it

play07:23

from place in both to place in world or

play07:26

spawned the thing is that if later on

play07:28

for some reason with spawn our enemies

play07:30

you'll see that they don't move and be

play07:32

like what is going on is the behavior

play07:34

through broken what is going on and

play07:36

really it's just that it is not

play07:37

possessing the AI because of this simple

play07:39

drop down because we have had to say

play07:41

that it will be able to be spawn world

play07:44

or spawned you get the idea anyway so of

play07:48

course right now if we drag it in which

play07:50

will be this one and of course nothing

play07:52

will happen

play07:53

right I explain nothing will happen and

play07:56

it's because

play07:57

in our behavioral tree we don't have

play07:58

anything so let's begin by actually

play08:01

doing something in the vehicle tree

play08:02

let's go ahead and open this up so

play08:06

um as I mentioned before I do have a you

play08:08

know in-depth tutorial on AI but

play08:10

basically the behavioral truth will work

play08:11

from top to bottom left to right so

play08:14

we'll have different sequences over here

play08:16

different tasks it will work from top to

play08:18

bottom left to right so the first thing

play08:20

I want to do is have a selector a

play08:23

selector will be able to choose between

play08:25

different

play08:26

um

play08:26

well you know what we're going to say

play08:29

tasks or compasses and basically be

play08:32

depending on their values and we'll be

play08:35

adding the conditions with the creators

play08:38

that will be seeing them in the next

play08:40

episode

play08:41

um but basically what we want to do now

play08:43

is go ahead and make a sequence so a

play08:46

sequence we'll go ahead and run

play08:47

different tasks from left to right as

play08:49

mentioned before and if there's an error

play08:52

in any of the sequence it will basically

play08:54

fail the whole sequence and move on into

play08:56

the selector and do this the next

play08:58

sequence or whatever it has okay so the

play09:01

first sequence over here will be is

play09:03

Patrol

play09:05

so let's go ahead and call this Patrol

play09:07

sequence so we already have everything

play09:09

good named and things like that and uh

play09:13

so yeah let's just begin with Patrol

play09:14

sequence so the first thing I want to do

play09:16

is go ahead and create a new task so for

play09:20

do this we can just go up here into new

play09:22

task and then it will open up our AI

play09:24

folder so in my case I'm going to right

play09:26

click every new folder and call this

play09:28

tasks basically so everything is go

play09:31

ahead and organize because we'll have

play09:33

basically different tasks in the future

play09:35

now inside the tasks we're going to have

play09:37

this which will be called

play09:39

um BT

play09:41

underscore task and then underscore and

play09:45

this will be basically Patrol random

play09:49

point

play09:50

Patrol random points that's pretty good

play09:52

name you save it and then we'll have a

play09:54

new uh basically blueprint over here so

play09:57

this will basically be like any other

play09:59

normal blueprint but of course it has

play10:00

its own things so the first thing that

play10:03

we have to do is go into functions and

play10:05

if we say all right we can have

play10:06

different functions over here and the

play10:08

first one that we want is receive

play10:10

execute AI this is pretty much the

play10:12

gameplay of the task but the test is

play10:15

gone ahead and execute it this will be

play10:18

the first Nar so in our case what we

play10:20

want to do is just get a random position

play10:22

around a radius of our enemy and just

play10:25

move into that place for our patrolling

play10:27

and later on in the series if you want

play10:29

we can get more in depth and basically

play10:31

do a spline you know with a certain path

play10:34

and so on but for now we're gonna make

play10:36

it more Dynamic for us and instead

play10:37

randomly you speak a random point and go

play10:40

into it and hey it will be easier for us

play10:42

and also uh I guess more Dynamic you

play10:45

know so the first thing I want to do is

play10:47

just get this and say move to and

play10:51

obviously though we have the AI move to

play10:52

node so basically these will just move

play10:55

the AI into a certain destination or

play10:58

actor in this case it will be a

play11:00

destination so in control Palm I'm going

play11:02

to put this into pump because that's the

play11:03

pump they're going to be controlling and

play11:06

uh

play11:07

yes plug it in and then we want to do is

play11:10

go ahead and get the destination and do

play11:12

a random point

play11:15

if I know how to type random point

play11:19

in reachable radius so this will

play11:22

basically speak up a random point in the

play11:25

math mesh so the the origin will be

play11:28

basically what the first uh basically

play11:30

the pivot of the radius will be in our

play11:33

case it will be in the AI so we can just

play11:35

get the control bound get actor location

play11:38

and then just plug that in into the

play11:40

origin now the radius is how far away we

play11:43

want to be able to well the enemy wants

play11:45

to be able to pick a random point in our

play11:48

case let's go ahead and just put this

play11:50

into variable so

play11:52

yeah we can change it dynamically later

play11:54

on from the vehicle 3 instead and you

play11:56

select it compile it and then when you

play11:59

spot a random well sorry the random note

play12:01

but at a default value of let's say

play12:03

three thousand right let's say that it

play12:05

will be well two thousand and it will be

play12:07

able to go at 2000 and then another

play12:10

thing I'm going to do is click this icon

play12:11

over here the I so it will be public so

play12:15

later on from the uh Behavior we'll be

play12:18

able to edit it if not it will not

play12:19

appear and we cannot change it so that's

play12:22

the number we want to do and then on

play12:23

here again in the acceptance radius is

play12:27

promote this to a variable and this will

play12:29

be the um

play12:30

the close

play12:32

well this top radius but actually

play12:35

instead of Raiders I like to call this

play12:37

distance because really this is the stop

play12:39

distance this is basically where the AI

play12:41

will stop again click the I to open up

play12:44

compile and the stop distance let's make

play12:46

it 120 because normally it does get

play12:49

tuned to close for the destination I

play12:51

don't like that and now in success what

play12:53

we need to do is if you see here we will

play12:56

not have anything here but we have uh uh

play13:00

we'll say finalize and finish execute so

play13:03

in success we'll plug this in here and

play13:06

take success but let's go ahead and copy

play13:08

and paste and unfail put this here and

play13:11

untick success and we will not do

play13:13

anything in the continuation but only if

play13:16

it has reached a point or has failed in

play13:20

the beginning of a point right yeah so

play13:22

we need this note in order to be able to

play13:24

you know finish this the task and go

play13:27

into the next one so let's go ahead and

play13:29

use compile save and we can actually

play13:31

close this now from our Patrol sequence

play13:34

you can get this test in our case OBD

play13:36

petrol random Point great and now you

play13:39

will see that we have the values here as

play13:41

we click them with the I icon we can now

play13:44

edit them anyway so once we have reached

play13:47

a random destination I want right after

play13:49

we have got it to that point and

play13:52

basically wait a few seconds so we have

play13:54

already a node called weight and we can

play13:57

wait for example two seconds

play13:58

these values are right now temporarily

play14:01

you can customize it as we go as you

play14:04

want your soldiers to wait more time or

play14:07

something like that so we'll be seeing

play14:08

right

play14:10

um and that's pretty much what we need

play14:12

you know to basically pretty much Start

play14:14

uh going ahead and experimenting with

play14:16

our AI so I'm really what we can do now

play14:19

is just make sure that we have nap mesh

play14:21

in the scene and I believe we then add

play14:23

one in the series because our dummy

play14:25

didn't move so just go up here and

play14:26

quickly add to the part and we'll go

play14:28

into volumes and you will see this map

play14:30

bounce volume so this will be basically

play14:33

an area so we want to do is go ahead and

play14:35

put this into the center

play14:38

which actually let's just put it in the

play14:40

center of the scene kind of it doesn't

play14:42

need to be exact but now with the scale

play14:44

and the locked on let's put this for

play14:46

example 50 so we'll fill up the whole

play14:48

area and now if I press P you will see

play14:51

that it will basically calculate all the

play14:53

possible path scenarios that the AI will

play14:57

be able to go so this is very important

play14:59

if you don't have a nap mesh bounce in

play15:01

the scene it will not work the area will

play15:04

not able to move around because this is

play15:05

how what a Unreal Engine uses to

play15:07

calculate all the paths and so on uh so

play15:10

with that said and we can now press play

play15:12

and there we go the AI is now going

play15:14

ahead and moving pick a random point and

play15:17

then stopping for two seconds and then

play15:19

picking a random point and going and

play15:21

going again

play15:23

great so everything is going ahead and

play15:25

working so I think I want to do is of

play15:27

course add the animations and make his

play15:30

rotation a bit smoother because right

play15:32

now it just stops instantly or tastes

play15:35

like if it's a robot then confused and

play15:37

like that so let's go into the bpai

play15:40

blueprint and we're gonna go into the

play15:42

class defos and you search for jaw and

play15:45

then you will see that this is enabled

play15:47

this is go ahead and deselect this and

play15:49

let's go into the character movement

play15:51

component go down and you'll see this

play15:53

which is the rotation settings and what

play15:56

we want to do is just enable and Orient

play15:59

rotation to movement so basically the AI

play16:02

will be able to rotate smoothly with

play16:05

this rate that is right now applied on

play16:07

the side into that rotation and it will

play16:09

not be instantly like a rubber turn you

play16:12

know and it will just feel much better

play16:14

now let's go ahead and add some

play16:16

animations into this AI

play16:18

because right now it doesn't really move

play16:21

it now I believe that we cannot add

play16:23

directly our uh you know uh animation

play16:27

blueprint that we did but let me just

play16:30

check anyway and see because we are

play16:32

casting into a character and we are you

play16:36

know getting some things from a

play16:37

character and the character is actually

play16:40

third person reference and it will

play16:43

really you know break other stuff over

play16:45

here so we cannot directly use this

play16:48

character even though just the same

play16:50

skeleton sorry this blueprint so we will

play16:52

need to create a new animation blueprint

play16:54

even though it is temporary and maybe we

play16:56

will be able to use this when the filter

play16:58

but for now uh we'll just create a new

play17:01

um

play17:02

animation blueprint so let's go into AI

play17:05

let's right click animation blueprint

play17:07

select the SK mannequin let's say create

play17:11

ABP underscore Ai and let's go ahead and

play17:14

open this guy up and then this will be

play17:17

gonna be simple uh we're gonna get our

play17:20

blend space which is welcome run now the

play17:23

thing is that on here uh basically as

play17:26

you can see if I what did I close the

play17:28

other one we open this up

play17:30

uh we have different state machines so

play17:33

if we go into the NM graph you will see

play17:35

that we have the main then we have

play17:37

Locomotion and so on and Locomotion for

play17:39

example we have the idle walk run all

play17:42

these things going on

play17:44

and the velocity and speed is higher in

play17:46

terms of that so I do believe that we

play17:48

can select all of this actually copy and

play17:51

paste it

play17:52

um so let's go ahead and do so let's get

play17:53

The Locomotion stand machine Ctrl C go

play17:56

into the other one and then just paste

play17:59

it

play18:00

and there we go we have it here and

play18:03

there we go we have everything now it

play18:05

did not create the variable and we have

play18:07

speed but it's not created so just right

play18:10

click and create variable speed and

play18:12

compile and that should be it so

play18:14

actually that should be working we can

play18:16

schedule motion plugin in now first of

play18:18

all I just want to add the default slot

play18:19

just in case like I mentioned before in

play18:21

this series we want to play an anime

play18:23

into animation Montage like attacking is

play18:26

already set up so now compile uh we do

play18:29

have an error which is your Delta so

play18:31

just right click and create variable

play18:33

so we'll create it now the lean will not

play18:36

be set up right now for this episode but

play18:39

yeah you know with time will do so so

play18:41

that should work um if we're now going

play18:43

to the bpai and go into the uh the mesh

play18:47

itself we can now go up into the NM

play18:50

class and put the BP Ai and here you

play18:53

should be able to move with animations

play18:55

and he still

play18:57

and he doesn't move so why isn't he

play19:00

moving well uh actually I have no idea

play19:04

honestly

play19:06

um oh there we go so this might happen a

play19:09

lot to you

play19:10

so for some reason the AI just doesn't

play19:13

move and you have no idea what is

play19:15

happening the first thing that you

play19:17

should do is go into your scene outliner

play19:19

go down and see the nap mesh and if it

play19:23

says unloaded all you have to do just go

play19:25

ahead and save gunship as everything if

play19:27

you go to recent levels and open up the

play19:29

map again and you will see that now the

play19:32

the enough match will be back here so

play19:35

for some reason I'm real engine

play19:38

breaks down and it goes ahead and

play19:40

disables the nutmeg I don't know why but

play19:42

it just does that so make sure that you

play19:45

reload the level if it doesn't move the

play19:47

the AI just doesn't work okay quick note

play19:49

here anyway so now

play19:51

it doesn't move with the animations as

play19:53

you can see

play19:55

um so this is probably because we

play19:57

haven't set up the speed of course so

play19:58

let's go into the then graph oh

play20:01

of course this is from the RPG character

play20:02

but we can pretty much copy the same

play20:04

stuff so booking is pretty much get uh

play20:07

all the notes just get this get this and

play20:10

get this

play20:10

Ctrl C go into the other AI then graph

play20:15

paste it and then plug this in in here

play20:19

put this here and we can just get this

play20:21

one out

play20:23

and then

play20:24

um we can just delete the velocity we

play20:26

actually don't need it compile and say

play20:28

and now yes you will see that he will

play20:31

move there we go with his proper

play20:32

animations and stop and he will taste

play20:35

much smoother than before and of course

play20:37

we can even make the animations a bit

play20:39

smoother but you get the idea and even

play20:41

he has the stop animation too because we

play20:43

best copied from a character and

play20:45

everything is gonna end up working and

play20:48

if I were to also

play20:50

hit him I should be able to damage him

play20:52

now it might be a bit hard because he

play20:55

will be constantly moving and stuff but

play20:57

also I should be able to tight luck into

play20:58

it so I don't know where he went now

play21:01

where do you go it's in here okay wow

play21:04

you're moving so fast man uh explain him

play21:06

okay tap yes

play21:09

basically gone ahead and finding his

play21:11

area

play21:12

so now I can yes I can go ahead and

play21:14

attack him but of course he's always

play21:15

moving

play21:17

at okay can you stand still for a second

play21:20

okay

play21:26

of course and okay we do have some some

play21:30

errors don't worry about that we'll go

play21:32

ahead and fix them in the next episode

play21:33

but we have the EA already working and

play21:35

someone of course fully combat we have

play21:37

to tune in other things that of course

play21:39

he will not just run away you know and

play21:42

so on

play21:43

uh but that's it guys if you found so

play21:45

helpful I would really appreciate you

play21:46

like the video and subscribe to my

play21:47

channel I have lots of Unreal Engine

play21:49

Parts so go ahead and check them out

play21:51

join my description service you can put

play21:52

any questions that you have or you know

play21:54

share your progress with the series or

play21:56

with any games that you have and also

play21:58

from you know my socials as tutor and

play22:00

Instagram so in the next episode we'll

play22:02

go ahead and continue with the AI system

play22:04

we'll make sure that he can detect you

play22:07

with some Pawn sets and stuff uh for now

play22:09

it will be only for vision and then and

play22:12

it will be starting to chase you okay uh

play22:15

so with that said you know if you have

play22:17

any question go ahead and drop it in the

play22:18

comments or in the description and now

play22:21

yes we thought I said like the video

play22:22

subscribe and bye bye

play22:27

foreign

play22:29

[Music]

Rate This

5.0 / 5 (0 votes)

Do you need a summary in English?