Unreal Engine 5 RPG Tutorial Series - #12: Target Lock and Dodge Roll

Gorka Games
10 Mar 202331:44

Summary

TLDR在这段视频脚本中,制作者带领观众继续深入角色扮演游戏(RPG)系列的教程。首先,他们解决了玩家在下蹲时胶囊碰撞体不缩小的问题,通过调整第三人称蓝图中的胶囊组件的高度值,实现了更自然的下蹲动作。接着,通过启用摄像机滞后功能,改善了摄像机移动的平滑性,减少了“咔嚓”声。此外,制作者还介绍了如何设置目标锁定系统,使用户能够在战斗中锁定敌人,以及如何实现躲避动作,增加了游戏的动态性和战斗的流畅性。最后,他们还讨论了如何通过输入动作和动画蒙太奇来实现躲避输入,并确保在攻击过程中不能执行躲避动作。整个教程内容丰富,步骤详细,对于希望在Unreal Engine 5中创建RPG游戏的开发者来说,是一份宝贵的学习资源。

Takeaways

  • 📺 在RPG系列教程中,将设置教程锁定系统,以便在战斗中锁定敌人,减少玩家的担忧。
  • 🔄 将设置一个翻滚系统,允许玩家向左右翻滚来躲避敌人。
  • 🛡️ 通过调整胶囊碰撞器的高度,实现角色蹲下时碰撞体积的缩小。
  • 🔩 利用事件图和胶囊组件,调整角色蹲下时的碰撞高度,以避免穿模问题。
  • 📏 通过设置胶囊组件的半高度,实现角色蹲下时的碰撞体积变化。
  • 🤸‍♂️ 创建了一个翻滚动画,并导入到RPG角色中,通过动画蒙太奇实现翻滚效果。
  • 🎯 实现了目标锁定功能,使用球体追踪来检测前方的敌人,并锁定视角。
  • 🔄 通过时间轴和插值函数,平滑地过渡胶囊高度和网格偏移,以改善蹲下和翻滚的动画效果。
  • ➡️ 使用输入动作和集合来绑定目标锁定和翻滚的新按键输入。
  • 🚫 通过检测是否正在攻击来阻止在攻击过程中执行翻滚动作。
  • 🔄 对于目标锁定,实现了锁定和解锁的逻辑,允许玩家在锁定敌人后取消锁定。

Q & A

  • 在视频中提到的RPG系列教程是关于什么的?

    -视频中的RPG系列教程是关于如何在游戏开发中设置角色的教程锁定系统和翻滚系统,以便在战斗中锁定敌人并进行躲避操作。

  • 为什么在角色蹲下时胶囊碰撞体会出现问题?

    -当角色蹲下时,胶囊碰撞体的高度没有相应减小,导致角色模型与地面发生穿透,这是因为胶囊组件的高度没有根据角色的蹲下动作进行调整。

  • 如何调整胶囊碰撞体以适应角色的蹲下动作?

    -通过在第三人称蓝图中调整胶囊组件的高度值,当角色开始蹲下时减小高度,当角色站立时恢复到原始高度。

  • 为什么角色在蹲下时会感觉动作很突然(Snappy)?

    -这是因为胶囊高度的立即改变导致的,可以通过启用相机滞后(Camera Lag)和调整相关参数来使相机移动更加平滑。

  • 如何实现目标锁定功能?

    -通过在第三人称输入动作中创建一个新的输入动作,使用球体追踪(Sphere Trace)来检测前方的敌人,并在检测到带有'damageable'标签的敌人时锁定目标。

  • 如何取消目标锁定?

    -在目标锁定的逻辑中添加一个条件检查,如果目标锁定变量为空,则取消锁定,允许玩家自由控制相机。

  • 视频中提到的翻滚动画是如何实现的?

    -通过导入特定的翻滚动画资源,并在第三人称角色蓝图中创建一个新的输入动作来触发这个动画,同时确保在动画播放期间不能进行攻击。

  • 如何避免在攻击过程中执行翻滚动作?

    -通过检查攻击系统组件的'is attacking'属性,如果角色正在攻击,则不允许执行翻滚动作。

  • 为什么需要设置一个'not dodging'的变量?

    -为了避免角色在执行翻滚动作的过程中再次进入翻滚状态,需要一个标志变量来表示角色当前是否正在翻滚。

  • 如何使翻滚动画的过渡更加平滑?

    -通过在动画蒙太奇(Animation Montage)的Blend Out设置中使用Cubic曲线,并调整Blend Out时间来实现更平滑的过渡效果。

  • 为什么有时目标锁定会失效?

    -可能是因为追踪通道(Trace Channel)设置不正确,改为使用'Physics Body'而不是'Visibility'可以提高检测的准确性。

Outlines

00:00

😀 角色蹲伏与摄像机锁定系统设置

本段介绍了如何在RPG系列教程中设置摄像机锁定系统和翻滚躲避机制。首先,通过调整胶囊碰撞体的高度来实现角色蹲伏效果,解决了蹲伏时胶囊碰撞体不缩小的问题。接着,通过启用摄像机延迟和调整参数,使摄像机运动更加平滑,减少了蹲伏时的“快照”效果。

05:01

🎮 摄像机平滑跟随与高度调整

详细说明了如何调整摄像机跟随玩家的平滑度,通过设置摄像机延迟参数,让摄像机在玩家蹲伏或移动时更平滑地跟随。同时,还讨论了如何通过改变胶囊碰撞体的高度和添加偏移量来优化角色模型与地面的交互,避免角色穿模问题。

10:02

🎯 实现目标锁定与摄像机控制

本段讲解了如何创建一个新的输入动作来实现目标锁定功能。通过使用球体追踪技术,检测玩家摄像机前方的敌人,并在检测到可攻击对象时锁定目标。此外,还介绍了如何通过设置控制器旋转来实现摄像机的锁定视角,并添加了偏移量来调整摄像机的视角高度。

15:04

🔄 摄像机解锁与动画调整

讨论了如何实现摄像机的解锁功能,允许玩家在锁定目标后通过再次按下指定按键来解除锁定。同时,还涉及了动画的导入和调整,如何通过调整动画蒙太奇和动画蓝图来实现角色的翻滚躲避动作,并确保在攻击过程中无法执行翻滚动作。

20:05

🛡 解决碰撞检测问题并完善躲避机制

本段内容集中于解决角色在执行躲避动作时的碰撞检测问题,确保角色的胶囊碰撞体和武器不会产生错误的碰撞。此外,还讨论了如何通过修改输入动作和动画蓝图来完善躲避机制,包括设置躲避动作的布尔变量,以及调整动画蒙太奇的混合时间和退出策略。

25:08

🔄 锁定机制的进一步优化

最后,本段内容对锁定机制进行了进一步的优化,通过调整追踪通道和对象类型来提高锁定敌人的准确性和稳定性。同时,还提到了如何通过社交媒体和Discord服务器与开发者社区互动,获取帮助和分享进度。

Mindmap

Keywords

💡RPG系列

RPG系列指的是角色扮演游戏(Role-Playing Game)的系列教程。在视频中,这是教学的主题,涉及到如何在RPG游戏中设置教程锁定系统和翻滚系统,增强玩家的战斗体验。

💡教程锁定系统

教程锁定系统是指在游戏中锁定摄像机视角以便于玩家在战斗中更专注于操作的一种机制。视频中提到了设置该系统,以减少玩家在战斗中的操作负担。

💡翻滚系统

翻滚系统是游戏中的一种躲避机制,允许玩家角色通过翻滚动作来躲避敌人的攻击。视频中详细讲解了如何设置翻滚系统,使玩家能够向左或向右翻滚以躲避攻击。

💡胶囊碰撞器

胶囊碰撞器是游戏开发中用于角色碰撞检测的一种组件。在视频中,为了使角色在蹲下时能够通过某些空间,需要调整胶囊碰撞器的高度。

💡摄像机平滑移动

摄像机平滑移动是指在游戏中摄像机跟随玩家时采用的一种缓动效果,以避免移动过于突兀。视频中通过启用摄像机延迟来实现平滑移动,提升了玩家的视觉体验。

💡目标锁定

目标锁定是指在游戏中玩家可以选择并锁定一个目标,以便更准确地对敌人进行攻击。视频中创建了一个输入动作来实现目标锁定功能,增强了战斗的互动性。

💡动画蒙太奇

动画蒙太奇是一种将多个动画剪辑组合在一起的技术,用于创建复杂的动画序列。在视频中,为了实现翻滚动作,使用了动画蒙太奇来播放一系列翻滚动画。

💡根运动

根运动是指动画中的腿部或整个身体的基础运动,它影响角色的位置和方向。视频中提到了启用根运动,以确保动画与角色的移动同步。

💡输入动作

输入动作是玩家通过控制器或键盘输入的指令,游戏根据这些指令来执行特定的动作或功能。视频中创建了一个新的输入动作来实现目标锁定和翻滚功能。

💡碰撞检测

碰撞检测是游戏中用于确定物体是否接触或穿过其他物体的技术。视频中通过调整碰撞器和碰撞通道来优化目标锁定功能,确保玩家能够准确锁定敌人。

💡动画混合

动画混合是在游戏中平滑过渡从一个动画到另一个动画的技术。在视频中,通过设置动画混合的时间和类型,改善了翻滚动画的流畅度和视觉连贯性。

Highlights

介绍了如何在RPG系列教程中设置教程锁定系统,以便在战斗中锁定敌人,减少玩家的担忧。

设置了躲避系统,允许玩家向左或向右躲避敌人。

讨论了当玩家蹲下时胶囊碰撞器不缩小的问题,并提供了解决方案。

通过第三人称蓝图调整胶囊组件的高度,以实现蹲下时角色大小的变化。

解决了角色蹲下时胶囊碰撞器过低和穿地的问题。

启用了摄像机滞后功能,使摄像机移动更加平滑,减少了蹲下的突兀感。

调整了摄像机滞后参数,使游戏运动更加流畅。

通过事件图调整胶囊高度和网格偏移,以实现蹲下时角色的正确碰撞和视觉效果。

使用时间轴和插值函数实现蹲下动作的平滑过渡。

创建了新的输入动作,用于实现目标锁定功能。

使用球体追踪和通道检测来实现目标锁定,允许玩家锁定并关注敌人。

实现了目标锁定的取消功能,允许玩家在锁定状态下通过再次按下按键来解除锁定。

讨论了如何避免角色模型在躲避时与地面发生穿透的问题。

导入并设置了躲避动作动画,增强了战斗的动态性和玩家的操作体验。

通过动画蒙太奇和输入动作的结合,实现了在战斗中可以执行躲避动作的功能。

确保了在执行躲避动作期间,玩家不能连续躲避,增加了游戏的平衡性。

调整了动画蒙太奇的混合时间,使躲避动作的过渡更加平滑。

优化了目标锁定的检测机制,通过物体类型而不是通道来提高锁定的准确性和稳定性。

鼓励观众如果觉得视频有帮助,可以点赞和订阅频道,加入Discord服务器以获取更多支持和交流。

Transcripts

play00:00

what's up guys welcome to new unview

play00:02

engine 5 tutorial today we'll go ahead

play00:04

and continue on with the RPG series

play00:06

we'll go ahead and set up the tutorial

play00:08

lock system so we can lock the camera

play00:10

into the enemy while we are you know in

play00:13

combat and it will just enable us to

play00:15

have a bit of less worries when we are

play00:18

fighting and so on and also we'll go

play00:20

ahead and set up a Dutch and roll system

play00:22

so we can dodge your enemy to the right

play00:24

to the left and so on it's gonna be a

play00:26

very easy build for so let's get started

play00:31

all right so the first thing that we are

play00:33

going to go ahead and do is basically do

play00:35

one thing that you guys have

play00:37

um comment me and also let me know in

play00:41

the Discord and right now basically when

play00:43

you go ahead and Crouch and your capsule

play00:47

uh collider doesn't go ahead and Shrink

play00:50

so let's say that I was going ahead and

play00:53

getting this thing over here I'm gonna

play00:56

duplicate real quick you don't have to

play00:57

do this okay guys this is to Showcase uh

play01:00

what I'm saying right now

play01:01

and make it let's say like this uh so

play01:04

right now I cannot pass but if I'm

play01:07

Crouch okay that's a bit too low maybe

play01:09

like this so like this of course I

play01:12

cannot pass but if I crouch I should be

play01:14

able but I still cannot pass and this is

play01:17

because of the capsule component so we

play01:19

have to go ahead and basically decrease

play01:22

so let's go into the third person

play01:24

blueprint over here okay and we can also

play01:28

go ahead and you see it real quick

play01:30

if I enable capsule component so we can

play01:33

see it right when we play the game so

play01:35

come on look let me go into the viewport

play01:37

and if you select the capsule component

play01:39

over here I can go into details and

play01:41

search for the hidden in game and use it

play01:42

safely so now you will see it on game as

play01:45

you can see so basically when I crouch

play01:47

you can see that it still is like with

play01:50

the height of what the normal player

play01:52

would have and of course we don't want

play01:55

them we want to go ahead and change it

play01:58

depending where Crouch or not

play02:00

so let's go quickly into the event graph

play02:03

I'm gonna go into our Crouch and you can

play02:05

see that we have all our stuff over here

play02:07

and basically we have to go into here

play02:10

basically when we start crouching so

play02:12

let's get all this right over here so

play02:15

basically uh from the camera and also

play02:19

the sprinting

play02:21

let's get to this and put a bit to the

play02:23

right so we have some space so basically

play02:25

let's go ahead and get our capsule

play02:27

component and the value that we have to

play02:29

change is this so set

play02:31

uh half height and this is basically the

play02:35

height so now we can just plug this here

play02:37

plug this here copy paste this plug this

play02:41

here and plug this here beautiful okay

play02:44

let's put this over here so we can save

play02:46

it better and great you can now put this

play02:49

here it's a bit better

play02:51

okay so right now the uh capsule height

play02:56

The Hub height is 90. so let's say that

play02:59

of course when we go and exit our

play03:02

crouching we need to set it back to 90.

play03:04

but when we start crouching let's set it

play03:06

to around let's say 40. okay and now

play03:09

you'll see that the capsule with the

play03:10

crease and also yes I need to connect

play03:13

the capsule component to the node

play03:14

because I duplicate it okay so now you

play03:16

will see that when I crouch the capsule

play03:18

indeed goes ahead and shrinks but

play03:22

basically there are a few problems and

play03:24

it's first of all 40 is to low and then

play03:26

our character is going through the

play03:28

ground and so on and you know there are

play03:31

many reasons on why this is happening if

play03:34

you go here you can see that if I put it

play03:36

into 40

play03:37

exactly the feet will be on the ground

play03:40

and this is not really what we want so

play03:43

what we have to do is find a middle

play03:44

point so let's say 50

play03:47

16

play03:49

5 I think will be kind of the point over

play03:52

there so let's head to let's do 60 okay

play03:56

let's go put it back to 90 of course and

play03:58

then let me close to these steps and

play04:00

open again the event graph

play04:01

uh this is a big cleaner

play04:04

this year okay let's go and put this

play04:07

around 60 we said so now of course we

play04:10

can go ahead and Crouch but if we have a

play04:14

problem and is that of course our um

play04:17

oh we have two problems as our mesh is

play04:19

going through the ground and then also

play04:21

it's very Snappy there's a snap as you

play04:23

can see

play04:25

um so there are a few things that we can

play04:26

go ahead and change over here first of

play04:29

all let's quickly go ahead and resolve a

play04:31

bit of the

play04:33

um snappiness so what we can do is

play04:36

enable camera lag and it's just

play04:38

basically making the camera movement

play04:40

much smoother as it will add a nice

play04:42

interpolation with a small delay in in

play04:45

its movement so we're going to the

play04:47

camera boom and we search for a lag you

play04:49

will see here enable a camera lag so if

play04:52

I enable this and compile you will not

play04:54

notice a huge difference when we play

play04:56

the game right on but if I crouch now it

play04:58

is not so snobby I don't worry we'll

play05:01

increase the less snappiness in a second

play05:04

we'll fix one more thing we'll basically

play05:05

do this slowly now directly set the

play05:08

height but just to show you a bit how

play05:10

the camera like works if I put this

play05:12

value into let's say instead of 10 1

play05:15

and go here you can see that now it

play05:18

takes much more for a camera to follow

play05:20

the player so basically it's just making

play05:23

things smoother depending on the spot

play05:24

the higher the quicker it will be so

play05:26

around 10 works pretty good honestly I

play05:29

like it and also our movement in our

play05:31

game will be also smoother as you can

play05:33

see like it's just a bit smoother it

play05:36

gets a bit better and also we can just

play05:38

increase it maybe a bit let's put it to

play05:39

12 you know you can play with the

play05:41

settings and so I think it's 12 will

play05:43

work pretty good and then also when we

play05:45

Crouch it's less Snappy but still it is

play05:47

a bit Snappy so we have to go ahead and

play05:49

also fix that but then also in our half

play05:52

height we have to change this because

play05:54

right now if we put this instead of 90

play05:56

to 60

play05:59

okay a smaller but then we'll have to

play06:02

increase our height so we have to put it

play06:05

back into here right until the the foot

play06:10

over here so what we can do is just add

play06:13

30 because it's just basically the

play06:14

difference between the two so we can

play06:16

just add an offset of 30 inter mesh when

play06:18

we change let's go back into the van

play06:21

graph and right after this is put once

play06:24

again our camera movement well uh

play06:28

distance over here

play06:30

and we're gonna get our mesh and

play06:32

basically we're gonna use a note which

play06:33

is ADD offset it's gonna be a local

play06:36

offset okay it's a pretty big note but

play06:39

we're only going to use one more thing

play06:40

which is here so in 30 so in the set at

play06:43

30. and then I'm going to do the same

play06:45

copy and paste it

play06:47

but

play06:49

over here and now plug in the mesh and

play06:53

then this will be minus 30 because we

play06:54

want to subtract it and now you will see

play06:58

that when I crouch it is correct and

play07:02

also I forgot to put this back into an

play07:04

idea at the start sorry about that for

play07:06

this 90 there we go

play07:08

and then you can see that now it is

play07:11

correctly but there's still this uh

play07:13

snappiness into it so now also I will be

play07:15

able to go through great pretty pretty

play07:18

cool as you can see and then when I'm

play07:20

like this now so that's exactly what we

play07:22

want great so now I want to do is

play07:24

basically slowly with also a timeline

play07:26

changes value

play07:28

so again this is very messy so let's go

play07:31

ahead and make some space into it so

play07:33

let's get all this and just put a bit up

play07:36

so we can put this one a bit up and the

play07:39

basically move this one here we go

play07:42

because there's a lot of things going on

play07:44

let's get this move it here

play07:47

this here

play07:49

and the Sears are about this guys but we

play07:52

need to do some cleaning because holy

play07:55

crap this is pretty

play07:58

messy right now here okay

play08:01

uh much better great so we have to add

play08:04

some timeline into this too so just go

play08:07

ahead and right click add

play08:09

timeline over here and then this will be

play08:12

the uh capsule

play08:18

something like that let's go ahead and

play08:20

double click to enter it and now it's

play08:22

gonna add a float and this is gonna be

play08:25

our new height

play08:27

okay it's gonna be a flow track and now

play08:30

we want to set the length to be let's

play08:32

say how much does this take in the other

play08:35

cam it is one second all right so we'll

play08:37

do the same let's put it well actually

play08:39

let's do 0.5 because I think it's gonna

play08:41

be better so let's put 0.5 and then add

play08:43

a key the first key let's selected and

play08:45

put the time to be zero as it will be

play08:47

restored and the value as zero but then

play08:49

let's add another key and this time the

play08:51

time will be at 0.5 which is where it

play08:53

ends and then the value I won and then

play08:56

you will see that it will just go uh in

play08:59

a linear equation here

play09:02

so we can just now go ahead and play

play09:04

this from the start

play09:06

right actually before we set our capsule

play09:11

height so move this a bit and let's get

play09:13

this front plate from start and then on

play09:17

update we'll go ahead and put this here

play09:21

basically both of these ones the things

play09:24

that we don't want to also basically do

play09:27

all this in the update because this is

play09:28

basically separate

play09:30

so we want to do is from here do a

play09:33

sequence

play09:35

and yes the first one will go from here

play09:36

but the second one will go all the way

play09:39

to here to the branch so we don't have

play09:41

to do anything in there so double click

play09:44

put the serum

play09:46

and put this one here

play09:48

so yeah extremely messy

play09:51

but we don't have a lot of room

play09:54

um but but there we go we can make it a

play09:57

bit better great

play09:58

so that's what I'm going ahead and

play10:00

working

play10:02

um and now from this we need to do

play10:05

exactly the same another sequence

play10:07

the this one will go into the reverse

play10:11

okay now for Matt let's just reverse and

play10:13

this one will just go straight into the

play10:15

branch and now we can disconnect this

play10:16

one okay because if not

play10:18

it will go ahead and do so there and yes

play10:22

I just forgot we can just delete this

play10:24

both ones over here uh no this one

play10:27

because now if we do the reverse it will

play10:31

go back into Norm so great everything

play10:33

going crazy crazy good uh so let's get

play10:37

the height and let's do a lurk and

play10:39

you'll see a float lurp so now we can

play10:41

hold Ctrl and move the a into the alpha

play10:44

so now we can transition between two

play10:45

values which in this case will be from

play10:48

90

play10:50

two

play10:51

um 260. and now we can just plug that

play10:54

into the half height capsule and then

play10:57

we'll need to do the same with the local

play10:58

offset so we're gonna get another lerp

play11:01

blurp float and then the mode into the

play11:06

alpha with control the first point will

play11:08

be uh yes 30 and then it's going to be

play11:12

minus 30.

play11:13

and I'm gonna plug that into there but

play11:15

we need to right click in here and split

play11:17

it so we can just put it into the set

play11:19

axis

play11:20

and that should work exactly like it is

play11:23

always but with a nice

play11:26

okay so you can see the capsule is good

play11:29

but the uh is incorrect we don't have to

play11:33

basically add a local we have to

play11:35

transition between new two sorry so now

play11:37

in the mesh

play11:39

we can just do set I was a location

play11:44

set relative location for the image okay

play11:47

I added two meshes okay we're going to

play11:48

delete this one because now it's not

play11:50

adding now it's just setting because

play11:52

it's better for us again right click

play11:54

split it and put it on the Zed but now

play11:57

we have to manually find the position so

play12:00

at the start of will be minus 89

play12:02

so let's plug that in here minus 89. and

play12:05

then the second one will be basically I

play12:07

was a plus 30. so it will be a minus 59

play12:11

okay so minus 59 there you go a lot of

play12:16

calculations here but there we go so now

play12:19

there you go we have a smooth transition

play12:21

between the two

play12:22

ah okay

play12:24

thankfully okay sorry about that guys if

play12:27

I confuse some of you guys I was mainly

play12:30

because it was a bit of a spaghetti gold

play12:32

there but basically let me real quick

play12:34

recover it so basically until here we

play12:37

are making a sequence so it will just do

play12:39

the same of the camera it will just

play12:40

continue like normal okay nothing will

play12:43

go ahead and change

play12:45

but

play12:46

um in the in the first one here it will

play12:51

do the new thing so basically we're

play12:52

doing a small transition here and we're

play12:55

getting this a transition from 90 to 60

play12:57

and we are setting this new height so

play12:59

slowly it will do it and then in here

play13:02

we're basically changing from this

play13:05

location instead which is the normal one

play13:07

into the new one basically I'm applying

play13:11

it for mesh and then one is in the not

play13:13

crouching we will just do it from the

play13:15

reverse because it will just go you know

play13:18

to the other values and then here we

play13:20

just continuous normal to the camera so

play13:22

yeah sorry about that but done we can

play13:24

move on into the target lock template so

play13:28

let's go ahead and do so but let's

play13:30

create a new input so let's go into the

play13:32

third person inputs and then actions and

play13:34

now we can just go ahead and right click

play13:36

go into input action it's going to be EA

play13:38

underscore and then here we can say uh

play13:41

it's going to be

play13:43

um Target lock

play13:45

and we don't have to even open it you

play13:47

save it and close it great let's go now

play13:49

to the collection and on here we can add

play13:51

it so new mapping and this will be our

play13:53

and Target lock and then we're gonna

play13:56

assign a key in this case we can select

play13:58

it and say tap okay let's say that with

play14:00

tab we can go ahead and entire lock of

play14:02

course you can choose whatever key you

play14:04

want let's close it and now we can just

play14:06

go down over here into the blueprints

play14:07

let's find a nice space right over here

play14:10

let's say on the Sprint team right click

play14:12

it's going to be e a underscore Target

play14:14

lock the first one with the arrow here

play14:16

and basically in startup we can start

play14:19

making our calculations so we want to do

play14:22

is make a sphere Trace

play14:26

by Channel basically this would use

play14:28

great and invisible right cast and

play14:31

movable sphere

play14:33

um forward okay well right now not

play14:35

forward but we'll set it so it's forward

play14:37

so the starting point will be actually

play14:39

from the camera so let's get the full

play14:41

camera and then say get weld location

play14:44

and now you can plug that into the start

play14:47

over here

play14:49

great now the end point will basically

play14:51

be well let's get the rotation okay the

play14:54

world rotation and let's get the forward

play14:56

axis basically where the camera is

play14:59

looking at and now we can use multiply

play15:01

this value by a number so it's going to

play15:04

be the distance that will be able to

play15:06

detect an enemy but we have to right

play15:08

click over here and convert this into a

play15:10

nice float a nice number and in this

play15:13

case it will be let's say around 500.

play15:15

and now we need to do is get this and

play15:18

just add this into this so we'll get the

play15:20

direction and this will be the end point

play15:22

so the certain point will just be in our

play15:24

camera and the endpoint will be 500

play15:27

um of distance in front of our camera

play15:31

and then the radius let's set something

play15:33

as

play15:35

125. first you can play with the

play15:37

settings once we have it going on and

play15:40

then the the bug type let's say it's

play15:42

gonna be for duration so we can preview

play15:43

it so naturally we can start proving it

play15:45

if I compound and go here I can press

play15:47

Tab and you can see this um sphere so

play15:51

this is where the uh

play15:54

it will detect the enemies so if I go

play15:55

here I will say Tab and then if it

play15:57

detects the enemy it will go there

play16:00

so great uh everything is going ahead

play16:02

and working so now we need to go ahead

play16:05

and just make sure that we have hidden

play16:07

something so if we have hit something we

play16:09

can now get the out hit and break it so

play16:11

we can get all the details about the

play16:13

object so we want to get the hit actor

play16:15

and make sure that it has the tag

play16:17

damageable

play16:19

which is the one that we create for the

play16:21

enemy in this case just the dummy so

play16:23

let's go ahead and just check if it's

play16:24

spell like that Ctrl e to open the dummy

play16:27

and now we can go into the class

play16:28

defaults and search up attack and then

play16:32

is this one damageable so I'm just going

play16:34

to copy and paste this is the same

play16:36

spelling just in case but it should be

play16:38

completely fine so ever any tag that has

play16:42

this any actor that has a stack will be

play16:45

able to Target lock into it so it's

play16:46

gonna be cool and very Dynamic so get

play16:49

the uh out here and make another Branch

play16:51

this will be a separate Branch over here

play16:54

great so

play16:57

uh now want to do is basically tire lock

play17:00

into that one so let's save the hit

play17:02

actor into a variable right click and

play17:04

then promote to Bible and this will be

play17:06

the actor

play17:10

to Target lock okay and now oh just said

play17:15

over here in the true so if this is true

play17:17

okay it has the tag damage book we want

play17:21

to go ahead and set it as a new variable

play17:24

great so now we can compound and save so

play17:26

now we will detect our enemy and save it

play17:28

in a variable but of course nothing more

play17:30

we'll go ahead and have him

play17:32

so we need to do now is go into the van

play17:35

tick and do so some things over there

play17:38

let's go here and move all that and to

play17:40

the right which is actually in a stamina

play17:42

but it's okay we'll move in later on and

play17:44

make a sequence so we'll do the stamina

play17:46

things over here and then another point

play17:48

we'll do our basically our um our new

play17:52

stuff so let me just wrap it a bit let's

play17:54

proceed to comment it it's going to be

play17:56

Target lock let me put the T

play18:00

go and let's apply our preset over here

play18:03

great so this is basically perfect

play18:09

um so in here what we can do is now make

play18:12

sure that we have a a an actor tutorial

play18:15

lock if so basically we are Target

play18:18

locking so let's get the actor and let's

play18:21

right click and convert this into a

play18:22

validated kit so basically if it's valid

play18:25

it means that this variable has our

play18:27

actor that we have just detected saved

play18:30

on so if it's true basically we need to

play18:32

start lock so we want to do is basically

play18:35

get the controller

play18:37

okay and to get the control and now we

play18:40

need to do is set the control rotation

play18:43

so this will basically set up and

play18:47

override the whole rotation of the of

play18:49

our player

play18:51

so now the new rotation will be

play18:52

basically a find local rotation the

play18:55

starting point will be our current

play18:57

location so get actual location but our

play19:00

destiny our Target will be the actor

play19:03

location of

play19:05

our enemy so now we can just plug that

play19:07

into Target I know this is very messy

play19:11

right now because overlapping with our

play19:13

code let's put it here great that's a

play19:16

bit better we'll move the advantage

play19:17

later on

play19:19

um so now if we compile you will see

play19:21

that actually it should be working so if

play19:23

I go here and press tab

play19:25

and I get a bit closer I need to change

play19:27

the distance you can see then I I cannot

play19:29

move with my mouse the camera but it

play19:31

will be tire locked into the enemy great

play19:33

so now we need to do some more things

play19:35

first of all you notice that it was the

play19:37

camera was very down so then that we can

play19:39

do is basically apply an offset so let's

play19:42

go and break this pin and right click

play19:44

and split it on both of them

play19:46

okay and then actually we don't have to

play19:48

split it so you can just drag this and

play19:51

basically subtract it so we're gonna

play19:53

subtract an amount of distance let's say

play19:56

Indie said 100. so basically now the the

play20:00

thing will be upper and also let's

play20:02

increase a bit the distance

play20:05

so let's say a thousand

play20:08

pretty far away we're gonna be able to

play20:10

detect our enemies let's go here press

play20:13

tab

play20:14

I think it's collating with something

play20:16

else huh

play20:20

okay sorry about that

play20:22

um

play20:24

yes I think it's colliding it should be

play20:27

touching only the damageable

play20:30

um and it has ignore itself so I don't

play20:34

really know

play20:35

why it's not detecting him there we go

play20:38

now I don't know what happened but hey

play20:39

now the camera is basically more up in

play20:42

the sky so it's easier for us to go

play20:44

ahead and see the enemy and so on and

play20:47

it's easier to us for attack it will be

play20:49

already pinned into the center of him

play20:51

great so now we need to go ahead and

play20:53

well do the opposite be able to unturn

play20:56

your lock let's go here into the starter

play20:58

we can get a branch

play21:00

and

play21:02

and sorry not a branch but we can just

play21:04

get director here and then right click

play21:07

and convert to valid again so basically

play21:09

plug it here and if it's not valid it

play21:11

means that this bamboo is empty we have

play21:13

not a third lock to go ahead and unlock

play21:15

hunt so we just want to do the

play21:17

calculations but if we already have one

play21:20

on we want to go ahead and get this

play21:22

third lock and set it to be nothing

play21:25

empty so now basically we will not be

play21:28

able to continue to tire lock because in

play21:30

Advantage it will detect that is empty

play21:32

so if I try a lock as you can see I'm

play21:35

sorry locking but when I press tab again

play21:38

I will go ahead and be free and then I

play21:41

can go and Target lock to him if it

play21:44

takes I don't know why something's

play21:45

detected or not but now we can go ahead

play21:47

and try log again great so everything is

play21:49

working and

play21:51

um

play21:52

I think it's colliding

play21:55

with myself honestly

play21:58

which is pretty strange anyway I'm gonna

play22:01

also turn on the capsule component to

play22:03

not be hidden in game because that's a

play22:06

bit yes

play22:08

um

play22:09

and the swords should not have any

play22:11

Collision but it's weird because

play22:14

basically we have ignore self on so I

play22:18

don't know why it's not sometimes not

play22:20

detecting

play22:22

see it's like

play22:24

it's like making two different ones

play22:26

strange but anyway

play22:30

huh

play22:36

oh you know what is the trace Channel

play22:39

which is set to visibility let's go

play22:42

quickly into here into our dummy

play22:44

let's Ctrl e

play22:46

and let's go into the capsule component

play22:48

and basically if we open collection

play22:50

presets you'll see okay visibility is

play22:52

set to block

play22:54

and the mesh itself

play22:56

is set to block so it should always

play22:59

detect it

play23:01

so

play23:03

okay now they type the person okay

play23:05

anyway you can go ahead and right now

play23:08

tire lock in our enemy also motion warp

play23:11

into it okay so now there's only one

play23:13

more thing left in this video and

play23:16

basically it is the Dutch so again I

play23:19

have left the animation in the

play23:21

description is go ahead and load it from

play23:23

Google Drive it's again from the RPG

play23:25

template from epic games totally free I

play23:28

just extracted this animation so it's

play23:29

easy for you guys and it's good go ahead

play23:32

and grab it and just drag it into the

play23:34

content browser but first let's go ahead

play23:36

and open the folder so everything is

play23:37

organized let's go to characters RPG

play23:39

character animations and now let's go

play23:42

ahead and create a new folder it's going

play23:43

to be Dodge and underscore Raw

play23:47

let's go and open this and now we can

play23:50

just drag it into here so the skeleton

play23:53

will be the normal SK mannequin the ue51

play23:56

and now we're going to say in Port all

play23:58

and now we have the animation here so

play24:01

you can see if we open it you can see

play24:03

the motion warping happening and we need

play24:06

to go under here and say enable root

play24:08

motion and also force uh root block

play24:12

great so now we need to go and create a

play24:14

new input so we can play it so let's go

play24:16

into the third person character input

play24:18

and actions and just go ahead and right

play24:20

click and create a new

play24:22

reset input action EA underscore and

play24:26

this will be basically this Dodge

play24:29

we don't have to do anything we just

play24:30

need to go into collection and I'll add

play24:32

a new mapping in this case it will be

play24:35

basically Dodge and let's say it's going

play24:37

to be for example X

play24:40

the thing is that we have control and

play24:42

shift already for motion voting

play24:46

and also crouching so we'll see later on

play24:49

the series will arrange our keys better

play24:51

of course and if we will also add a

play24:54

mapping for controllers which is really

play24:56

the best gaming is to play an RPG so I

play24:59

will also add that and we better anyway

play25:01

we can go back now into the third person

play25:03

character

play25:04

and let's go down over here entire lock

play25:07

so again the a underscore is going to be

play25:11

in this case

play25:12

um

play25:13

Dodge okay with the arrow and in started

play25:16

we'll go ahead and say play a name

play25:19

Montage okay great so now we have to

play25:22

create an animation Montage so let's go

play25:24

back into our animation that we have

play25:25

just imported in here in the Dodge well

play25:28

just right click into it create an image

play25:31

we can leave the name like this go here

play25:33

and just plug it in great so now we'll

play25:35

play the animation each time that we

play25:37

press the key

play25:38

but we only want to do it uh basically

play25:41

we want to do it even though we are

play25:44

attacking so maybe I am attacking

play25:48

and I want to go ahead you can see how

play25:50

it look cool looks

play25:52

um and basically

play25:53

you know Vault so both no but Dodge okay

play25:56

so uh the thing is that if not if I am

play25:59

in middle of an attack you will see

play26:01

and I vote not voice but Dodge you can

play26:04

see that I cannot longer attack so

play26:06

basically we need to detect if we are

play26:08

attacking and if so can't sell the combo

play26:11

so we need to go ahead and just get this

play26:12

and make a branch and we're gonna go and

play26:15

get our attack system component and then

play26:18

say get is attacking

play26:20

and if it's not attacking it will

play26:23

directly go into the enemy Montage but

play26:25

if it is attacking we need to get this

play26:27

and do stop combo

play26:30

and put it in true basically in between

play26:33

great so that's pretty much it

play26:36

so what we have to do

play26:38

and

play26:40

um

play26:40

and that's it so now we can go ahead and

play26:42

attack and I can dodge and then continue

play26:45

to attack perfectly great

play26:47

so now I can go ahead and tie a lock to

play26:50

the enemy you can go ahead and start

play26:52

fighting and then you can go and Dodge

play26:54

cancel my attack move back here attack

play26:58

Dodge in all directions go back here

play27:01

Dodge and continue attacking great now

play27:05

things like I can interrupt my Dutch and

play27:07

looks pretty weird as you can see let's

play27:09

quickly go ahead and make a variable

play27:11

coach called not catch code and it's

play27:15

dodging

play27:16

and basically I need to change this code

play27:19

to be instead of play and a montage play

play27:22

animation

play27:24

uh play Montage just play montage

play27:27

hold Ctrl to get all the pins and mode

play27:29

here and then let's plug in the Dodge

play27:31

again so things like this node as

play27:34

difference compared to the other one it

play27:36

will have different outputs for when the

play27:38

animation is completed also get the mesh

play27:41

and drag it into this cartoon mesh so it

play27:43

will play in that mesh out there so when

play27:45

it's completed we'll get inside it's

play27:47

touching to be false but when it started

play27:51

we will set is touching two

play27:54

through

play27:56

and then as you start we will go ahead

play27:59

and make sure that

play28:01

um

play28:02

make another branch

play28:03

and make sure that we are not touching

play28:06

so let's get touching and it's not

play28:08

Boolean great so we cannot Dodge and

play28:12

Dodge while we are dodging okay so now

play28:14

you can see it's great I cannot do what

play28:17

I was doing before great really good

play28:19

stuff over here uh let's go into

play28:21

characters would be character animations

play28:23

go back into the Dodge row let's open

play28:25

the Montage I just wanted to do the

play28:27

final thing let's go into the blend out

play28:28

and let's put this on cubic and let's

play28:31

put around 0.4 seconds

play28:32

basically it will just make the blending

play28:35

out a bit smoother as you can see okay

play28:39

this makes it a bit smoother

play28:41

and uh there we go

play28:43

so this one more thing that I want to

play28:46

look is that sometimes you know it

play28:48

doesn't it takes in the enemy for some

play28:50

reason very strange reason

play28:52

so I'm gonna go back into the entire

play28:54

lock and instead of doing a sphere

play28:56

trades by Channel I'm gonna make a

play28:58

sphere

play29:00

oh

play29:02

and sphere trades for Optics it's pretty

play29:05

pretty much the same thing but instead

play29:07

of giving us Adventure detecting uh the

play29:11

object by a channel it will just detect

play29:13

the object by the object types let's

play29:16

hold it uh code control move this down

play29:18

hold Ctrl move this down hold Ctrl move

play29:22

this down and hold Ctrl move this down

play29:24

hold Ctrl move this down hold on

play29:28

move this down if it doesn't crash while

play29:30

okay well just plug the end point here

play29:33

and the radius 125 and then the debug

play29:37

type for duration let's go ahead and

play29:39

just move it down because we don't need

play29:41

it right now

play29:42

let's put it up let's get object types

play29:44

and say make array so now we can select

play29:46

and in our case it will be pawns because

play29:49

normally in Unreal Engine all the

play29:51

characters are Pawns in our case it is

play29:53

and it will continue to be so so pawns

play29:55

and uh that's pretty much it so let's

play29:58

see if that's gonna fix it hopefully and

play30:04

it didn't it it made it worse basically

play30:08

um

play30:09

so maybe

play30:11

Okay so

play30:15

yes it's a pawn right

play30:18

let's make it uh well maybe it's a

play30:20

physics body because it changed

play30:23

in a second guys

play30:25

yes so it is a physics body if you can

play30:29

try a pawn if it doesn't work physics

play30:30

body and the reason is that we have it

play30:33

so our mesh it has basically a physics

play30:37

body in it that's really I mean the

play30:39

capsule component is like a pawn kind of

play30:41

but whatever reason uh but now it should

play30:46

always work yes good good good

play30:49

so now the combat should be way more

play30:53

fluid as you can see

play30:55

and and yes

play30:57

okay

play30:59

good

play31:00

and also our crouching it is way

play31:04

smoother

play31:06

go here

play31:07

there we go

play31:08

cool cool sub over here so if you found

play31:11

it so helpful I really appreciate you

play31:13

could like the video and subscribe to my

play31:14

channel I have lots of unviewings in

play31:16

fact though so if you want to go ahead

play31:17

and check them out go ahead join my

play31:19

Discord server so you can go ahead and

play31:21

you know show you the progress that

play31:22

you're making in the series or in your

play31:24

own games or price and also ask any

play31:26

questions about the series or that you

play31:28

have in general or not real engine on

play31:30

top with other devs that just mean

play31:32

follow me on my social so there's

play31:34

Twitter and Instagram and now yes before

play31:36

I said bye

play31:38

foreign

play31:40

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
RPG游戏教程锁定翻滚机制战斗系统游戏开发UE5教程角色动画动作设计目标锁定玩家控制游戏优化
Do you need a summary in English?