How To Make a DOOM CLONE in Unity || E1M7 Basic UI

SpawnCampGames
2 Jun 202117:51

Summary

TLDR本视频教程介绍了如何为Doom克隆游戏创建用户界面(UI)。首先,在Unity中创建一个新的UI Canvas,并设置为随屏幕尺寸缩放。接着,添加背景和健康指示器等UI元素,并使用锚点预设来调整它们的位置和大小。教程还涵盖了如何使用Text Mesh Pro创建自定义字体文本,并为UI元素编写脚本以实现动态更新。通过创建一个Canvas Manager脚本来管理UI元素的引用,并使用Singleton模式确保脚本可以在游戏的其他脚本中轻松访问。最终,通过在游戏脚本中调用Canvas Manager来更新UI,确保UI与游戏状态同步。

Takeaways

  • 🎮 创建了一个名为'playerui'的UI画布,用于Doom克隆游戏的界面设计。
  • 🔧 设置了UI的缩放模式,使其能够根据屏幕尺寸进行调整,并设置了参考分辨率1920x1080。
  • 🖼️ 在UI中创建了背景图像,并调整了其大小和锚点,以适应不同分辨率。
  • 👤 为游戏中的'Doom Guy'创建了四个不同的面部表情精灵,并将其设置为2D UI纹理。
  • 💊 创建了健康指示器UI图像,并设置了其大小和位置,用于显示玩家的生命值。
  • 🔑 创建了钥匙指示器和子图像,用于显示玩家收集的钥匙数量和类型。
  • 📜 使用了自定义字体,并利用Text Mesh Pro创建了UI文本,用于显示弹药、健康和护甲信息。
  • 🔄 设计了一个UI管理器脚本,用于统一管理UI元素的更新,而不是每个脚本单独更新。
  • 🔑 实现了通过脚本控制UI元素的显示,如根据玩家状态更新角色的面部表情和钥匙指示器。
  • 🔧 通过Singleton模式简化了对UI管理器的访问,使得其他脚本可以方便地调用UI管理器的功能。
  • 🛠️ 在Unity中对脚本进行了测试和调试,确保UI元素能够正确反映玩家的状态变化。

Q & A

  • 在Unity中创建UI Canvas的第一步是什么?

    -在Unity的层级结构中创建一个新的UI Canvas,并暂时命名为playerUI。

  • 如何设置UI Canvas以适应不同屏幕尺寸?

    -设置UI Canvas的Scale Mode为Scale With Screen Size,并设置参考分辨率,例如1920x1080。

  • 如何将2D精灵设置为UI图像?

    -将精灵拖入UI Canvas中,然后更改其Texture Type为2D UI。

  • 如何调整UI元素的位置和大小?

    -使用锚点预设(Anchor Presets)来调整UI元素的位置和大小,可以通过同时按住Shift和Alt键来同时改变锚点和位置。

  • 如何创建健康指示器UI图像?

    -在player canvas中创建一个新的UI图像,并命名为健康指示器(health indicator),然后使用锚点预设进行定位和调整大小。

  • 如何为UI添加自定义字体?

    -首先创建一个名为font的新文件夹,将下载的.ttf字体文件拖入其中,然后在Text Mesh Pro中使用Font Asset Creator生成字体图集。

  • 如何使用Text Mesh Pro创建UI文本?

    -在UI中创建一个新的UI Text Text Mesh Pro,设置字体资产,并使用Wreck Tool调整大小和位置。

  • 如何更新UI文本元素的值?

    -创建一个UI管理器(Canvas Manager)脚本,该脚本持有对每个文本元素的引用,并在其他脚本中调用UI管理器的更新函数来更新值。

  • 如何实现UI管理器的单例模式?

    -在Canvas Manager脚本中声明一个私有静态Canvas Manager实例,并提供一个公共静态实例访问器,确保全局只有一个UI管理器实例。

  • 如何通过脚本更新玩家的生命值、护甲和弹药?

    -在玩家健康、护甲和弹药相关的脚本中调用Canvas Manager的updateHealth、updateArmor和updateAmmo函数,并传递相应的值。

  • 如何在游戏中更新和重置钥匙的UI显示?

    -使用Canvas Manager的updateKeys函数来更新钥匙UI的显示,并使用clearKeys函数来重置所有钥匙的状态。

Outlines

00:00

🎮 创建Doom克隆游戏的UI界面

视频教程介绍了如何为Doom克隆游戏创建用户界面(UI)。首先,在Unity的层级结构中创建一个新的UI Canvas,并命名为playerui。设置缩放模式以适应屏幕尺寸,并设置参考分辨率为1920x1080。在Canvas内部,创建一个新的UI Image作为背景,并在项目中新建一个UI文件夹,将背景和Doom角色的四个表情精灵拖入其中。接着,更改纹理类型为2D UI,并设置背景图片的锚点和大小,调整颜色。然后,创建健康指示器UI Image,并设置其颜色和位置。此外,还创建了一个空对象作为钥匙指示器,并为其添加子图像,使用与钥匙拾取相同的精灵,并设置锚点和大小。最后,介绍了如何使用Text Mesh Pro创建自定义字体的UI文本,并调整其位置、大小和颜色。

05:04

🖌️ 完善UI设计并实现UI管理脚本

继续UI设计,教程中介绍了如何复制弹药文本并修改为健康值显示,并添加百分比符号。通过复制健康文本来创建护甲显示,并调整其在UI中的位置。创建UI管理器脚本以简化各脚本对UI元素的更新操作,避免每帧检查,而是在值变化时通知UI管理器更新。定义了Canvas Manager脚本,其中包括公共变量如健康、护甲、弹药的Text Mesh Pro UI、健康指示器Image以及钥匙的GameObject。在Unity中分配这些变量后,编写更新健康、护甲、弹药值的方法,以及更新Doom角色精灵和钥匙激活状态的函数。还实现了一个单例模式,以便其他脚本可以轻松访问Canvas Manager。

10:04

🔧 脚本编写与UI更新逻辑

本段介绍了如何在Canvas Manager脚本中编写具体的更新逻辑。详细说明了如何根据健康值更新健康指示器的精灵,并根据健康值的不同显示不同的Doom角色表情。同时,也展示了如何更新弹药和护甲的文本显示。对于钥匙的更新,通过传入键的颜色来激活相应的钥匙UI,并提供了一个清除所有钥匙的函数。此外,还讨论了如何将Canvas Manager集成到其他脚本中,例如玩家健康脚本和玩家库存脚本,以及如何调用更新函数来反映游戏状态的变化。

15:06

🔄 测试UI功能并修复问题

在完成UI脚本编写后,教程进入了测试阶段。测试中发现弹药和护甲在游戏开始时没有正确更新,因此对枪械脚本和玩家健康脚本进行了修改,确保在游戏开始时调用相应的Canvas Manager更新函数。经过修正,测试显示弹药、护甲、钥匙拾取以及角色受到伤害时的UI更新均能正常工作。视频最后表示期待在接下来的视频中进一步开发游戏玩法,并结束了本教程。

Mindmap

Keywords

💡UI

UI,即用户界面,是人与计算机系统交互的图形界面。在视频中,UI用于创建游戏《毁灭战士》的克隆版本,是游戏的重要组成部分,用于展示玩家的状态信息,如生命值、弹药和钥匙数量等。例如,创建'playerui' UI Canvas,以及健康指示器和弹药计数器等元素,都是UI设计的一部分。

💡Unity

Unity是一个广泛使用的跨平台游戏开发引擎,支持开发者创建2D和3D游戏。视频中提到的Unity用于构建游戏界面和脚本,如创建UI Canvas和编写Canvas Manager脚本。Unity的UI系统允许开发者设计和实现游戏的用户界面,使其适应不同的屏幕尺寸和分辨率。

💡Canvas

在Unity中,Canvas是一个渲染表面,用于显示UI元素。Canvas可以包含图像、文本、按钮等UI组件。视频中,'playerui' Canvas是用于展示玩家信息的主要UI元素,它通过锚点和位置调整来适应不同的屏幕大小。

💡Anchor Presets

锚点预设是Unity UI系统中用于快速设置UI元素对齐方式的工具。通过锚点预设,开发者可以轻松地将UI元素对齐到Canvas的边缘或角落。视频中,使用锚点预设来调整背景、健康指示器和钥匙指示器的位置和大小。

💡Sprites

精灵(Sprites)是2D图像或动画,常用于游戏中表示角色、物品或环境。视频脚本中提到了使用精灵来创建背景和角色的生命值指示器。例如,使用'doom guy'的四个面部精灵来表示角色的不同生命状态。

💡Text Mesh Pro

Text Mesh Pro是Unity的一个流行的文本渲染插件,它提供了比Unity默认UI文本更高级的文本渲染功能。视频中,开发者使用Text Mesh Pro创建了弹药、健康和护甲的文本显示,并通过调整字体、大小和颜色来集成到游戏UI中。

💡Singleton

Singleton是一种设计模式,确保一个类只有一个实例,并提供一个全局访问点。在视频中,Canvas Manager使用Singleton模式,使得其他脚本可以轻松地访问和更新UI元素,而无需每个脚本都持有对UI组件的引用。

💡Script

在Unity中,脚本是附加到游戏对象上的C#代码文件,用于定义对象的行为。视频中,开发者编写了多个脚本,如Canvas Manager、Player Health Script和Gun Script,用于控制UI更新、玩家生命值和弹药管理等。

💡Key Indicator

钥匙指示器是游戏中用于显示玩家当前拥有的钥匙数量的UI元素。在视频脚本中,开发者创建了一个名为'key indicator'的空GameObject,并在其下创建了代表不同颜色钥匙的图像,用于指示玩家收集到的钥匙。

💡Health Indicator

健康指示器是游戏中用于展示玩家生命值的UI组件。视频中,健康指示器通过一个图像组件实现,该图像会根据玩家的生命值变化而改变,使用不同的'doom guy'精灵来表示不同的生命状态。

Highlights

创建Doom克隆游戏的用户界面(UI)。

在项目中创建一个新的UI Canvas并命名为playerui。

设置UI Canvas的缩放模式以适应屏幕尺寸,并设置参考分辨率。

创建UI图像用作背景,并调整其锚点和大小。

创建并配置健康指示器UI图像。

创建空对象作为键指示器,并添加子图像表示不同颜色的钥匙。

使用自定义字体创建UI文本元素。

使用Text Mesh Pro创建弹药、健康和护甲的文本显示。

创建Canvas Manager脚本来管理UI元素的更新。

使用单例模式让其他脚本能够轻松访问Canvas Manager。

在Player Health脚本中更新健康、护甲和弹药的显示。

在Player Inventory脚本中初始化键的状态,并在获取钥匙时更新UI。

在Gun脚本中更新弹药计数并在游戏开始时初始化。

在Key Pickup脚本中根据钥匙颜色更新UI。

修正游戏开始时弹药和护甲未正确更新的问题。

完成UI的测试,确保所有元素如预期工作。

计划在未来的视频中进一步开发游戏玩法。

Transcripts

play00:02

spinecamp here today we're going to make

play00:04

a ui for our doom clone

play00:06

and write a script to tie it all

play00:07

together so on our project the first

play00:09

thing we're going to do is go to the

play00:10

hierarchy and we're going to create a

play00:12

new ui canvas

play00:14

and we'll name it playerui for now we

play00:16

can go into our 2d mode while we lay

play00:18

this out

play00:20

but before we go any farther let's make

play00:21

the scale mode scale with screen size

play00:24

and put in your reference resolution

play00:27

mine is 1920 by 1080.

play00:30

and inside we'll create a new ui image

play00:33

to start off

play00:35

and let's name it background so let's go

play00:38

back to our sprites folder of our

play00:40

project

play00:40

and i create a new folder for my ui

play00:42

called ui

play00:43

and i'm ready to drag in my sprites i

play00:45

have a background and four face sprites

play00:47

of the original doom guy

play00:49

so once they're all in here we can

play00:50

select them and change our texture type

play00:53

to 2d

play00:53

ui

play00:56

and hit apply

play01:00

and on the background that we just

play01:01

created let's go ahead and drag in our

play01:03

sprott in the source image

play01:06

and untick raycast target so now we can

play01:08

fix the position

play01:09

and size of this thing by using the

play01:11

anchor presets here at the top

play01:13

i'm going to hold shift and alt to

play01:15

change his anchor and position at the

play01:17

same time and i'm going to click

play01:18

this icon and it's going to stretch it

play01:20

across the bottom and anchor it at the

play01:22

bottom

play01:23

to fix the height we're going to take a

play01:25

peek at the background image

play01:27

and we'll see here there's 224 pixels so

play01:30

we can go back to the background

play01:31

inspectors

play01:32

and change the height manually to 224

play01:38

i think this is a bit too bright so

play01:40

let's just change the color

play01:41

a little bit good good

play01:45

so let's create another ui image in our

play01:47

player canvas

play01:48

and this will be called the health

play01:49

indicator and the anchors i'll again use

play01:52

shift and alt but this time i'm going to

play01:54

anchor it without stretching

play01:55

and i'm going to zoom in and we're going

play01:57

to adjust the size

play02:01

and then the position

play02:06

we're going to set the color to black

play02:08

for now

play02:14

so now we're going to create an empty

play02:17

and this is going to be called

play02:18

key indicator we're gonna hold shift and

play02:22

alt

play02:22

and we're gonna anchor this to the

play02:24

bottom right corner

play02:26

and then we're gonna take our move tool

play02:28

and move it

play02:29

to the center of where we want our keys

play02:33

so now as a child of the key indicator

play02:36

we'll create a new image

play02:37

and we're going to call this blue we're

play02:39

going to move it up

play02:41

to about the top position here and then

play02:43

we'll resize it to something that looks

play02:45

right

play02:45

and for the source image of this image

play02:47

we're going to use

play02:49

the same sprite that we used for the key

play02:50

pickups so let's go find those in our

play02:53

project

play02:53

and drag it in then we want to uncheck

play02:56

brake as target

play02:57

and before i forget let's go and do the

play02:59

same thing to our health indicator

play03:02

and then we can make the other two keys

play03:04

the same way

play03:06

we'll make a green key and then we'll

play03:09

make a red key

play03:11

and once we get all the keys made we can

play03:12

go ahead and select them all

play03:17

disable them all

play03:25

so now that our images are set up let's

play03:26

go ahead and work on our text

play03:28

and we'll also be using a custom font

play03:31

i'm going to create a new folder for our

play03:32

font called font

play03:34

and i'm going to drag in this dot ttf

play03:36

file that i downloaded for free

play03:38

the links in the description now we need

play03:39

to go up to windows

play03:41

and go to our text mesh pro click the

play03:44

font

play03:44

asset creator so if this is the first

play03:47

time with text mesh pro in your project

play03:48

you'll need to

play03:49

import the essentials then we'll need to

play03:51

select our font

play03:52

for our source font file and then we're

play03:55

going to click

play03:56

generate font atlas and then after that

play03:59

we'll hit save

play04:00

we'll make sure that this is in our font

play04:02

folder

play04:04

and we're ready to use it so in our ui

play04:07

we'll create a new ui

play04:11

text text mesh pro

play04:15

and name it ammo we'll be working left

play04:18

or right so first off we'll hold shift

play04:19

and alt

play04:20

and we'll select the bottom left from

play04:22

our anchor preset tool

play04:26

and move it into position

play04:33

in the inspector we select our new font

play04:35

for the font asset

play04:41

and use our wreck tool to resize this a

play04:43

bit

play04:46

next i'll change the text to 100

play04:49

and i'll mess with the size 72 seems

play04:52

good

play04:55

and i'll be aligning it to the right

play04:57

side

play05:03

and line this up to the center

play05:08

and then i'll mess with the color a bit

play05:10

to get it to fit with the ui better

play05:17

now we need health so let's just

play05:18

duplicate our ammo and name it health

play05:21

the rest are going to be percentages so

play05:23

to get our text centered let's go ahead

play05:24

and add a percent to the end

play05:26

we'll then align this in our health

play05:28

section of the ui

play05:31

and then we'll duplicate the health and

play05:32

you sit for our armor

play05:34

and now since this is closer to the

play05:36

right side of our screen

play05:38

we'll use the anchor presets and while

play05:40

holding shift and alt

play05:42

we'll align this to the bottom right

play05:46

now we can align this in the armor

play05:47

section of our ui i'm just going to

play05:49

check one of the other texts that we

play05:50

just made

play05:51

and find out what the y position is to

play05:53

make sure this is straight

play05:58

and with our anchors correctly set we'll

play06:00

see that if we go into play mode

play06:01

and mess around with our aspect ratio

play06:04

that you'll see that our ui scales

play06:06

accordingly

play06:08

[Music]

play06:11

now we have a ui canvas and we also have

play06:13

our player who has these scripts

play06:15

we could have each script change the

play06:17

value for each text element

play06:19

but we'll use a ui manager instead that

play06:21

will hold a reference to each of these

play06:23

text elements

play06:24

now we could have the ui manager check

play06:26

each script every frame but it's better

play06:28

to only update our values when we need

play06:30

to

play06:30

so instead we'll have each script tell

play06:32

the ui manager when it's changed

play06:34

and it will update the correct value for

play06:36

us

play06:38

so with that in mind i'll select my

play06:40

player ui canvas and add a

play06:42

new component this will be a script

play06:44

called something like

play06:45

canvas manager and we'll hit enter twice

play06:47

and double click it to open it in visual

play06:49

studio

play06:51

to begin with we only need the use in

play06:53

unity engine statement

play06:54

and we'll add unity engine.ui

play07:00

and tm pro for our text mesh elements

play07:04

now we can get rid of everything inside

play07:06

the class and we'll start fresh

play07:08

let's get all our variables ready to use

play07:10

we'll need a public text

play07:12

mesh pro ugui called health

play07:18

and two more for our armor and ammo

play07:22

we'll need a reference to our health

play07:24

indicator where our little doom guy's

play07:26

face is going to be

play07:27

so we'll use public image health

play07:29

indicator

play07:36

and we'll need the sprotts that we're

play07:38

going to use for it so public sprott

play07:40

health 1

play07:46

health 2 health 3 and health 4.

play07:51

we'll start with health 1 being our full

play07:53

health

play07:54

lastly we'll need our keys that we set

play07:55

up and disabled

play08:00

we'll just use public game objects here

play08:02

and have one for red

play08:03

blue and green

play08:07

before we go into the logic we'll save

play08:09

the script and go into unity

play08:11

and we'll assign all these variables

play08:13

[Music]

play08:15

so i'm going to just drag in our health

play08:17

armor and ammo text

play08:19

elements and our health indicator is

play08:22

next

play08:24

next we'll expand out our key indicator

play08:26

and grab our keys

play08:27

and assign them finally we need our

play08:31

health sprites

play08:32

and these won't be in the project so

play08:34

instead we'll just drag our sprotts that

play08:36

we imported earlier from our project

play08:38

window

play08:41

so health 1 was our healthy doom guy

play08:43

health 2 was our hurt doomed guy held 3

play08:46

a little bit more hurt and 4 would be

play08:48

dead and before we jump back into the

play08:52

script and i forget we need to select

play08:54

the health indicator

play08:55

and change the color back to white for

play08:57

doom guy sprites to

play08:59

show properly now back in the script we

play09:01

need some methods to update our values

play09:06

first we'll have a public void update

play09:09

health and

play09:11

we'll pass in an integer called health

play09:13

value as the argument

play09:18

now we'll need two more of these for

play09:20

updating our armor and our ammo

play09:22

and we'll call the ins here armor value

play09:26

and ammo value now we need a function

play09:28

for updating our doom guy sprite so

play09:30

we're going to say public void

play09:32

update health indicator and this time

play09:34

with no arguments

play09:38

and finally one last function

play09:42

called public void update keys

play09:52

now back in our update health

play09:56

we'll set our health dot text equals the

play09:58

health value we get

play10:00

and we need to convert it to a string

play10:02

with dot to string

play10:03

then we'll plus percentage sign in

play10:06

quotations

play10:07

to take it on to the end and then if our

play10:10

health ever changes we need to check

play10:12

our health sprites by calling the update

play10:14

health indicator function

play10:19

now we'll set our armor text the same

play10:21

way inside the update armor function

play10:28

with the armor value and then again for

play10:31

our ammo function

play10:32

only this time we can get rid of the

play10:34

plus parentheses

play10:37

so in our update health indicator

play10:39

function i lied because we're going to

play10:40

need an argument

play10:42

so up in the update health we're going

play10:43

to pass the health value into this

play10:45

function and back at the actual function

play10:47

we'll grab this by adding

play10:48

int health value as an argument

play10:52

we use if statements to change the

play10:54

sprott and since there's only three

play10:55

sprouts where the player is alive we'll

play10:57

split 100 into thirds

play10:58

so our first statement is if health

play11:00

value is greater than

play11:02

equal to 66 then we set the health

play11:04

indicator dot sprite to equal our health

play11:06

one sprout

play11:17

if health value is less than 66 and the

play11:19

health value is greater than or equal to

play11:21

33 then we'll set it to be

play11:23

our health 2 sprite and if it's less

play11:25

than 33 and greater than zero

play11:29

then it's our health three spot

play11:34

and if somehow it's less than zero well

play11:36

you're dead and our sprout should be

play11:38

health four

play11:42

now we'll finish out the functions we

play11:44

need with the update keys

play11:45

and here i also decided to pass in

play11:47

something we can use so as an argument

play11:49

we'll use a string

play11:51

called key color and inside the function

play11:53

it'll be pretty simple with

play11:55

f key color equals red

play12:03

then set our red key game object to be

play12:05

active with dot set active true

play12:12

and we can do the exact same thing for

play12:14

the other keys

play12:28

and here you'll see me adding a extra

play12:30

function called clear keys

play12:31

which sets them all to false and this

play12:34

would be used

play12:35

to reset the keys say at the start of a

play12:37

new level

play12:40

now this is basically the completed ui

play12:42

script it'll do everything we needed to

play12:44

do but we need a way to easily access it

play12:46

from our other scripts

play12:48

and i don't want to need a reference for

play12:49

each script so here i'm just going to

play12:51

write out a basic singleton

play12:55

we'll declare a private static canvas

play12:58

manager named underscore instance

play13:04

and a public static one called capital

play13:06

instance

play13:13

with open bracket get open bracket

play13:16

return underscore instance and

play13:22

close off those brackets and we'll need

play13:24

an awake

play13:29

where we ask if underscore instance is

play13:31

not null

play13:32

and it's not this

play13:38

so we're saying if it exists and it

play13:40

isn't this one then we'll destroy this

play13:42

one

play13:47

else it does exist and it is this one so

play13:49

we'll set the underscored instance to

play13:51

equal this

play13:53

now we can save our script and go back

play13:55

into unity to get the rest of our

play13:56

scripts to communicate with it

play13:59

we'll navigate to the player and the

play14:01

first script that i'll edit is our

play14:02

player health script

play14:06

we're going to go up here and find our

play14:09

start function and we'll say

play14:14

canvasmanager.instance.updatehealth

play14:15

health

play14:16

we'll pass in our health now we can find

play14:18

where our player takes damage

play14:20

and at the very bottom of this function

play14:23

after all the logic is ran

play14:27

we'll say canvas manager.instance

play14:30

again and we'll pass in our health

play14:38

and i just realized in this function

play14:39

where we take damage we could also be

play14:42

taking damage to our armor

play14:43

so we also want to call

play14:48

canvasmanager.instance.updatearmor and

play14:49

pass in our armor

play14:58

now at the very bottom of our give

play15:00

health function we're going to update

play15:02

our health

play15:05

and then at the very bottom of the give

play15:07

armor function

play15:08

we're going to update our armor

play15:17

now we can save that script and back in

play15:19

unity we'll hop into our player

play15:20

inventory next

play15:24

we'll create a start function because at

play15:26

the beginning of this script we want to

play15:27

call the last function that we made in

play15:29

our canvas manager to clear the keys

play15:31

and our key pickup is what actually

play15:33

modifies the script anyway so we'll

play15:35

update our key ui

play15:37

and the actual key pickup so save this

play15:39

script and it's finished

play15:41

next we'll update the ammo and for this

play15:43

it's pretty simple because we only have

play15:45

one gun for now

play15:46

so we'll open our gun script we'll find

play15:48

where we deduct the ammo

play15:49

and call the update ammo function

play15:52

and pass in the ammo and we'll also need

play15:55

to update it when we're given ammo so at

play15:57

the bottom

play15:58

of our give ammo function we can save

play16:01

that

play16:01

and back in unity finally we'll update

play16:03

the keys by going and finding our key

play16:05

pickup script

play16:11

so once it's open we can use

play16:14

canvasmanager.instance.updatekeys

play16:16

and it's asking for our key color so now

play16:18

we'll just use a string

play16:19

so for red we'll just use red

play16:23

and if is blue key we'll use the same

play16:26

method but we'll pass in blue

play16:28

and then we'll do green for green

play16:33

save that and we can go back into unity

play16:35

i'm going to collapse the ui because

play16:37

we're done with it i think

play16:42

and i'm going to go out of 2d mode and

play16:44

if i'm correct we can just scatter

play16:46

around the prefabs

play16:48

and everything should work

play16:53

well everything doesn't work it appears

play16:57

our ammo is not updated

play16:58

when the game starts so let's go up here

play17:00

and in our start

play17:02

function of our gun script we're going

play17:04

to go ahead and call that ammo function

play17:06

in our canvas manager

play17:10

so we can save that the next thing i

play17:13

noticed was our armor wasn't getting

play17:15

updated so

play17:16

we'll go into our player hell script and

play17:18

also in the start function

play17:20

here we're gonna update our armor as

play17:22

well as our health

play17:24

we can save that script then after those

play17:27

two mistakes are fixed we can go

play17:28

and play test and you'll see that

play17:31

everything's working our ammo

play17:33

our armor our key pickups and with our

play17:36

hotkey we can damage the player and see

play17:38

that our sprott

play17:39

is being updated accordingly so with the

play17:42

ui out of the way i look forward into

play17:44

getting into some more gameplay

play17:45

in the next few episodes so that's all i

play17:48

got

play17:48

spawn camp out

Rate This

5.0 / 5 (0 votes)

Related Tags
UI设计游戏开发毁灭战士Unity3D脚本编写界面布局玩家界面游戏教程视觉设计互动体验
Do you need a summary in English?