Unreal Engine 5 RPG Tutorial Series - #14: Equipment System

Gorka Games
19 Mar 202326:24

Summary

TLDR在这个Unreal Engine 5的教程视频中,我们将开始构建一个角色扮演游戏(RPG)的装备系统。视频首先展示了装备系统的结构,灵感来源于《刺客信条:起源》,玩家可以在界面中为角色装备武器、盾牌和护甲等。接着,教程详细介绍了如何在Unreal Engine中创建数据库和数据表,以及如何定义武器的结构,包括名称、伤害、等级要求、图标和模型等。此外,还展示了如何创建一个可拾取的武器蓝图,并通过玩家的交互动作将其添加到角色的库存中。最后,视频还简要介绍了如何在玩家蓝图中添加装备系统组件,并通过键盘按键实现拾取功能。整个教程旨在为观众提供一个易于跟随的入门指南,为后续的UI实现和更深入的系统集成打下基础。

Takeaways

  • 🎮 视频教程是关于Unreal Engine 5的RPG系列,今天开始装备系统的构建。
  • 🛡️ 装备系统将受到《刺客信条:起源》的启发,有角色在中间和装备槽位用于装备武器、护甲、盾牌等。
  • 📚 将创建一个数据库来组织所有的装备信息,包括名称、伤害值、所需等级、图标、静态网格和装备类型。
  • 🔍 通过创建一个名为`e_weapon_types`的枚举器来区分近战武器、远程武器、护甲和盾牌。
  • 📁 为了更好地组织,创建了两个结构体:`_s_weapons`用于定义武器的属性,`_s_slots`用于在数据库中存储装备槽位信息。
  • 🔨 使用数据表`DB_weapons`来存储所有武器的实例,并通过行名来区分不同的武器。
  • 🔄 创建了一个蓝图类`BP_weapon`,用于在世界中放置装备,并允许通过选择不同的数据库条目来更改静态网格。
  • 🔗 通过创建一个新的蓝图组件`bpc_equipment_system`,将装备系统整合到玩家角色中,以便于管理和拾取装备。
  • 🔑 实现了一个功能,允许玩家通过按'E'键与世界中的装备互动,并将其添加到库存中。
  • 📊 为了调试和查看库存中的装备,创建了一个自定义事件,通过按'H'键可以打印出当前库存中的所有装备。
  • 🌟 视频最后提到,接下来的教程将会涉及UI的实现,允许玩家在界面中选择和管理装备槽位。
  • 📢 鼓励观众点赞、订阅频道,并加入Discord服务器以获取更多帮助和交流。

Q & A

  • 在Unreal Engine 5中,如何开始构建装备系统?

    -首先,需要创建一个新的文件夹来组织装备系统相关的资源。接着,创建一个结构(Structure)来定义装备的属性,如名称、伤害值、图标、所需等级和装备类型等。然后,创建一个枚举器(Enumerator)来区分不同类型的装备,如近战武器、远程武器、装甲和盾牌。

  • 如何将装备添加到角色的装备槽中?

    -通过创建一个数据库(DataTable)来存储装备的结构信息,并在角色蓝图中添加一个装备系统组件(Component),该组件可以调用函数来添加装备到装备槽数组中。

  • 在Unreal Engine 5中,如何实现装备的拾取功能?

    -通过在玩家输入动作中添加一个交互(Interact)动作,使用线迹(Line Trace)或球体追踪(Sphere Trace)来检测玩家前方的物体。如果检测到装备物品,将其添加到玩家的装备槽数组中,并在世界中销毁该物品实例。

  • 如何通过蓝图创建自定义的装备属性结构?

    -在Unreal Engine的蓝图编辑器中,右键点击创建新的结构(Structure),并为装备定义所需的属性,如名称(String类型)、伤害(Float类型)、所需等级(Integer类型)等。

  • 在装备系统中,如何使用数据表来管理多种装备?

    -创建一个数据表(DataTable),并选择之前创建的装备结构作为其数据类型。在数据表中添加不同的装备项,每个装备项都有其独特的属性值,如名称、伤害、图标等。

  • 如何将装备模型添加到角色上?

    -通过在装备的蓝图类中添加静态网格组件(Static Mesh Component),并使用数据表中对应的装备项来动态设置该静态网格组件的模型。

  • 在装备系统中,如何实现装备类型的分类?

    -通过创建一个枚举器(Enumerator),定义不同的装备类型,如近战武器、远程武器、装甲和盾牌。然后在装备的结构中添加一个类型字段,使用这个枚举器来限制装备只能装备到对应的槽位中。

  • 如何通过蓝图动态改变装备的图标和模型?

    -在装备的蓝图中,使用数据表行获取(Get Row)节点来动态获取装备的属性,包括图标和静态网格模型。然后,将这些属性应用到相应的UI元素和角色模型上。

  • 在Unreal Engine 5中,如何实现装备的拾取并添加到玩家的背包中?

    -创建一个用于拾取装备的自定义输入动作,然后在玩家蓝图中使用追踪(Trace)来检测玩家前方的装备。当玩家按下拾取键时,检测到的装备将被添加到玩家的装备槽数组中,并通过调用装备系统组件的添加装备函数来实现。

  • 如何在游戏中调试并查看玩家当前拥有的装备?

    -在玩家蓝图中添加一个自定义事件,如按键H触发的事件,用来遍历装备槽数组并打印出每个装备的详细信息,从而实现在游戏中的调试查看。

  • 在装备系统中,如何简化装备的管理和自定义?

    -通过使用数据表和结构体来定义装备的属性,可以轻松地添加、修改或删除装备。所有的装备信息都存储在一个集中的数据库中,使得管理和自定义过程更加高效和有序。

Outlines

00:00

🔨 介绍装备系统和数据库构建

本段介绍了如何开始构建RPG系列中的装备系统。首先,创建一个以《刺客信条:起源》为灵感的装备界面,其中包括角色模型和装备槽。接着,讨论了如何创建数据库和添加武器,以及如何使武器可被拾取并添加到库存中。最后,介绍了如何在Unreal Engine中创建文件夹和结构,以及如何定义武器的不同参数,如名称、伤害值、等级要求和图标。

05:00

📚 创建枚举器和数据库

这一段讲解了如何创建一个枚举器来定义不同类型的武器,如近战武器、远程武器、护甲和盾牌。接着,创建了一个结构体S_Slots,用于在数据库中存储武器信息。然后,创建了一个数据表DB_Weapons,用于存储各种武器的具体信息,如名称、伤害、图标、模型和类型。

10:01

🛠️ 创建可拾取武器蓝图

本段介绍了如何创建一个可放置在世界中的BP_Weapon蓝图,该蓝图将包含一个静态网格来表示武器。通过创建一个S_Slots类型的变量,可以在世界中放置时选择不同的武器。此外,还介绍了如何在构造脚本中动态分配静态网格,以匹配数据库中选择的武器。

15:02

🔌 实现物品拾取和添加到库存

在这一段中,讲解了如何创建一个BPC_Equipment_System组件,该组件允许玩家拾取武器并将其添加到库存中。通过创建一个新的输入动作EA_Interact(绑定到E键),玩家可以与世界中的物品互动。使用球面追踪技术检测玩家前方的物品,并将其添加到库存数组中。

20:05

📊 调试和显示库存物品

最后一段讲述了如何通过自定义事件来调试和查看库存中的物品。通过按下H键,可以在屏幕上显示当前库存中的所有武器。这通过一个For Each循环实现,该循环遍历库存数组并打印出每个武器的详细信息。

25:06

📢 结语和社区互动

视频以鼓励观众点赞、订阅频道和加入Discord服务器结束,以便提出问题、展示进度和与其他开发者交流。同时,预告了下一集将开始制作UI界面,允许玩家选择装备槽。

Mindmap

Keywords

💡虚幻引擎5(Unreal Engine 5)

虚幻引擎5是一款由Epic Games开发的游戏引擎,广泛用于制作高质量的视频游戏和模拟。在视频中,它被用作创建RPG系列教程的基础平台,展示了如何利用这个引擎开发角色扮演游戏中的装备系统。

💡装备系统(Equipment System)

装备系统是角色扮演游戏中的一个核心组成部分,允许玩家为角色装备不同的物品,如武器、防具等,以增强角色的能力。视频中详细介绍了如何在虚幻引擎5中构建这样一个系统。

💡数据库(Database)

在视频中,数据库用于存储和管理游戏中所有装备的数据。通过创建数据表(DataTable)来组织装备的属性,如名称、伤害值、图标等,这有助于统一管理和更新装备信息。

💡蓝图(Blueprint)

蓝图在虚幻引擎5中是一种可视化脚本工具,允许开发者通过图形界面而非传统编程来创建游戏逻辑。视频中使用蓝图来设计装备的结构和行为,如创建装备的蓝图类和定义装备的属性。

💡静态网格(Static Mesh)

静态网格是游戏中用于3D模型的一种网格类型,它不包含任何动画或动态变化。在视频中,静态网格用于表示装备的3D模型,如武器和防具,它们会被添加到角色模型上。

💡UI插槽(UI Slots)

UI插槽是用户界面中用于展示和操作装备的部分,允许玩家在界面中看到并选择他们想要装备的物品。视频中提到了未来将会实现UI插槽,以便玩家可以直观地管理他们的装备。

💡枚举器(Enumerator)

枚举器是一种数据类型,用于定义一组命名的常量。在视频中,枚举器被用来定义装备的不同类型,如近战武器、远程武器、防具和盾牌,以便在装备系统中进行分类和使用。

💡数据表行(Data Table Row)

数据表行是数据表中的一个记录,包含了一组数据字段。在视频中,每个装备项都被定义为数据表中的一行,包含装备的所有属性,如名称、伤害、图标等。

💡拾取(Pick Up)

在视频中,拾取是指玩家能够通过游戏中的互动将装备从世界中拾取并添加到自己的库存中。这是通过在玩家蓝图中实现的,使用线迹追踪(Line Trace)来检测并拾取装备。

💡自定义事件(Custom Event)

自定义事件在蓝图中用于创建可以由其他蓝图或游戏逻辑触发的事件。在视频中,自定义事件被用来在玩家按下特定键时显示当前库存中的装备列表,用于调试和展示目的。

💡第三人称蓝图(Third Person Blueprint)

第三人称蓝图是虚幻引擎5中用于定义第三人称角色控制和行为的蓝图。视频中提到了将装备系统组件添加到第三人称蓝图中,以便将装备系统逻辑集成到玩家角色中。

Highlights

教程介绍了如何使用Unreal Engine 5创建角色扮演游戏(RPG)中的装备系统。

装备系统的设计灵感来源于《刺客信条:起源》,展示了角色装备武器和防具的界面布局。

创建了一个数据库和数据表来组织和存储装备的各项属性,如名称、伤害、等级要求等。

通过创建一个名为'S_Weapons'的结构体,定义了武器的基本属性,如名称、伤害和所需等级。

使用枚举类型'E_WeaponTypes'来区分不同类型的装备,如近战武器、远程武器、护甲和盾牌。

创建了'S_Slots'结构体,用于表示装备槽位中的具体装备项,包括装备数据和静态网格引用。

通过数据表'DB_Weapons'添加了初始武器,如轻剑、重剑和木弓,并设置了它们的属性。

创建了'BP_Weapon'蓝图类,用于在世界中放置装备,并允许玩家与之交互。

实现了一个功能,允许玩家通过E键与装备交互,并将选中的装备添加到库存中。

使用线迹追踪(Line Trace)技术来检测玩家视线范围内的装备,并实现捡取功能。

创建了一个自定义事件,通过按H键可以查看当前库存中的所有装备,方便调试。

教程展示了如何通过修改数据表中的数据来动态更新装备的属性和外观。

介绍了如何将装备系统组件添加到玩家角色蓝图中,以实现装备的捡取和库存管理。

强调了数据库和数据表的模块化设计,使得未来可以轻松添加新的装备类型和属性。

整个教程强调了Unreal Engine 5中蓝图系统的灵活性和对RPG装备系统的适用性。

预告了下一集将开始制作装备系统的用户界面(UI),允许玩家在界面中选择和装备物品。

鼓励观众点赞、订阅频道,并加入Discord服务器与其他开发者交流和展示进度。

Transcripts

play00:00

what's up guys welcome to new Unreal

play00:02

Engine 5 tutorial and today we are

play00:04

continuing with the RPG Series today we

play00:07

will finally begin with the equipment

play00:09

system we'll begin to structure all the

play00:11

database and so on make a peekable item

play00:14

that we can add into our inventory and

play00:17

with the next couple of episodes we'll

play00:19

be implementing the UI slots and so on

play00:21

it's going to be a very easy video to

play00:23

follow so let's get started

play00:27

alright so first of all let me show you

play00:29

a bit on how the equipment system will

play00:33

be structured so of course it will take

play00:36

again an inspiration from Assassin's

play00:39

Creed Origins as you can see we will

play00:42

have the character in the middle and

play00:43

then we'll have a few slots that we can

play00:45

equip our weapon okay or item in general

play00:49

like armor shield and so on okay so as

play00:53

you can see this is pretty much the

play00:55

reference image now we'll probably

play00:57

simplify a bit more instead of having

play00:59

two range and two Amelia we may have

play01:02

just one of each and then have it on

play01:05

this side so Malay shield and then armor

play01:08

and Rings something like that so

play01:10

probably simplify a bit but of course

play01:12

this is totally customizable you can

play01:15

change it however you want but of course

play01:17

this is how the RPG series will be based

play01:19

now in terms of structure it's pretty

play01:23

you know self-explanatory once you open

play01:25

the the slot you have a list of all the

play01:28

items that you have in your inventory so

play01:31

you can go ahead and just equip it so

play01:33

today we'll like I just mentioned before

play01:35

in the intro we will just begin making

play01:37

the database Destructor and adding some

play01:40

some weapons and then also going ahead

play01:43

and making the applicable items so they

play01:45

can go ahead and pick it up and add it

play01:47

into our inventor okay

play01:50

so with no more information let's go

play01:53

ahead and get started so let's go into

play01:55

unrue engine and the first thing that

play01:57

we're going to do is go ahead and create

play01:59

a new folder so we can have everything a

play02:02

bit more organized so let's go ahead and

play02:03

right click new folder and this will be

play02:05

the equipment uh system okay let's go

play02:10

ahead and open it up and now the first

play02:12

thing that we have to do is create a

play02:15

structure so if we right click and go uh

play02:18

into blueprints you will see that we

play02:20

have a structure okay so we go ahead and

play02:22

select it we can name this as underscore

play02:25

weapons now if you want to make it more

play02:28

General and in the future also be able

play02:30

to equip uh different types of um now

play02:34

weapons but maybe items in general for

play02:36

example

play02:38

um I don't know I mean honestly we're

play02:39

gonna also be adding Shields and armor

play02:42

under Destructor so it might not really

play02:45

in the future make sense on you know on

play02:48

eBay called weapons so if you want you

play02:50

can really just put it as items okay but

play02:53

for me I'm gonna basically leave it as

play02:56

Weapons as I think it will just be a

play02:58

clearer a name for for a structure in

play03:01

general so go ahead and open it

play03:03

and down here what we can do is put all

play03:06

different parameters that each weapon

play03:09

will have so in our case let's begin

play03:11

with the first parameter which will be

play03:13

the name of the item itself so this will

play03:16

be called name and this will be a type

play03:18

of string because this is just basically

play03:19

text let's add another variable and in

play03:22

the second one will have the damage so

play03:25

basically the damage that this weapon

play03:27

will do in this case we'll go ahead and

play03:30

put a float let's do another variable

play03:32

the next one will go ahead and a b let's

play03:35

say the required level to equip it

play03:39

so required level and this will be an

play03:43

integer and then let's do the icon so

play03:45

the icon that later on the UI will

play03:47

display so the icon will go ahead and be

play03:51

a 2d texture so texture to the optic

play03:54

reference there we go let's add another

play03:56

variable and this will be the static

play03:58

mesh okay this will actually be the

play04:01

model itself that will add into the

play04:03

character later on so this will be a

play04:06

static mesh

play04:09

reference and then finally we will have

play04:13

a type okay and you will see what what

play04:16

do you mean with type well the thing is

play04:17

there there will be in a specific slot

play04:19

for

play04:21

um melee or mainly I don't know how you

play04:23

spell in English but another weapon and

play04:25

another one from ranged another one for

play04:29

um armor and then another one for

play04:31

Shields

play04:32

okay so you will not be able to equip

play04:34

for example The Sword in the ranged or

play04:38

in the shield slide you know what I mean

play04:40

so we're a bit more structure so what we

play04:42

have to do here is create an enumerator

play04:45

so basically let me show you what is an

play04:47

enumerator just right click and I

play04:50

believe it was in there under

play04:52

miscellaneous

play04:53

uh was it here

play04:55

let me just go ahead and type it so you

play04:57

can just go into whatever part on the

play05:00

pop-up and just type enumerator

play05:03

okay enumeration is under blueprints

play05:05

okay so we can just go into Blueprints

play05:07

and enumeration I didn't remember what

play05:09

it was anyway we can just name this e

play05:11

underscore and really weapon types yeah

play05:16

weapon underscore types

play05:20

there we go and weapon types okay and

play05:23

now we can open this and on here what we

play05:25

can do is start adding just three types

play05:28

so we can add any numerator and this

play05:31

will be and let's say and

play05:35

uh melee weapons

play05:39

okay then we'll add another enumerator

play05:41

this will be range weapons

play05:45

and let's say that we're gonna add

play05:46

another one which will be for the armor

play05:49

and there were another one which will be

play05:52

for the uh what was the shields

play05:56

so shoots okay so now we can save this

play06:00

and close it so now back in our

play06:03

structure we can put the type to be the

play06:06

um e underscore weapon types that we

play06:09

have just created

play06:10

that's another score

play06:13

weapon types there we go

play06:15

and now we can select it so now later on

play06:17

here you will see that for each so this

play06:19

will be like for example the values that

play06:20

will appear for each weapon okay

play06:22

individually so we'll fill up the name

play06:24

the damage the icon and so on and then

play06:27

you can see this is the thing that does

play06:30

the enumerator we can go ahead and just

play06:33

have a drop down of all the options that

play06:36

we'll have so right now these are the

play06:39

default values so we will just leave it

play06:41

like that anyway so now we can close

play06:43

this and save it

play06:45

and what we have to do is create another

play06:49

um another

play06:51

structure okay and you'll be okay

play06:54

another one yes okay this might add a

play06:57

bit of confusion into it but we will

play07:00

have another uh structure into it let's

play07:02

go again into Blueprints and it's going

play07:04

to be structure and this will be called

play07:06

s underscore slots

play07:08

and let's open this structure over here

play07:10

and basically this structure will just

play07:13

have an item okay this will be called

play07:15

item and this will be a data table row

play07:20

handle and you will see later on why we

play07:24

are making this but basically when we

play07:27

create our P cable item and also later

play07:30

on in the slots reference we can use

play07:32

directly reference a single parameter

play07:34

and then there from there start breaking

play07:38

the the values into our whole icon name

play07:42

damage Etc so it's just making things

play07:45

more organized as we will only have one

play07:47

parameter later on

play07:48

for each weapon okay so you will see

play07:51

later on how it basically goes ahead and

play07:54

works but anyway so what we have to do

play07:56

right now is create a database for our

play07:59

weapons just right click and we go into

play08:02

uh now yes miscellaneous there's gonna

play08:05

be a data table okay so now we need to

play08:09

pick the structure and in this case

play08:11

we'll be basically the S weapons okay

play08:14

not the SLS okay it will be S weapons

play08:16

let's say okay and now it's gonna be DB

play08:18

for database underscore weapons let's go

play08:22

ahead and open this one up so now

play08:25

basically we can start adding our items

play08:28

so let's add the first one let's go

play08:30

ahead and separate this a bit so we have

play08:32

it a bit more organized you know

play08:35

so it's a bit better let's just put this

play08:39

over here there we go okay so first of

play08:42

all let's change the row name and this

play08:44

will be basically uh the first item that

play08:48

we will have in our case it will be a

play08:49

simple source so I'm just gonna call

play08:51

this a sort which is pretty much I think

play08:54

that the one that you're gonna start

play08:55

it's gonna be light sword and it just

play08:57

said that it's not valid because we

play08:59

can't have any spaces so we have to put

play09:01

an underscore so that's the row name and

play09:04

that's different from the name in the

play09:06

parameters now we have to put again a

play09:09

light short on here so that's always a

play09:10

different thing so on damage we can put

play09:12

for example let's say 10 for now the

play09:14

values of damage and require level do

play09:17

you know fill it up with actual balance

play09:19

in the future

play09:20

once we have to start leveling the game

play09:22

but for now it's just kind of to range

play09:25

itself let's say the required level is

play09:27

and zero because I mean this the weapon

play09:29

that you will start with so you can

play09:32

start with level zero and then icon for

play09:35

now let's just put for example this one

play09:37

over here in the future of course it

play09:39

will have proper icons and in second

play09:41

mesh we actually have our weapon sorry

play09:44

our sword so we can just go ahead and

play09:46

select it and then types well it will be

play09:49

melee weapons great so now we can add

play09:51

another one and this will be basically

play09:52

it says we will have a heavy sword again

play09:56

again heavy sword and the Damage will be

play10:00

well let's say double 20 but the

play10:03

required level will be let's say five

play10:05

the icon let's put for example this

play10:07

green guy and starting mesh we don't

play10:10

have anything so let's put it for

play10:11

example this sphere over here and again

play10:13

it will be metal weapons let's add one

play10:15

last one which will be basically the

play10:18

um bow so basically wooden say one bow

play10:22

again wooden bow on the name on the

play10:26

damage let's say the each of the arrow

play10:28

will be will be adding five the required

play10:31

level will be two the icon will be let's

play10:34

say uh this one is like an aim for the

play10:37

arc it's perfect and then let's say that

play10:39

it will be a cone and that will be under

play10:42

the range weapon so you can see how you

play10:44

can start adding weapons and how the

play10:46

flow will start to build up so it will

play10:49

basically be like this okay so slowly

play10:52

you will be able to feel your weapon so

play10:54

we have you started with three just do

play10:56

go ahead and start up alright so now

play10:58

that we have our database instructors

play11:00

created with some value design it is

play11:02

time to actually create the item that

play11:05

will basically pick up from the tour now

play11:08

of course later in the future we'll add

play11:10

the option that it will not be necessary

play11:12

to have it in the floor and pick it up

play11:14

manually we can just you know when we

play11:16

finish a quest we can use edit or

play11:18

whatever but for now we're just gonna go

play11:20

ahead and just place it in the world so

play11:22

it's easier for us to you know figure

play11:24

out how things will work so let's go

play11:26

ahead and just right click in the folder

play11:27

and create a new blueprint class and it

play11:29

will be a nectar because it will just be

play11:31

placed in the world this will be BP

play11:33

underscore weapon let's go ahead and

play11:35

open this up great so the first thing

play11:38

that we will add into it will be

play11:40

basically a static mesh so on here

play11:42

static mesh of course later on we will

play11:45

apply the one that will be in our

play11:46

database

play11:47

so the next thing that we have to do is

play11:49

create a new variable and this will be

play11:51

the I10 data so now we compile and

play11:54

select it we can go and change the

play11:56

variable type and this will be S slots

play11:59

so yeah the one that the second one that

play12:01

we created okay

play12:02

the one they're probably confused a lot

play12:05

of you guys anyway let's go and put

play12:07

instance edit tool and expose the spawn

play12:09

so basically when we will add it into

play12:11

the world we can use select it and

play12:13

change the parameter over there you know

play12:15

what I mean anyway let's go back into

play12:18

the weapon and now we can open up the

play12:22

data and the data table will be

play12:24

basically the DB weapons and then the

play12:27

row name well this will basically be

play12:31

assigned uh later on so basically from

play12:34

our we select an item we'll be able to

play12:37

pick it up and select it so for now

play12:39

let's just say it's going to be our

play12:40

heavy sword so basically this is how you

play12:43

will select which item it is okay so now

play12:46

that we have our 18 data variable

play12:48

created we need to do is go ahead and

play12:51

assign this static mesh so what I'm

play12:54

going to do is go into the construction

play12:55

script and basically this will always

play12:58

run also in the editor so not only when

play13:02

we are basically going ahead and playing

play13:04

the game when we press play but also

play13:06

when we are just working in editor so it

play13:09

is more convenient for us to see already

play13:11

the changes when we are editing the

play13:13

world

play13:14

so we need to do is get an 8 and data

play13:16

and go ahead and split it two times now

play13:20

probably you didn't really know what

play13:21

just happened there but let me just

play13:23

explain it with a few notes so we get it

play13:25

and go ahead and call the break slots

play13:27

basically we are accessing the item so

play13:30

if you can see if we go into slots we

play13:33

only have one parameter in this case we

play13:35

are going ahead and breaking and

play13:37

accessing that specific property

play13:39

so now we can go ahead and break it

play13:41

again and we'll be able to access it at

play13:44

a table

play13:45

so we are doing this with only one node

play13:48

so it's a bit more convenient for us you

play13:50

know this is more organized in my

play13:51

opinion so now we can go ahead and get

play13:53

the raw get that at the table Row in

play13:56

singular and plug this in and then plug

play13:58

in the row name and now we're going to

play14:00

do is go ahead and break the as a

play14:04

weapons

play14:05

now as you can see we'll be able to go

play14:08

ahead and get all the properties but in

play14:10

a more organized way because we didn't

play14:12

have to go ahead because it's just saved

play14:15

in a nice variable anyway so now we're

play14:17

going to do is go and get the second

play14:19

mesh and assign it on here so let's get

play14:21

the component and then call this a node

play14:24

which is said static mesh

play14:27

put it in row found and put the study

play14:30

mesh over here and now if we compound

play14:32

save and we go here and we get our

play14:35

weapon and drag it into the scene

play14:37

you will see in some moments

play14:39

please load there we go it will update

play14:43

as you can see right now it is selecting

play14:45

the sphere because I have the heavy

play14:47

sword and it's what I have basically on

play14:49

the database as you can see but if I

play14:52

were to go ahead and change it to the

play14:53

light server

play14:55

here you can see that now we have the

play14:57

sword so basically it's going ahead and

play15:00

it's working and it's going ahead and

play15:02

depending on the item that we are

play15:04

selecting it is assigning the start

play15:07

image that we had so everything is

play15:09

really cool it's just going ahead and

play15:11

saved in a single database so we can

play15:13

change whatever values on here and

play15:15

depending on the weapon type it will go

play15:17

ahead and automatically apply all the

play15:19

changes so it is extremely modular and

play15:22

very useful for us which is exactly what

play15:25

we want so now let's go ahead and make

play15:28

that we can go ahead and pick these

play15:29

weapons and add it into our inventory

play15:31

list so later on in the future when we

play15:34

make the other episodes and start with

play15:37

the UI we can go ahead and open these

play15:40

slots and find all the weapons that we

play15:42

have in inventory and be able to drag

play15:43

them and assign them and so on so let's

play15:46

go and create a new blueprint component

play15:48

so let's go into blueprint class it will

play15:50

be an actual component basically like we

play15:52

did with this test system and also the

play15:55

attack system we'll just add this

play15:57

component into our player blueprint so

play16:00

it's a bit more organized this will be

play16:01

bpc equipment system

play16:06

let's go ahead and open this up

play16:08

great so now we need to do on here is

play16:11

create a new function and let's say that

play16:14

this will be basically add a weapon okay

play16:19

so now over here what we can do is

play16:22

create a new variable and this will be

play16:25

basically

play16:27

um in general weapon slots okay so we'll

play16:31

be able if I put the deal like this

play16:34

we'll be able to go ahead and assign

play16:36

these slots over there

play16:39

so what we need to do here is change the

play16:43

variable type to be S slots again

play16:47

and then in this case it will be an

play16:49

array if you don't know what an array is

play16:51

it's basically a list of of items so in

play16:55

case we have a list of s slots okay

play16:58

you can compile and you can see that we

play17:00

can start adding them on here but of

play17:02

course we won't add them manually it

play17:05

will be depending on which ones we pick

play17:07

in the inventory

play17:08

so what we can do right now is get the

play17:11

weapon slots and basically go ahead and

play17:13

call this function which will add an

play17:15

item and here you're gonna say well

play17:17

which item do we want to add well it

play17:20

will it will be the one that we get as

play17:22

an input so let's go ahead and hover and

play17:24

it will create a new input and this will

play17:25

be yes the uh the new item there we go

play17:28

that's the item that we want to go ahead

play17:30

and and add so there we go so now you

play17:34

can compile and save now let's go ahead

play17:36

and make a quick uh implementation here

play17:39

and it's going ahead and you know being

play17:42

able to uh pick up the weapons okay

play17:46

so let's go and create a new key for

play17:49

that so let's go into the third person

play17:51

input action right click input action

play17:56

EA underscore pick up

play18:00

in the future maybe we change actually

play18:02

yes it's going to be interact okay it

play18:04

makes more sense to call it interact so

play18:07

let's say it's going to be basically

play18:09

interact let's go ahead and open this

play18:11

and yeah I won't have to do anything

play18:14

just go back into the collection and now

play18:16

we can go ahead and add it so it was

play18:19

interact and now we can press this key

play18:21

and let's say it's going to be the E key

play18:23

save it

play18:24

and close it it's now back in here we

play18:27

can delete these two things and do the

play18:28

EA underscore interact

play18:31

it's going with them what the one with

play18:32

the arrow

play18:33

and then on here we will be able to find

play18:36

our items so we want to do is do and

play18:40

started a sphere trace and let's do by

play18:46

Channel

play18:47

okay actually no

play18:49

uh sphere trace for objects okay

play18:54

and the starting point will be basically

play18:56

the camera from the player and so on so

play18:59

actually I'm going to a DP gameplay

play19:01

and basically get the owner of this

play19:04

component

play19:05

and then go ahead and cast to the third

play19:08

person catcher so here we'll be able to

play19:11

access our pens which is the third

play19:13

person cut blueprint and basically

play19:15

access the the camera

play19:18

over here so scroll down and you will

play19:20

see here it is full camera

play19:22

so let's go ahead and right click and

play19:23

promote this to a variable so we have it

play19:25

as a variable so now

play19:28

I'm here later on

play19:30

let's get pick up trace it will be able

play19:35

to supply our preset so just go ahead

play19:38

and just get the full camera

play19:40

use it as a variable so now this will be

play19:43

the get weld location

play19:45

okay because I mean we want to go ahead

play19:48

and as the starting point and then in

play19:51

default camera gets the rotation and

play19:53

again the world rotation in this case we

play19:55

want to get the forward Vector because

play19:57

we want to get the direction at which

play19:59

the camera is looking in front of it and

play20:02

we want to multiply this by right click

play20:05

over here commit to pin into Float by

play20:07

the distance so let's say it's going to

play20:08

be a thousand for now okay we'll be able

play20:10

to pick up items very far away this kind

play20:13

of temporary now we'll go ahead and get

play20:15

the word location and add it with the

play20:18

direction so now this will give us the

play20:21

end point the rate is going to be for

play20:22

example 15 something like that and then

play20:25

for object types we'll make an array in

play20:28

this case will be basically uh

play20:31

was upon both Dynamic Maybe

play20:34

we'll see which one it is the one that

play20:37

we want and basically let's say it's

play20:40

going to be for duration so you can just

play20:42

spray it real quick and if we have

play20:44

basically hit something we will go ahead

play20:47

and break the result

play20:50

and now we want to do is go ahead and

play20:54

get the hit actor and cast to the weapon

play20:59

that we have just created now in this

play21:00

case I don't think it's necessary to

play21:02

create an interface because in this case

play21:04

it's specifically in the equipment

play21:06

system to only pick up the actual

play21:09

weapons so for now really there's no

play21:11

need to create an interface now later on

play21:13

we will definitely go ahead and increase

play21:15

and interact interface for other things

play21:17

like opening doors or whatever if we do

play21:19

so a test in the future I don't know uh

play21:22

we'll be seeing but yes for this weapon

play21:24

type I think it's better just to cast

play21:26

directly

play21:27

and that's pretty much it we need to go

play21:30

ahead and get the um the eight and item

play21:34

data no item no a Titan there and now

play21:37

you can just go and get the I add weapon

play21:39

function

play21:40

that we just did create and then pass

play21:42

the new item so it will just go ahead

play21:44

and add this new item into our inventory

play21:48

and this should go ahead and work okay

play21:51

so let's go ahead and add this component

play21:54

into our player character let's go into

play21:56

third person Blueprints and open this up

play21:58

and I'm going to components and add the

play22:01

bpc underscore equipment system press

play22:04

enter we don't have to change anything

play22:06

over here just compile and save and I

play22:08

can close this and press play so now

play22:11

we'll press e you can see that we'll be

play22:13

creating a line Trace to pick up the

play22:15

items that we have in front well it's a

play22:17

screw tray so we have like more area to

play22:20

pick it up it's easier so now if we go

play22:22

here at least you'll be able to pick it

play22:24

up as you can see it's detecting the

play22:25

object so what you need to do is go

play22:28

ahead and also let's say that we need to

play22:30

destroy this specific item so let's go

play22:33

ahead and destroy the actor so we get an

play22:36

um you know a feeling that we have just

play22:38

picked up from the floor and we is not

play22:41

just going ahead and duplicating itself

play22:43

or something like that and then also

play22:46

let's go ahead and print uh basically

play22:49

item gathereds on that item gathered

play22:53

gathered

play22:56

I don't know whatever right I use a

play22:59

print to have feeling that we have paid

play23:02

that something so now I'm here we can go

play23:04

and pick it up you can see item gathered

play23:06

here now let's go ahead and check that

play23:09

it is actually going ahead and adding

play23:11

properly

play23:12

into our uh array of items into our

play23:17

inventory pretty much I mean you could

play23:19

really rename this into mentoring but I

play23:20

just prefer to name a weapon so that's

play23:22

for now I think it's just more

play23:24

convenient but let's go ahead and just

play23:26

add a new custom event

play23:30

so for example when we press h okay the

play23:34

bug this basically to just debug it okay

play23:37

just to see which items we have in the

play23:39

mentor because right now we don't have

play23:40

any UI to display it and in this episode

play23:43

we are not building that so we will go

play23:46

ahead and just press h and see a list of

play23:49

all the items that we have real quick uh

play23:51

of Prince just do us to see if it's

play23:53

working okay this is just debug type so

play23:55

we can do is just go ahead and and get

play23:58

the weapon slots

play24:00

okay and then do a for each Loop so it

play24:03

will go ahead and go through all the

play24:05

array of items and on here we're going

play24:07

to split it and split it again and we

play24:11

can just go ahead and print this row

play24:13

item so we can just go ahead and say

play24:14

print

play24:15

and I'll pass this row and now it will

play24:18

go ahead and print the row now make sure

play24:20

that like this is just printing the row

play24:24

not the item property okay so make sure

play24:26

that you also have assigned the row name

play24:29

as also the name so this is the the name

play24:31

as a property and this is the row name

play24:33

so there are different things but you

play24:34

have to also name the two so make sure

play24:37

anyway so now I picked this up and then

play24:40

press what was H you can see that I have

play24:43

light sort ordered in the top left

play24:45

corner let's just go ahead and make the

play24:48

print

play24:49

I close the other things uh duration

play24:52

let's say five and then also if I

play24:56

duplicate this object and then change

play24:58

the icon type to be heavy sword for

play25:02

example and this huge I'm gonna rescale

play25:04

it

play25:05

um and then also duplicate this and put

play25:08

it as the wooden boat and make it a bit

play25:10

bigger okay you can see that now I can

play25:13

go ahead and pick up all the different

play25:16

items over here and then item gather

play25:18

item gathered and then press

play25:21

um was H and you can see here wooden bow

play25:23

heavy sword and light sword so it is

play25:26

going ahead and working we are being

play25:28

able to pick up different Isis bullet

play25:30

floor added to an inventory and then we

play25:32

we can change it at any time because of

play25:36

our database and at the table and change

play25:38

it properties great so if you found it

play25:40

so helpful a really cheap if you could

play25:42

like the video and subscribe to my

play25:44

channel I have lots of Unreal Engine 5

play25:45

throws so when I go ahead and check them

play25:47

out go ahead

play25:49

join my Discord server so you can ask

play25:51

any questions about the series or in

play25:53

general about mu engine and show your

play25:55

progress and your work and so on and

play25:58

talk with other developers as me and

play26:00

follow me on my soldiers such as Twitter

play26:02

and Instagram so yeah in the next

play26:03

episode then we'll begin with a UI

play26:06

adding these slots and be able to select

play26:08

them probably we'll see how it goes

play26:10

depending on how the episodes last but

play26:14

with all I said bye bye

play26:17

foreign

play26:22

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
Unreal Engine 5RPG装备系统数据库UI界面游戏开发教程角色定制3D模型游戏设计
Do you need a summary in English?