1
00:00:00,200 --> 00:00:04,740
Welcome back my fellow game developers to a brand new video.

2
00:00:04,740 --> 00:00:06,000
And in this video,

3
00:00:06,000 --> 00:00:07,590
when we run our game,

4
00:00:07,590 --> 00:00:09,380
when we click on the enemy,

5
00:00:09,375 --> 00:00:12,515
you'll notice that he has an extra variable in here,

6
00:00:12,510 --> 00:00:16,140
which is the enemy health and phi shoot him with a couple of bullets.

7
00:00:16,140 --> 00:00:20,510
Notice how his health deteriorates from 100 to 40.

8
00:00:20,505 --> 00:00:28,895
And if I keep shooting him from 40 to 0 and he disappears because he is dead.

9
00:00:28,890 --> 00:00:32,310
So we are going to learn a lot of things in this video.

10
00:00:32,310 --> 00:00:36,780
Put your thinking caps on and let's get started.

11
00:00:36,775 --> 00:00:44,345
Oh, okay, So now time to start damaging our enemies using method.

12
00:00:44,345 --> 00:00:48,775
So first thing we're going to do is we're going to create a way

13
00:00:48,770 --> 00:00:53,650
to add health or to remove health from our enemy.

14
00:00:53,645 --> 00:00:56,815
So I'm going to go into the enemy controller.

15
00:00:56,810 --> 00:01:00,200
And here, Let's open up Visual Studio.

16
00:01:00,200 --> 00:01:06,530
And I'm going to create an integer variable that will represent the health of the enemy.

17
00:01:06,530 --> 00:01:08,030
Why is it an integer?

18
00:01:08,030 --> 00:01:10,010
Well, because we want to keep things simple.

19
00:01:10,010 --> 00:01:11,990
We don't want it to be a float.

20
00:01:11,990 --> 00:01:15,380
So I'm going to add it right here under the speed.

21
00:01:15,380 --> 00:01:20,110
So we're going to create a serialized field which will be of type integer.

22
00:01:20,105 --> 00:01:22,385
And it's going to be called the Health.

23
00:01:22,385 --> 00:01:25,315
And I'm going to set it to be 100 at the beginning,

24
00:01:25,310 --> 00:01:28,780
so we never have the Health at 0.

25
00:01:28,775 --> 00:01:32,885
I'm going to look back into inspector and see how that looks.

26
00:01:32,885 --> 00:01:36,445
And they now, okay, great.

27
00:01:36,440 --> 00:01:42,670
So now you can see that I have the option in here to change the health of our enemy.

28
00:01:42,665 --> 00:01:47,995
Now, how are we going to make sure that every time the enemy gets hit,

29
00:01:47,990 --> 00:01:50,720
we remove a bill of health.

30
00:01:50,720 --> 00:01:55,130
We are going to create a method to do that. What are methods?

31
00:01:55,130 --> 00:01:57,910
Well, you've already seen me create methods.

32
00:01:57,905 --> 00:01:59,725
The update is a method.

33
00:01:59,720 --> 00:02:05,380
We start as a method and also the gizmo select as a method.

34
00:02:05,375 --> 00:02:12,725
But let's delve a bit deeper into the actual structure of a method and see how we use it.

35
00:02:12,725 --> 00:02:15,175
So let me put my laser on,

36
00:02:15,170 --> 00:02:17,530
and this is the method structure.

37
00:02:17,525 --> 00:02:23,875
So it's similar to the way we create variables in that it has an accessibility.

38
00:02:23,870 --> 00:02:26,200
So an access type, what is it?

39
00:02:26,195 --> 00:02:28,315
Is it a private, a public?

40
00:02:28,310 --> 00:02:30,590
We can't make it a serialized field,

41
00:02:30,590 --> 00:02:33,110
but we can create either a public,

42
00:02:33,110 --> 00:02:37,940
which means that we can access this method from anywhere in our scripts,

43
00:02:37,940 --> 00:02:39,160
in any other scripts.

44
00:02:39,155 --> 00:02:45,475
If it's private, we can only access it inside of the class where we are using.

45
00:02:45,470 --> 00:02:47,870
Then we have the return type.

46
00:02:47,870 --> 00:02:50,830
For example, void returns, nothing.

47
00:02:50,825 --> 00:02:52,475
What is a return type?

48
00:02:52,475 --> 00:02:53,935
As we move through the course,

49
00:02:53,930 --> 00:02:56,570
you'll understand all the different return types.

50
00:02:56,570 --> 00:03:01,960
But what this means is that we can actually return a value from this method.

51
00:03:01,955 --> 00:03:03,635
If it doesn't return anything,

52
00:03:03,635 --> 00:03:05,345
that means it's void.

53
00:03:05,345 --> 00:03:08,015
So for example, let me show you in here.

54
00:03:08,015 --> 00:03:11,245
This is a void because we don't return any value.

55
00:03:11,240 --> 00:03:14,660
We don't expect any value to be given back

56
00:03:14,660 --> 00:03:18,980
from this method later on when we do have a method that returns something,

57
00:03:18,980 --> 00:03:21,580
may, I will make sure to point that out for you.

58
00:03:21,575 --> 00:03:24,425
Next, we have the method name.

59
00:03:24,425 --> 00:03:27,055
So usually whenever you want to name a method,

60
00:03:27,050 --> 00:03:30,580
you have to name it by what this method actually does.

61
00:03:30,575 --> 00:03:34,805
And you can notice how we create the name of a method.

62
00:03:34,805 --> 00:03:41,605
It, unlike the variables were the first word has to always be in the lower class,

63
00:03:41,600 --> 00:03:45,530
or the first letter of the first word has to be lower class.

64
00:03:45,530 --> 00:03:47,410
In a method name,

65
00:03:47,405 --> 00:03:51,425
all the words inside of the method name have to be capitalized.

66
00:03:51,425 --> 00:03:53,855
So you can see that adding velocity,

67
00:03:53,855 --> 00:03:56,065
so this method is a private,

68
00:03:56,060 --> 00:03:58,550
so we only use it in a class void.

69
00:03:58,550 --> 00:04:02,210
It doesn't return anything and its name is adding velocity.

70
00:04:02,210 --> 00:04:06,020
That means it adds velocity to some kinds of objects.

71
00:04:06,020 --> 00:04:08,770
And what are the parentheses on the end?

72
00:04:08,765 --> 00:04:11,215
While these are called the parameter,

73
00:04:11,210 --> 00:04:16,300
parameter means that we can send a certain value to that method.

74
00:04:16,295 --> 00:04:21,575
And it can use it in order to do calculations or anything that it wants.

75
00:04:21,575 --> 00:04:28,285
We will demonstrate how this all works in the method which will damage our enemies.

76
00:04:28,280 --> 00:04:31,010
So enough talking, let's get started.

77
00:04:31,010 --> 00:04:34,000
I'm going to open up Visual Studio and here,

78
00:04:33,995 --> 00:04:37,885
and I'm going to create a method inside of the enemy controller.

79
00:04:37,880 --> 00:04:40,850
I will scroll down on the Earth, the update.

80
00:04:40,850 --> 00:04:44,560
And in here I will create a method to damage the enemy.

81
00:04:44,555 --> 00:04:47,035
First thing first, what do I need it to be?

82
00:04:47,030 --> 00:04:48,680
Does it have to be a private?

83
00:04:48,680 --> 00:04:52,210
So I can only use it inside of here and the enemy controller,

84
00:04:52,205 --> 00:04:54,425
or does it have to be a public?

85
00:04:54,425 --> 00:04:56,965
That means I can access it from anywhere.

86
00:04:56,960 --> 00:05:00,860
Well, most probably I will need it to be public because

87
00:05:00,860 --> 00:05:04,820
I want the bullets damage the enemy whenever they hit the enemy.

88
00:05:04,820 --> 00:05:08,200
What's going to be a public void,

89
00:05:08,195 --> 00:05:12,155
and I'm going to call it the damage enemy.

90
00:05:12,155 --> 00:05:17,405
And it's a void because we don't need to return anything from the damage enemy.

91
00:05:17,405 --> 00:05:21,695
All we need to do is remove a bit of health that we already have.

92
00:05:21,695 --> 00:05:23,915
And here, so the enemy health.

93
00:05:23,915 --> 00:05:26,245
And let's change this or no,

94
00:05:26,240 --> 00:05:29,150
I'm going to show you a very cool trick and just stay bit.

95
00:05:29,150 --> 00:05:32,260
Anyways, let's continue on with our main focus.

96
00:05:32,255 --> 00:05:36,415
I also want to send them a parameter of type integer,

97
00:05:36,410 --> 00:05:38,630
which is going to be the damage.

98
00:05:38,630 --> 00:05:39,760
They can.

99
00:05:39,755 --> 00:05:47,095
So now what I can do is I can access the health and I can remove from it.

100
00:05:47,090 --> 00:05:50,480
Sorry, the damage taken.

101
00:05:50,480 --> 00:05:52,680
So now what happens?

102
00:05:52,684 --> 00:05:56,274
You already know what the minus sign means.

103
00:05:56,270 --> 00:06:01,250
That means that we remove from the health the damage taken.

104
00:06:01,250 --> 00:06:11,150
And finally, we need to make sure that if the health is less than or equal to 0.

105
00:06:11,150 --> 00:06:14,600
That means you just add a bit of spaces in here.

106
00:06:14,600 --> 00:06:22,340
That means that our enemy has died and I want to destroy the game object.

107
00:06:22,340 --> 00:06:26,350
Okay, So let's look at another time at this.

108
00:06:26,345 --> 00:06:30,805
And before we do that, I think that the name health of a variable isn't that specific.

109
00:06:30,800 --> 00:06:34,130
I think we need to change it to enemies health.

110
00:06:34,130 --> 00:06:35,530
So what can I do in here?

111
00:06:35,525 --> 00:06:37,855
I can change the name in here to enemy health.

112
00:06:37,850 --> 00:06:42,560
Okay, and then scroll down here and change these two right here.

113
00:06:42,560 --> 00:06:44,650
But this is a bit cumbersome,

114
00:06:44,645 --> 00:06:49,085
especially if we have used health maybe 10 times in our code.

115
00:06:49,085 --> 00:06:50,945
So how can we avoid this?

116
00:06:50,945 --> 00:06:52,735
Simply double-click on health,

117
00:06:52,730 --> 00:06:54,850
click Control R, R.

118
00:06:54,845 --> 00:06:57,395
And now you'll see that you can add this.

119
00:06:57,395 --> 00:07:00,365
So I'm going to call this the enemy health.

120
00:07:00,365 --> 00:07:02,165
I'm going to hit Enter.

121
00:07:02,165 --> 00:07:03,755
And if I scroll down,

122
00:07:03,755 --> 00:07:06,895
you'll see that enemy health has changed.

123
00:07:06,890 --> 00:07:08,480
So as a reminder,

124
00:07:08,480 --> 00:07:12,310
control or our click it two times,

125
00:07:12,305 --> 00:07:13,975
hold down Control R.

126
00:07:13,970 --> 00:07:18,920
And you'll be able to change the variable name and change it everywhere and the game.

127
00:07:18,920 --> 00:07:23,360
Now, the next thing we're going to do is we're going to actually call this method.

128
00:07:23,360 --> 00:07:25,000
And where do we call it from?

129
00:07:24,995 --> 00:07:27,775
We need to go to the bullet controller.

130
00:07:27,770 --> 00:07:32,920
And let me just find the bullet controller in here somewhere.

131
00:07:32,915 --> 00:07:34,715
Where is it in the scripts?

132
00:07:34,715 --> 00:07:38,605
In the bullets, in the law terrible at controller.

133
00:07:38,600 --> 00:07:42,980
And in here when we trigger something so we hit an object,

134
00:07:42,980 --> 00:07:44,320
what we're going to do,

135
00:07:44,315 --> 00:07:48,605
we're going to let me just remove this line from here.

136
00:07:48,605 --> 00:07:54,605
So we instantiate the impact and we're going to go ahead and access the collision.

137
00:07:54,605 --> 00:07:56,395
So what is the collision right here?

138
00:07:56,390 --> 00:08:02,140
As you can see, this is a parameter that is being sent to the method on Trigger Enter.

139
00:08:02,135 --> 00:08:06,695
What is the collision? It's the object that we've just collided with.

140
00:08:06,695 --> 00:08:08,635
So for example, if we hit a wall,

141
00:08:08,630 --> 00:08:10,850
the collision would be the wall that we've hit.

142
00:08:10,850 --> 00:08:11,960
And in our case,

143
00:08:11,960 --> 00:08:14,720
the collision will be the enemy that we've hit.

144
00:08:14,720 --> 00:08:18,880
And I'm going to get the component, excuse me.

145
00:08:18,875 --> 00:08:21,775
So I'm going to get the component which is on

146
00:08:21,770 --> 00:08:25,850
this collision and it's going to be the enemy controller.

147
00:08:25,850 --> 00:08:27,830
And in the enemy controller,

148
00:08:27,830 --> 00:08:30,760
because I've made this method in here public,

149
00:08:30,755 --> 00:08:32,395
I can access it right here,

150
00:08:32,390 --> 00:08:34,610
which is the damage and amine.

151
00:08:34,610 --> 00:08:39,380
And what should I send to this damage enemy?

152
00:08:39,380 --> 00:08:41,200
You can see right now, here,

153
00:08:41,195 --> 00:08:42,385
there is no arguments,

154
00:08:42,380 --> 00:08:44,450
so we need to give the damage taken.

155
00:08:44,450 --> 00:08:46,490
You'll notice all of this right here.

156
00:08:46,490 --> 00:08:51,130
So I'm going to send to it the damage amount.

157
00:08:51,125 --> 00:08:53,785
But we haven't created a damage amount.

158
00:08:53,780 --> 00:08:56,260
So let's go ahead and create it in here.

159
00:08:56,255 --> 00:09:02,425
So the bullet will also have a variable which will be an integer.

160
00:09:02,420 --> 00:09:05,390
And that will just copy this,

161
00:09:05,390 --> 00:09:10,750
which is going to be the damage amount and I'm going to set it to around 10.

162
00:09:10,745 --> 00:09:13,075
So what's happening in here?

163
00:09:13,070 --> 00:09:16,720
Every time the bullet collides with something,

164
00:09:16,715 --> 00:09:19,655
we get the information of that collision.

165
00:09:19,655 --> 00:09:21,185
We get the collision,

166
00:09:21,185 --> 00:09:23,795
we get the component of the enemy controller,

167
00:09:23,795 --> 00:09:26,725
and we access the damage enemy method there.

168
00:09:26,720 --> 00:09:28,850
We sent to it the damage amount.

169
00:09:28,850 --> 00:09:31,120
We go to the enemy controller.

170
00:09:31,115 --> 00:09:34,135
It's public, everything we get the enemy health,

171
00:09:34,130 --> 00:09:36,730
we remove the damaged taken.

172
00:09:36,725 --> 00:09:40,855
The damage taken as obviously the damage amount right here.

173
00:09:40,850 --> 00:09:45,110
And then we check if the health is less than or equal to 0.

174
00:09:45,110 --> 00:09:49,280
If it is, we destroy the game object because the enemy has done.

175
00:09:49,280 --> 00:09:52,040
So. Let's save all of that.

176
00:09:52,040 --> 00:09:54,710
And let's go ahead and test it out in Unity.

177
00:09:54,710 --> 00:09:57,410
So I'm going to click on the enemy,

178
00:09:57,410 --> 00:09:59,210
make sure that we see the enemy health.

179
00:09:59,210 --> 00:10:01,520
I'm going to run the code.

180
00:10:01,520 --> 00:10:04,610
I'm going to try to shoot our enemy.

181
00:10:04,610 --> 00:10:07,100
So I showed it until the bullets get third.

182
00:10:07,100 --> 00:10:08,720
Let's see enemy health.

183
00:10:08,720 --> 00:10:10,120
It was done.

184
00:10:10,115 --> 00:10:12,155
There you go. It became 90.

185
00:10:12,155 --> 00:10:16,675
Let me try to shoot him two times now his health should become 70 right here.

186
00:10:16,670 --> 00:10:19,970
Keep that 80, 70, there you go.

187
00:10:19,970 --> 00:10:22,370
The enemy is being damaged.

188
00:10:22,370 --> 00:10:24,620
And if I keep shooting him with all my bullets,

189
00:10:24,620 --> 00:10:28,690
you'll notice that 70 becomes 0 and the enemy disappears.

190
00:10:28,685 --> 00:10:31,355
But notice what happens right now.

191
00:10:31,355 --> 00:10:34,745
First of all, our bullets kept on flying everywhere.

192
00:10:34,745 --> 00:10:36,605
Why did that happen?

193
00:10:36,605 --> 00:10:37,375
Let me zoom out.

194
00:10:37,370 --> 00:10:39,980
You can see the bullets did not interact with the wall.

195
00:10:39,980 --> 00:10:41,530
They did not get destroyed.

196
00:10:41,525 --> 00:10:44,005
And we got an error right here.

197
00:10:44,000 --> 00:10:49,730
And let me open the console window so we can see what the problem is. There you go.

198
00:10:49,730 --> 00:10:52,760
You can see that we have for errors for

199
00:10:52,760 --> 00:10:56,060
the four bullets right here that interacted with the wall.

200
00:10:56,060 --> 00:10:59,140
And let's double-click on this arrow and see what happened.

201
00:10:59,135 --> 00:11:02,815
Oh, so you can see it takes us to the line that we have

202
00:11:02,810 --> 00:11:06,950
an error and let me show you this one more time. Double-click.

203
00:11:06,950 --> 00:11:08,270
We are on this line.

204
00:11:08,270 --> 00:11:10,030
You can see right here.

205
00:11:10,025 --> 00:11:13,475
And because this line didn't execute properly,

206
00:11:13,475 --> 00:11:17,125
the destroy didn't execute properly solvable, It's kept flying.

207
00:11:17,120 --> 00:11:19,240
This is just a side note.

208
00:11:19,235 --> 00:11:20,785
Anyways, what's the problem?

209
00:11:20,780 --> 00:11:25,180
The problem is that we are accessing the collision, right?

210
00:11:25,175 --> 00:11:30,265
The collision should be the enemy because we are trying to access the NMI controller.

211
00:11:30,260 --> 00:11:34,640
But the problem is that right now we've just hit a wall,

212
00:11:34,640 --> 00:11:40,130
and this wall does not have the enemy script on it. Interesting.

213
00:11:40,130 --> 00:11:42,950
So how are we going to save this?

214
00:11:42,950 --> 00:11:46,970
Well, thankfully we have a very, very powerful tool.

215
00:11:46,970 --> 00:11:48,380
Let me talk this right here.

216
00:11:48,380 --> 00:11:50,770
Let me clear all these nasty errors.

217
00:11:50,765 --> 00:11:55,355
We have an extremely powerful tool that we haven't yet talked about.

218
00:11:55,355 --> 00:11:58,195
If I go into the edit layers, as we saw,

219
00:11:58,190 --> 00:12:01,700
we have the layers of the physics layers,

220
00:12:01,700 --> 00:12:03,350
we have the sorting layers.

221
00:12:03,350 --> 00:12:06,280
We also have this tag right here.

222
00:12:06,275 --> 00:12:07,765
And what we can do,

223
00:12:07,760 --> 00:12:09,770
we can tag the enemy,

224
00:12:09,770 --> 00:12:11,660
was an enemy tag.

225
00:12:11,660 --> 00:12:18,020
And then whenever we are trying to check for the enemy controller, before we do that,

226
00:12:18,020 --> 00:12:23,590
we can create a condition that checks if the tag on the collision is an enemy,

227
00:12:23,585 --> 00:12:25,795
then we can go ahead and damage it.

228
00:12:25,790 --> 00:12:30,640
If it's not an enemy or the object that we fit isn't tagged as an enemy,

229
00:12:30,635 --> 00:12:34,765
then we cannot access the enemy controller.

230
00:12:34,760 --> 00:12:36,860
So let me go back in here.

231
00:12:36,860 --> 00:12:38,750
Let me show you where we can create dagger.

232
00:12:38,750 --> 00:12:41,090
We can simply click on this plus button,

233
00:12:41,090 --> 00:12:42,860
name the tag, whatever we want,

234
00:12:42,860 --> 00:12:44,780
save that, go back to the enemy.

235
00:12:44,780 --> 00:12:49,790
And you can see right here that we can tag him with a tag that we've just created.

236
00:12:49,790 --> 00:12:51,040
Let me go back.

237
00:12:51,035 --> 00:12:53,035
Delete the stack right here.

238
00:12:53,030 --> 00:12:54,340
Yep. Okay.

239
00:12:54,335 --> 00:12:58,685
Also because the enemy was tagged that can untagged.

240
00:12:58,684 --> 00:13:00,864
I'm not sure why I did it.

241
00:13:00,860 --> 00:13:05,750
So there you go. Will be removed from this list the next time the project is loaded.

242
00:13:05,750 --> 00:13:07,640
Okay, So this was a big mistake,

243
00:13:07,640 --> 00:13:10,330
but no worries about it because now it's time for

244
00:13:10,325 --> 00:13:14,105
a challenge and your challenge is to tag our enemies.

245
00:13:14,105 --> 00:13:15,235
So first of all,

246
00:13:15,230 --> 00:13:17,650
create an enemy tag just like I showed you.

247
00:13:17,645 --> 00:13:21,065
Make sure to tag the enemy within the enemy tag.

248
00:13:21,065 --> 00:13:23,905
Before getting the enemy controller,

249
00:13:23,900 --> 00:13:27,550
check for a condition if the collision object,

250
00:13:27,545 --> 00:13:29,665
so you already know what the collision object is,

251
00:13:29,660 --> 00:13:31,900
has the enemy tag on him.

252
00:13:31,895 --> 00:13:34,585
And I recommend that you go through Google,

253
00:13:34,580 --> 00:13:40,060
you find a way of how we can check for the tag and compare the tag.

254
00:13:40,055 --> 00:13:43,325
If you want to go on by yourself, go ahead and do it.

255
00:13:43,325 --> 00:13:45,715
If not, I will give you a small hint.

256
00:13:45,710 --> 00:13:48,820
You can use something called the.com DAG,

257
00:13:48,815 --> 00:13:50,585
go check it out in Unity dogs,

258
00:13:50,585 --> 00:13:53,635
use your information, do your own research.

259
00:13:53,630 --> 00:13:55,790
There is another way of checking for the tag.

260
00:13:55,790 --> 00:13:57,460
I do recommend that you find it.

261
00:13:57,455 --> 00:14:02,155
Pause the video right now and go do the shopping.

262
00:14:02,150 --> 00:14:04,190
Hey, welcome back.

263
00:14:04,190 --> 00:14:05,600
How did you get on with that?

264
00:14:05,600 --> 00:14:10,850
So this is the unit of documentations, component.com, DAG declaration.

265
00:14:10,850 --> 00:14:12,280
It returns a bool,

266
00:14:12,275 --> 00:14:15,085
whether it's true or not or no public bool.

267
00:14:15,080 --> 00:14:17,780
Also the compare tag is a bool and we're going

268
00:14:17,780 --> 00:14:20,860
to use it in our if statement because as we know,

269
00:14:20,855 --> 00:14:23,855
a condition in the if statement is a true or false.

270
00:14:23,855 --> 00:14:28,225
So we can also see how it's used and it's used on the Trigger Enter,

271
00:14:28,220 --> 00:14:30,790
how convenient for us.

272
00:14:30,785 --> 00:14:32,605
So we use this other,

273
00:14:32,600 --> 00:14:33,740
they called it other,

274
00:14:33,740 --> 00:14:35,330
we have it as collision.

275
00:14:35,330 --> 00:14:37,340
It's the same, no worries about that.

276
00:14:37,340 --> 00:14:40,210
So let's see how we can do with in here.

277
00:14:40,205 --> 00:14:42,385
So before we check for a collision,

278
00:14:42,380 --> 00:14:44,260
I've added a tab right here.

279
00:14:44,255 --> 00:14:53,125
I'm going to see if the collision that we've just hit.com tag is an enemy.

280
00:14:53,120 --> 00:14:54,530
And before we do that,

281
00:14:54,530 --> 00:14:59,680
we must create this type which is the enemy. Hit Enter.

282
00:14:59,675 --> 00:15:03,475
So I'm going to make sure that we write it correctly.

283
00:15:03,470 --> 00:15:07,820
So enemy, and I'm going to tag our enemy as the enemy.

284
00:15:07,820 --> 00:15:09,320
So now in here,

285
00:15:09,320 --> 00:15:11,080
if it is an enemy,

286
00:15:11,075 --> 00:15:15,745
then we are going to go ahead and do the collision and another nifty tricks,

287
00:15:15,740 --> 00:15:17,900
This video is full of nifty tricks.

288
00:15:17,900 --> 00:15:20,960
If you only have one line under the if condition,

289
00:15:20,960 --> 00:15:23,840
you don't need to add these brackets right here.

290
00:15:23,840 --> 00:15:26,230
So if you only have one line,

291
00:15:26,225 --> 00:15:29,815
you do not need to add the brackets if I add another line.

292
00:15:29,810 --> 00:15:33,700
So for example, the destroyer is not part of the if condition.

293
00:15:33,695 --> 00:15:36,445
Even if I take it and put it right here,

294
00:15:36,440 --> 00:15:40,150
it will still be not part of the condition.

295
00:15:40,145 --> 00:15:42,625
And if you're a bit confused by that, no worries.

296
00:15:42,620 --> 00:15:44,180
You can add your own brackets.

297
00:15:44,180 --> 00:15:46,070
This is just a small test.

298
00:15:46,070 --> 00:15:50,210
You can even add a comment in here to say that this is what happens.

299
00:15:50,210 --> 00:15:52,960
So I'm going to save that now.

300
00:15:52,955 --> 00:15:57,055
And only if the collision an enemy tag on it.

301
00:15:57,050 --> 00:16:01,030
Well, we call the enemy controller and give them to him.

302
00:16:01,025 --> 00:16:02,195
Let's test this out.

303
00:16:02,195 --> 00:16:07,115
I'm going to run the game and I'm going to start shooting the walls.

304
00:16:07,115 --> 00:16:09,775
And there you go, you can see that we have no errors.

305
00:16:09,770 --> 00:16:11,560
If I shoot the enemy,

306
00:16:11,555 --> 00:16:15,925
then I will look at the damage the enemy has taken.

307
00:16:15,920 --> 00:16:18,200
There you go. You can see that it's at 40.

308
00:16:18,200 --> 00:16:21,110
I will shoot him three more times,

309
00:16:21,110 --> 00:16:24,490
so he becomes 30, 20, 10.

310
00:16:24,485 --> 00:16:30,085
And finally, I will shoot him for the last time and he gets destroyed without any errors.

311
00:16:30,080 --> 00:16:31,660
So I hope you enjoy,

312
00:16:31,655 --> 00:16:36,445
I hope you are committing all of the changes that we are making.

313
00:16:36,440 --> 00:16:37,840
It's very important.

314
00:16:37,835 --> 00:16:42,845
Sometimes I will be doing this outside of the realm of the video.

315
00:16:42,845 --> 00:16:44,875
And with that said, I hope you enjoy it.

316
00:16:44,870 --> 00:16:47,060
If you are enjoying this course,

317
00:16:47,060 --> 00:16:48,710
please leave me a review.

318
00:16:48,710 --> 00:16:50,740
It helps me out a lot.

319
00:16:50,735 --> 00:16:53,915
It lets everyone know that this is a good course.

320
00:16:53,915 --> 00:16:56,335
So make sure to leave me a review.

321
00:16:56,330 --> 00:16:57,830
Thank you so much for watching.

322
00:16:57,830 --> 00:17:00,500
I'll see you in the next video where we will be making

323
00:17:00,500 --> 00:17:03,430
the depth of our enemies a bit more brutal.

324
00:17:03,425 --> 00:17:06,425
So I'll see you then.

