Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:03,460 --> 00:00:07,600
Now we want some way to actually see what this damage is doing to our character.
2
00:00:07,840 --> 00:00:15,190
So in the mobile game resources, you'll find a graphic health bar just going to add this to our canvas.
3
00:00:15,640 --> 00:00:25,300
Just right click Jujuy and new image drag elfa into the source image and click certain ATSIC.
4
00:00:26,830 --> 00:00:30,400
This one is not a rakas target because we don't need to interact with it.
5
00:00:30,790 --> 00:00:36,310
But instead of its image type being simple, we're going to make this one filled image and to change
6
00:00:36,310 --> 00:00:38,380
its fill method to horizontal.
7
00:00:39,040 --> 00:00:42,250
And you'll now see that the full amount can be regulated.
8
00:00:42,700 --> 00:00:45,790
I actually want it to go from the right instead.
9
00:00:46,270 --> 00:00:53,740
OK, so it can go can do this and we can actually manipulate this in the code by using this fill amount
10
00:00:54,010 --> 00:00:54,700
variable.
11
00:00:55,990 --> 00:00:59,230
OK, first of all, I just need to position this somewhere on the screen.
12
00:00:59,230 --> 00:01:01,000
So I'm going to choose the top.
13
00:01:01,000 --> 00:01:01,630
Right.
14
00:01:06,290 --> 00:01:08,180
And it's not an item that we need to click on.
15
00:01:09,530 --> 00:01:15,980
However, I still recommend that you change type just to see where it is on all the different pieces.
16
00:01:15,980 --> 00:01:18,260
As you can see there, it's basically been excluded.
17
00:01:18,980 --> 00:01:23,870
Well, I want to make sure that it is targeted to the top right.
18
00:01:24,380 --> 00:01:32,720
And then I simply just want to drag this over a little bit until it fits nicely in the corner.
19
00:01:36,290 --> 00:01:41,480
We get that as close as I can to the corner and then that way on other systems.
20
00:01:43,400 --> 00:01:45,500
It shouldn't be too far away from the edge.
21
00:01:45,540 --> 00:01:50,930
Now, as you can see there on the Apple iPhone, and it's being cut off.
22
00:01:50,930 --> 00:01:55,640
So I just need to check it on each of the devices.
23
00:01:59,050 --> 00:02:00,370
Yeah, that's OK.
24
00:02:01,990 --> 00:02:03,100
It's perfectly fine.
25
00:02:07,300 --> 00:02:13,480
Feel free to go through absolutely every one of them, but I should imagine at the moment this is pretty
26
00:02:13,480 --> 00:02:13,750
good.
27
00:02:19,380 --> 00:02:20,430
It's a really long film.
28
00:02:26,250 --> 00:02:26,580
Right.
29
00:02:26,730 --> 00:02:28,590
OK, so it looks fine on all of them.
30
00:02:29,270 --> 00:02:32,100
Great, I'll just go back to Samsung Galaxy J7.
31
00:02:32,720 --> 00:02:36,240
That's that's one that kind of looks very generic.
32
00:02:37,170 --> 00:02:37,650
Excellent.
33
00:02:37,770 --> 00:02:42,170
OK, so let's change the name of this to help.
34
00:02:43,980 --> 00:02:50,360
Whenever we want to access, for example, in the components that are on a UI element in the script,
35
00:02:50,370 --> 00:02:53,610
we do need to tell it that we are accessing UI.
36
00:02:53,850 --> 00:03:02,100
So if we go back into the main script right at the top, we do now need to say using unity engine dot
37
00:03:02,220 --> 00:03:02,730
UI.
38
00:03:07,100 --> 00:03:13,700
Not way I get access to that image, OK, so I'll just leave myself in another comment.
39
00:03:13,820 --> 00:03:17,360
So health bar.
40
00:03:19,130 --> 00:03:24,710
So this is going to be a public health type image for health bar.
41
00:03:28,820 --> 00:03:34,730
In fact, it doesn't need the capital be there, so just one word health bar, OK, and then I need
42
00:03:34,730 --> 00:03:36,020
some kind of a damage amount.
43
00:03:36,050 --> 00:03:37,490
It's going to take place each time.
44
00:03:37,490 --> 00:03:39,200
One of the animals hit me, it's me.
45
00:03:39,830 --> 00:03:41,600
So I'll make that a public float.
46
00:03:42,200 --> 00:03:44,210
Old damage amount's.
47
00:03:45,500 --> 00:03:48,350
I'll probably make that about zero point zero five.
48
00:03:50,240 --> 00:03:51,230
Now, it's right at the moment.
49
00:03:51,360 --> 00:04:00,200
It does need an F on the end, and the actual fill amount only goes between zero and one.
50
00:04:00,710 --> 00:04:04,700
So if you got a value greater than one, that will instantly be filled.
51
00:04:05,510 --> 00:04:11,680
So when when you're talking about taking damage off there, it has to be a value less than zero zero.
52
00:04:11,780 --> 00:04:15,530
If it's really small, so it's only going to take it off by increments.
53
00:04:15,580 --> 00:04:16,850
And that's exactly what I want.
54
00:04:18,950 --> 00:04:19,240
OK.
55
00:04:19,280 --> 00:04:20,360
Which is why it's so small.
56
00:04:20,630 --> 00:04:26,690
If you do all the different damage amount, let's say, for a ghost or a bat or a zombie, you could
57
00:04:26,690 --> 00:04:29,210
create three different damage amounts if you want.
58
00:04:31,490 --> 00:04:37,790
And where we have our update and we've seen if zombie attack is equal to true and we're simply going
59
00:04:37,790 --> 00:04:46,190
to take it and the health bar off from here, so we're going to say healthcare, don't fill them out.
60
00:04:47,120 --> 00:04:50,080
Minus equals damage amount.
61
00:04:51,770 --> 00:04:52,150
That's it.
62
00:04:52,270 --> 00:04:53,000
It's quite easy.
63
00:04:53,660 --> 00:04:55,910
Let's do that also for the other ones.
64
00:04:55,970 --> 00:05:03,200
Some control C, control V and control the OK.
65
00:05:04,400 --> 00:05:08,810
And that will then start to take the alpha.
66
00:05:09,320 --> 00:05:12,620
So some of the length of the health bar until it reaches zero.
67
00:05:12,980 --> 00:05:15,230
OK, so we're going to see the player getting damaged.
68
00:05:17,570 --> 00:05:19,190
Let's click on ground.
69
00:05:19,700 --> 00:05:22,730
We do need to assign this image health bar.
70
00:05:25,450 --> 00:05:27,220
Now we can try this out.
71
00:05:32,480 --> 00:05:35,420
OK, so we don't let these creatures talk me.
72
00:05:38,590 --> 00:05:41,830
There we go, can see the alsp really going down now.
73
00:05:47,090 --> 00:05:47,370
Right.
74
00:05:47,730 --> 00:05:49,370
These creatures are too far together.
75
00:05:49,580 --> 00:05:51,740
And don't worry, we're going to be sorting that later.
76
00:05:52,850 --> 00:05:55,280
Definitely the health bar is now going down.
77
00:05:55,760 --> 00:05:59,720
And when it gets to zero, we actually want some kind of a game over.
78
00:05:59,900 --> 00:06:01,010
You've sort of lost.
79
00:06:01,910 --> 00:06:06,350
So to do that, I'm going to go all the way down to the bottom.
80
00:06:08,750 --> 00:06:14,390
Well, I have the time delay, and I'm going to do instead of for enemies, I'm going to do check for
81
00:06:14,390 --> 00:06:15,020
Gameover.
82
00:06:21,220 --> 00:06:29,980
It's going to be a custom function, so I'll create that now just above for enemies may be able to avoid
83
00:06:30,730 --> 00:06:33,910
check for came over.
84
00:06:38,070 --> 00:06:44,430
OK, and all I'm going to say is if Health Healthpoint don't fill amount.
85
00:06:46,670 --> 00:06:50,120
Is less than or equal to zero.
86
00:06:50,780 --> 00:06:57,020
That's the case, and at the moment, all I'm going to do is basically display a message Debord debunked
87
00:06:57,020 --> 00:07:00,020
log game over.
88
00:07:01,910 --> 00:07:06,410
Later, we'll add some functionality so that you can basically be turned back to the menu.
89
00:07:08,990 --> 00:07:14,600
OK, and that's how you get a health bar working in your game.
8062
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.