1
00:00:00,000 --> 00:00:05,690
Welcome back my fellow game developers to a brand new video.

2
00:00:05,685 --> 00:00:08,885
As you can see, we've added a couple of rooms to our game.

3
00:00:08,880 --> 00:00:12,690
We've added a couple of paths to our game now our level,

4
00:00:12,690 --> 00:00:14,510
or actually I should have said our level.

5
00:00:14,505 --> 00:00:17,375
Now our level looks kind of really nice.

6
00:00:17,370 --> 00:00:20,940
You know that Cinna machine really did add some flavor to the game,

7
00:00:20,940 --> 00:00:25,770
which gave us the ability to run around and make bigger levels and more interesting ones.

8
00:00:25,770 --> 00:00:28,740
But that's not the only thing that is very cool.

9
00:00:28,740 --> 00:00:31,310
If I run the game, look at the scene,

10
00:00:31,305 --> 00:00:35,715
you can see that now we have doors that are blocking our way from moving.

11
00:00:35,715 --> 00:00:38,255
And these will be the doors that we used to go to

12
00:00:38,250 --> 00:00:41,230
the next level after we kill our enemies,

13
00:00:41,230 --> 00:00:43,310
obviously we need to kill our enemies.

14
00:00:43,310 --> 00:00:45,890
But this is not of our concern right now.

15
00:00:45,890 --> 00:00:47,270
Later on it will be.

16
00:00:47,270 --> 00:00:51,280
But for now, let's not waste any more time and let's get started.

17
00:00:51,275 --> 00:00:56,515
And we will be learning full of amazing stuff, amazing 0 case.

18
00:00:56,510 --> 00:01:01,240
So we are going to go ahead and create doors.

19
00:01:01,235 --> 00:01:02,515
What are the doors?

20
00:01:02,510 --> 00:01:04,610
I've created the door's already,

21
00:01:04,610 --> 00:01:05,960
you can see them right here.

22
00:01:05,960 --> 00:01:08,600
I'll provide you the door and the resources,

23
00:01:08,600 --> 00:01:09,910
but it's fairly simple.

24
00:01:09,905 --> 00:01:13,465
All I did was cropped out the where is it?

25
00:01:13,460 --> 00:01:15,830
The main photo?

26
00:01:15,830 --> 00:01:17,500
The main picture.

27
00:01:17,495 --> 00:01:21,085
And just use the door that was already available there.

28
00:01:21,080 --> 00:01:24,830
So now we can go ahead and add the door or let's add it in here.

29
00:01:24,830 --> 00:01:26,060
So we have the door,

30
00:01:26,060 --> 00:01:33,050
we set the layer maybe on the player or we can set the layer on the, on a separate door.

31
00:01:33,050 --> 00:01:37,120
And what those doors is going to do is it's going to go ahead and close

32
00:01:37,115 --> 00:01:42,275
these two pathways that I've also created and I haven't talked about those.

33
00:01:42,275 --> 00:01:44,455
So what is the point of our game?

34
00:01:44,450 --> 00:01:47,420
How are we going to transition from level to level?

35
00:01:47,420 --> 00:01:49,720
Just like we saw in the hades game.

36
00:01:49,715 --> 00:01:51,875
Every time we kill all the enemies,

37
00:01:51,875 --> 00:01:54,135
we will have these two barricades.

38
00:01:54,139 --> 00:01:56,589
We will have this door and a second one.

39
00:01:56,585 --> 00:01:58,285
So here two doors.

40
00:01:58,280 --> 00:02:00,020
And when we kill all the enemies,

41
00:02:00,020 --> 00:02:02,390
we are simply going to deactivate the doors.

42
00:02:02,390 --> 00:02:06,620
And this will allow our player to move through and to the pathway where

43
00:02:06,620 --> 00:02:10,900
he will find two portals here and he can go through them.

44
00:02:10,895 --> 00:02:13,195
But let's not get ahead of ourselves.

45
00:02:13,190 --> 00:02:15,890
Let's first of all start off by making sure that

46
00:02:15,890 --> 00:02:20,390
these doors work and what else wanted to tell you? Oh, okay.

47
00:02:20,390 --> 00:02:23,390
So if you go into that tile palette right here,

48
00:02:23,390 --> 00:02:28,390
you can see that we can add these two anchors or wherever you, these pathways here.

49
00:02:28,385 --> 00:02:30,385
But the problem with these pathways,

50
00:02:30,380 --> 00:02:32,630
if I click on the grid and wall,

51
00:02:32,630 --> 00:02:36,200
you can see that they will also stop the player from moving.

52
00:02:36,200 --> 00:02:37,370
So what do I mean?

53
00:02:37,370 --> 00:02:41,090
I've made sure that this is the ground and these are the wall.

54
00:02:41,090 --> 00:02:43,190
And if I, for example,

55
00:02:43,190 --> 00:02:47,480
run the game, you'll see that I can walk around everywhere.

56
00:02:47,480 --> 00:02:49,010
And if I go through here,

57
00:02:49,010 --> 00:02:51,430
you can see that I can no longer move.

58
00:02:51,425 --> 00:02:55,255
And that's because we have a collider under and that is

59
00:02:55,250 --> 00:02:59,170
something that we will have to fix in order to move through them, obviously.

60
00:02:59,165 --> 00:03:01,595
So how are we going to fix this?

61
00:03:01,595 --> 00:03:06,365
Well, if we go into our tile set right here,

62
00:03:06,365 --> 00:03:10,375
the cones, if we scroll down,

63
00:03:10,370 --> 00:03:13,160
we can find the image right here.

64
00:03:13,160 --> 00:03:14,710
Go into the inspector,

65
00:03:14,705 --> 00:03:16,745
select the Sprite Editor.

66
00:03:16,745 --> 00:03:17,975
Open this up.

67
00:03:17,975 --> 00:03:21,785
If we go from the Sprite Editor to the custom physics shape,

68
00:03:21,785 --> 00:03:23,225
Let's click in here.

69
00:03:23,225 --> 00:03:26,575
You can see that if we, Where is it, ok,

70
00:03:26,570 --> 00:03:28,280
so the anchor and here,

71
00:03:28,280 --> 00:03:32,210
if we click on one of those, we can generate.

72
00:03:32,210 --> 00:03:35,330
And now we have the anchor points of the physics.

73
00:03:35,330 --> 00:03:39,860
So this is how the collider will be rendered on this sprite.

74
00:03:39,859 --> 00:03:46,299
So I'm going to make sure that it's very or not even tiny.

75
00:03:46,295 --> 00:03:48,685
I'll make sure that it is about 0.

76
00:03:48,680 --> 00:03:50,570
So asset this like this, like this,

77
00:03:50,570 --> 00:03:54,520
and finally, lie this.

78
00:03:54,515 --> 00:04:00,475
I will apply the changes and wait for just a second.

79
00:04:00,470 --> 00:04:05,160
It will take a bit of time to change the colliders and the game Also,

80
00:04:05,164 --> 00:04:08,184
we might have to draw these price again.

81
00:04:08,180 --> 00:04:10,460
Okay, great, So this one is finished.

82
00:04:10,460 --> 00:04:12,760
Let's generate on this block.

83
00:04:12,755 --> 00:04:14,815
Also. Move it here.

84
00:04:14,810 --> 00:04:17,660
We don't need to move it down like the one in the middle.

85
00:04:17,660 --> 00:04:19,220
We can just move it to the right.

86
00:04:19,220 --> 00:04:23,650
Apply. Now the collider will only be on this side.

87
00:04:23,645 --> 00:04:29,095
And finally, find any, any day.

88
00:04:29,090 --> 00:04:31,310
Now, we can click on the last one,

89
00:04:31,310 --> 00:04:33,050
generate OK. Not last one.

90
00:04:33,050 --> 00:04:35,390
Actually, we still have two more to do.

91
00:04:35,390 --> 00:04:36,320
So.

92
00:04:36,320 --> 00:04:38,080
Now that you know how this is done,

93
00:04:38,075 --> 00:04:41,045
I'm going to do the one above and I'm wound to

94
00:04:41,045 --> 00:04:44,225
obviously expect you to be doing this at the same time with me.

95
00:04:44,225 --> 00:04:46,025
This is not a challenge.

96
00:04:46,025 --> 00:04:51,505
This is just us making our game much better.

97
00:04:51,500 --> 00:04:56,690
So generate, generate, move this to the left,

98
00:04:56,690 --> 00:05:00,440
I apply the changes.

99
00:05:00,440 --> 00:05:04,340
And for some reason it is extremely slow.

100
00:05:04,340 --> 00:05:07,940
I thought it might be just a little bit faster.

101
00:05:07,939 --> 00:05:11,919
So come on, Generate.

102
00:05:11,915 --> 00:05:13,775
Move this here.

103
00:05:13,775 --> 00:05:16,865
It's like that, just like that.

104
00:05:16,865 --> 00:05:18,745
Apply.

105
00:05:18,749 --> 00:05:24,379
And I'm so excited to show you how this is all going to work.

106
00:05:26,850 --> 00:05:31,840
Final one, generate how boring is this?

107
00:05:31,840 --> 00:05:32,950
Yep, it is.

108
00:05:32,950 --> 00:05:35,920
I know it's because of the waiting time that we have to wait

109
00:05:35,920 --> 00:05:39,790
for unity to generate physics.

110
00:05:39,790 --> 00:05:44,310
So I think we should have moved this down also.

111
00:05:44,305 --> 00:05:49,485
Let me just see something also should have been moved down.

112
00:05:49,480 --> 00:05:52,650
Just like that. Now we apply the changes.

113
00:05:52,645 --> 00:05:55,395
Now if we go back,

114
00:05:55,390 --> 00:05:58,830
maybe we should draw them back. Maybe we shouldn't.

115
00:05:58,825 --> 00:06:00,135
That's the problem with limited.

116
00:06:00,130 --> 00:06:03,110
If we go close when it unity than open it,

117
00:06:03,110 --> 00:06:04,990
maybe we won't find this problem.

118
00:06:04,985 --> 00:06:06,685
So let's see what we have.

119
00:06:06,680 --> 00:06:08,990
So there you go, the walls are still there,

120
00:06:08,990 --> 00:06:12,160
but if I choose this another time,

121
00:06:12,155 --> 00:06:15,155
and I draw that, Let's say here.

122
00:06:15,155 --> 00:06:21,235
Okay, So obviously there is something very wrong here.

123
00:06:21,230 --> 00:06:24,890
Oh, okay, so we had a small technical problem.

124
00:06:24,890 --> 00:06:26,750
Now if I click on the walls,

125
00:06:26,750 --> 00:06:29,480
I thought for a secondary didn't work, but it did.

126
00:06:29,480 --> 00:06:30,770
Now if you see the walls,

127
00:06:30,770 --> 00:06:36,670
the collider is no longer here and just on the sides that it's intended to be on.

128
00:06:36,665 --> 00:06:40,655
Now when I run the game, I look here.

129
00:06:40,655 --> 00:06:42,325
If I move up, there you go.

130
00:06:42,320 --> 00:06:43,790
I can walk through them.

131
00:06:43,790 --> 00:06:48,350
Now, obviously there is a problem which is that I'm walking over them.

132
00:06:48,350 --> 00:06:49,970
We will fix this in just a bit,

133
00:06:49,970 --> 00:06:52,270
but for now we have this working.

134
00:06:52,265 --> 00:06:54,785
This should maybe be on a different layer.

135
00:06:54,785 --> 00:06:56,875
No worries about that. Let's continue on.

136
00:06:56,870 --> 00:06:59,000
What do we actually need to do in here?

137
00:06:59,000 --> 00:07:02,020
And we need to add the two closed doors.

138
00:07:02,015 --> 00:07:04,765
We need to get a reference to them and we need to make sure

139
00:07:04,760 --> 00:07:07,660
that whenever the player is in the room,

140
00:07:07,655 --> 00:07:10,255
we want to close them off.

141
00:07:10,250 --> 00:07:12,070
So let's get started.

142
00:07:12,065 --> 00:07:16,945
The first thing that we want to do is we want to go ahead and add the two doors.

143
00:07:16,940 --> 00:07:23,600
So I'm going to go into the doors and I'm going to select in the inspector in here.

144
00:07:23,600 --> 00:07:26,210
And I'm just going to add it in the hierarchy,

145
00:07:26,210 --> 00:07:29,800
create the object first Gore fits here.

146
00:07:29,795 --> 00:07:35,525
I'm going to go ahead and set it as the Charlotte set it as the player.

147
00:07:35,525 --> 00:07:36,905
No worries about that.

148
00:07:36,905 --> 00:07:39,355
We'll set that as the layer, layer.

149
00:07:39,350 --> 00:07:43,520
So this is the door one,

150
00:07:43,520 --> 00:07:45,550
and I'm going to duplicate it.

151
00:07:45,545 --> 00:07:53,605
This is going to be the door 2 and I'm going to move it to the other side.

152
00:07:53,600 --> 00:07:56,590
Or you know what, let's not duplicate this right now.

153
00:07:56,585 --> 00:07:59,195
First we need to add a box collider around

154
00:07:59,195 --> 00:08:02,095
because we don't want to play or to move through this door.

155
00:08:02,090 --> 00:08:06,950
So I'm going to add a box collider 2D.

156
00:08:06,950 --> 00:08:09,470
And let's see how that box looks.

157
00:08:09,470 --> 00:08:11,690
Okay, I think that looks good enough.

158
00:08:11,690 --> 00:08:14,530
And I'm now going to duplicate this door.

159
00:08:14,525 --> 00:08:17,465
This will be the door 2,

160
00:08:17,465 --> 00:08:21,935
and I'm going to move it right into here.

161
00:08:21,935 --> 00:08:24,995
So now these two pathways are closed off.

162
00:08:24,995 --> 00:08:26,795
I will run the game.

163
00:08:26,795 --> 00:08:30,115
I will try to walk through the door and there you go.

164
00:08:30,110 --> 00:08:32,890
You can see that I cannot walk through.

165
00:08:32,885 --> 00:08:33,515
Excellent.

166
00:08:33,515 --> 00:08:35,725
Now, what is the next step?

167
00:08:35,720 --> 00:08:38,750
The next step is I'm going to prefab this.

168
00:08:38,750 --> 00:08:41,660
I'm going to go into the prefab, right-click.

169
00:08:41,660 --> 00:08:46,480
Create Folder, room, or rooms or wrong.

170
00:08:46,475 --> 00:08:49,975
This will be for anything that involves a room.

171
00:08:49,970 --> 00:08:56,080
And I'm going to just prefab this and I'll call this the simply the door. There you go.

172
00:08:56,075 --> 00:08:59,875
And now I will just add this again at the prefabs.

173
00:08:59,870 --> 00:09:01,700
So it's attached to the prefab.

174
00:09:01,700 --> 00:09:03,650
So if we ever change something,

175
00:09:03,650 --> 00:09:06,530
that changes are happening for everything.

176
00:09:06,530 --> 00:09:12,170
Okay, so let's go ahead now and create a game object in here,

177
00:09:12,170 --> 00:09:14,920
which is going to be called the room.

178
00:09:14,915 --> 00:09:17,495
I'm going to reset its position.

179
00:09:17,494 --> 00:09:21,654
And this room will have a child on it called the doors.

180
00:09:21,649 --> 00:09:28,269
And this will be the object that will hold all the doors that we have in the room.

181
00:09:28,265 --> 00:09:31,535
Now we are going to create a new script in here.

182
00:09:31,535 --> 00:09:33,665
And we're going to attach it to the room,

183
00:09:33,665 --> 00:09:35,875
and this will be the room manager.

184
00:09:35,870 --> 00:09:42,350
So scripts, right-click, let's create a folder for the managers.

185
00:09:42,350 --> 00:09:47,680
And in here we are going to create a C-sharp script for the room.

186
00:09:47,675 --> 00:09:49,265
Manager.

187
00:09:49,265 --> 00:09:52,025
Hit Enter, wait for it to compile.

188
00:09:52,025 --> 00:09:53,425
No, thank you.

189
00:09:53,420 --> 00:09:55,580
I don't need it right now.

190
00:09:55,580 --> 00:09:57,950
And wait for it to compile.

191
00:09:57,950 --> 00:10:00,460
Okay, So rooms, Let's add the script in here.

192
00:10:00,455 --> 00:10:02,245
Let's open up the room manager.

193
00:10:02,240 --> 00:10:04,310
And what do we need in here?

194
00:10:04,310 --> 00:10:05,910
Well, we need to have an,

195
00:10:05,910 --> 00:10:10,780
an array of game objects that will represent the doors that we want to close.

196
00:10:10,775 --> 00:10:15,175
So the game object and array,

197
00:10:15,170 --> 00:10:20,260
which is the doors to close.

198
00:10:20,255 --> 00:10:21,985
Save that.

199
00:10:21,980 --> 00:10:27,940
And now what we want to do is we want to create a huge trigger around the entire map.

200
00:10:27,935 --> 00:10:32,185
And then check when the player is inside this trigger room.

201
00:10:32,180 --> 00:10:34,370
And why do we need to be inside the sugar room?

202
00:10:34,370 --> 00:10:35,900
Because maybe.

203
00:10:35,900 --> 00:10:41,000
For example, you want your game to have just a little bit of a bigger level.

204
00:10:41,000 --> 00:10:43,630
Maybe when you get through some kind of doors,

205
00:10:43,625 --> 00:10:48,395
the doors close and then the level starts and until you kill all the enemies,

206
00:10:48,395 --> 00:10:50,285
then you can move out of the room.

207
00:10:50,285 --> 00:10:53,305
So that's why I wanted to go with

208
00:10:53,300 --> 00:10:59,480
this stop process of having doors close only when the player is inside the throne.

209
00:10:59,480 --> 00:11:03,350
So let's first of all add these two doors on

210
00:11:03,350 --> 00:11:07,280
coming to lock this down at the two doors to the doors to close.

211
00:11:07,280 --> 00:11:08,630
There we go, save that.

212
00:11:08,630 --> 00:11:11,440
And now I'm going to go back and my script.

213
00:11:11,435 --> 00:11:16,835
And in here I'm going to create a boolean which will be a serialized field.

214
00:11:16,835 --> 00:11:23,105
And that will be the close door on layer.

215
00:11:23,105 --> 00:11:24,245
Enter.

216
00:11:24,245 --> 00:11:25,445
Save that.

217
00:11:25,445 --> 00:11:29,245
And what are we going to do in here while we are going to go

218
00:11:29,240 --> 00:11:33,940
through all of these on the, on sugar.

219
00:11:33,935 --> 00:11:35,375
Enter.

220
00:11:35,375 --> 00:11:39,455
Okay, this should have been too deep.

221
00:11:39,455 --> 00:11:44,675
And actually let's create the entrepreneur enter to the immediately.

222
00:11:44,675 --> 00:11:48,635
And in here we are going to check if the

223
00:11:48,635 --> 00:11:55,805
collision.com tag is the layer.

224
00:11:55,805 --> 00:12:00,625
Now I'm going to cheat because I already know how player is written.

225
00:12:00,620 --> 00:12:07,670
And we are going to check if closed-door on player enter.

226
00:12:07,670 --> 00:12:11,740
Okay, So now we want to go ahead and close our doors.

227
00:12:11,735 --> 00:12:13,805
Now we have this array right here.

228
00:12:13,805 --> 00:12:14,825
What should we do?

229
00:12:14,825 --> 00:12:18,505
Should we go through all of them and close them one by one?

230
00:12:18,500 --> 00:12:22,330
So I should write door to close, for example,

231
00:12:22,325 --> 00:12:26,195
0 dot active to true,

232
00:12:26,195 --> 00:12:28,165
and then do door one,

233
00:12:28,160 --> 00:12:29,500
door to door three.

234
00:12:29,495 --> 00:12:35,185
We could do that, but there is a problem and we don't know how many doors we will have.

235
00:12:35,180 --> 00:12:38,950
So what we can do is we can loop through them.

236
00:12:38,945 --> 00:12:42,175
And one of the first full or the first loops

237
00:12:42,170 --> 00:12:44,770
that I want to teach you is the for each loop.

238
00:12:44,765 --> 00:12:47,035
So what is a for each loop?

239
00:12:47,030 --> 00:12:49,250
Let's see how that structure works.

240
00:12:49,250 --> 00:12:52,940
It allows you to go through each thing in

241
00:12:52,940 --> 00:12:57,140
a collection of things of the same type in an array.

242
00:12:57,140 --> 00:12:59,690
So what do I mean by things?

243
00:12:59,690 --> 00:13:04,040
So let's say we have a type which in our case is the game object.

244
00:13:04,040 --> 00:13:09,850
The thing is the door in the doors that we want to close.

245
00:13:09,845 --> 00:13:14,425
So what we do, just like it says, for each door,

246
00:13:14,420 --> 00:13:18,520
which is of type game object in the doors to close,

247
00:13:18,515 --> 00:13:21,715
we can go ahead and do stuff with it.

248
00:13:21,710 --> 00:13:25,490
So for example, we can access some method on the thing.

249
00:13:25,490 --> 00:13:31,390
We can use the thing in some other method and we can execute other things.

250
00:13:31,385 --> 00:13:33,965
So was that explained what we want to do?

251
00:13:33,965 --> 00:13:40,825
Our goal in this video is to go ahead and access or loop through using the For Each,

252
00:13:40,820 --> 00:13:43,820
we want to loop through all the doors and make sure

253
00:13:43,820 --> 00:13:46,810
that we set all of them active to true.

254
00:13:46,805 --> 00:13:49,015
So as soon as the player enters the room,

255
00:13:49,010 --> 00:13:55,070
everything will be closed off until he kills all of the enemies later on.

256
00:13:55,070 --> 00:13:56,620
So with that explained,

257
00:13:56,615 --> 00:14:01,345
I am going to issue you a challenge to go through all the doors and close them.

258
00:14:01,340 --> 00:14:07,180
So create a for each loop that goes through all the doors endorsed closed.

259
00:14:07,175 --> 00:14:09,775
Set, each door to active.

260
00:14:09,770 --> 00:14:11,810
And I'll just give you a hint.

261
00:14:11,810 --> 00:14:14,030
Use the set active to true.

262
00:14:14,030 --> 00:14:15,070
I've already showed you.

263
00:14:15,065 --> 00:14:17,645
I tried to give you as many hands as possible.

264
00:14:17,645 --> 00:14:20,275
I know this is maybe the first time you see loops.

265
00:14:20,270 --> 00:14:25,910
This is a great opportunity to try to see something for

266
00:14:25,910 --> 00:14:28,700
the first time and tried to implement it in front of you

267
00:14:28,700 --> 00:14:31,750
without me teaching you that beforehand.

268
00:14:31,745 --> 00:14:33,545
I know it's a bit hard.

269
00:14:33,545 --> 00:14:35,965
I would drink it as one of the hardest challenges,

270
00:14:35,960 --> 00:14:37,010
but don't worry about it.

271
00:14:37,010 --> 00:14:38,920
Take your time. Pause the video,

272
00:14:38,915 --> 00:14:43,175
try to do your best and I'll see you in just a bit.

273
00:14:43,210 --> 00:14:46,510
K, How did you get all of that?

274
00:14:46,505 --> 00:14:48,025
I hope it wasn't too hard.

275
00:14:48,020 --> 00:14:52,610
So what we're going to do is we're going to create a for-each loop.

276
00:14:52,610 --> 00:14:57,080
And as I've said, we are going to go through the game objects.

277
00:14:57,080 --> 00:15:00,190
And we can call this whatever we want the doors,

278
00:15:00,185 --> 00:15:06,515
the doors we can call it ABC you whatever we want in doors to close.

279
00:15:06,515 --> 00:15:10,165
And what we'll do in here is we'll simply access the door,

280
00:15:10,160 --> 00:15:15,280
dot set active. True.

281
00:15:15,275 --> 00:15:16,955
Save that.

282
00:15:16,955 --> 00:15:19,285
Back in Unity.

283
00:15:19,280 --> 00:15:25,100
We are going to go ahead and activate these doors.

284
00:15:25,100 --> 00:15:26,800
So let's say they are open.

285
00:15:26,795 --> 00:15:28,595
First thing we enter the room.

286
00:15:28,595 --> 00:15:33,065
Okay, Also, I should not have clicked on here.

287
00:15:33,065 --> 00:15:35,455
I'm going to turn on back the room.

288
00:15:35,450 --> 00:15:37,360
So what happened here?

289
00:15:37,355 --> 00:15:40,345
And that's something that I always fall to

290
00:15:40,340 --> 00:15:43,820
as I've had the room and I've had it locked in.

291
00:15:43,820 --> 00:15:47,600
So I chose the two doors and clicked on this one.

292
00:15:47,600 --> 00:15:48,710
So I turned off the room.

293
00:15:48,710 --> 00:15:51,170
Actually, you can see right here whatever you choose,

294
00:15:51,170 --> 00:15:52,370
it's still the room.

295
00:15:52,370 --> 00:15:56,290
So what I'm going to unlock this shows the two doors.

296
00:15:56,285 --> 00:15:57,695
And I'm going to.

297
00:15:57,695 --> 00:15:59,435
Go ahead and turn them off.

298
00:15:59,435 --> 00:16:01,175
I'll go into the room.

299
00:16:01,175 --> 00:16:05,545
I'm going to add a component which will be a huge box collider.

300
00:16:05,540 --> 00:16:10,300
Now, the only problem here is that maybe the collider will check

301
00:16:10,295 --> 00:16:15,265
for the player and when he actually hasn't yet entered the room.

302
00:16:15,260 --> 00:16:19,340
So let's go back in here and see on Trigger Enter.

303
00:16:19,340 --> 00:16:22,070
When we enter the trigger,

304
00:16:22,070 --> 00:16:24,620
that's when this method will be called.

305
00:16:24,620 --> 00:16:25,610
So let's see.

306
00:16:25,610 --> 00:16:29,840
I'm not sure, sometimes it's because of how the script is executed.

307
00:16:29,840 --> 00:16:32,960
So FVA room script executed first,

308
00:16:32,960 --> 00:16:34,610
then we will have the room,

309
00:16:34,610 --> 00:16:37,450
and then we will have the player.

310
00:16:37,445 --> 00:16:40,135
So this way the player actually enters.

311
00:16:40,130 --> 00:16:42,170
So I'm going to save this.

312
00:16:42,170 --> 00:16:44,180
I'm going to, okay,

313
00:16:44,180 --> 00:16:49,280
so this is a trigger when I have an error.

314
00:16:49,280 --> 00:16:53,020
Okay, so this error is nothing to worry about.

315
00:16:53,015 --> 00:16:54,815
Run the game.

316
00:16:54,815 --> 00:16:57,085
Okay, So the doors didn't close.

317
00:16:57,080 --> 00:17:00,970
Let's choose to close the doors on player enter.

318
00:17:00,965 --> 00:17:02,285
Okay, So there we go.

319
00:17:02,285 --> 00:17:05,755
It worked. So I hope you understood what my concern was.

320
00:17:05,750 --> 00:17:10,100
I sometimes this is what happens when I was first creating this game.

321
00:17:10,100 --> 00:17:11,030
This is what happens.

322
00:17:11,030 --> 00:17:12,940
So I had to create something different.

323
00:17:12,935 --> 00:17:16,175
But I noticed that sometimes it works, sometimes it doesn't.

324
00:17:16,175 --> 00:17:19,625
I just wanted to let you know beforehand so you don't think Oh,

325
00:17:19,625 --> 00:17:22,075
Michael, every single time a mistake.

326
00:17:22,070 --> 00:17:24,590
Now actually, so I hope you enjoy it.

327
00:17:24,590 --> 00:17:26,960
I hope you did the for each challenge.

328
00:17:26,960 --> 00:17:29,420
I know it was a complicated,

329
00:17:29,420 --> 00:17:34,940
but this is a good way to practice your game developer skills.

330
00:17:34,940 --> 00:17:39,250
So I'll see you in the next video where we will be catching

331
00:17:39,245 --> 00:17:44,585
all the enemies that we have so we can kill them and then open the doors when they die.

332
00:17:44,585 --> 00:17:46,555
So I'll see you then.

333
00:17:46,550 --> 00:17:49,820
Make sure to stage all your files.

334
00:17:49,820 --> 00:17:50,470
Sorry for that.

335
00:17:50,465 --> 00:17:53,305
And make sure to leave me a review if you haven't yet.

336
00:17:53,300 --> 00:17:55,120
It helps me out a lot.

337
00:17:55,115 --> 00:17:55,825
Thank you.

338
00:17:55,820 --> 00:18:00,530
See you next time. Hey, Michael here from the future,

339
00:18:00,530 --> 00:18:04,150
you thought you got rid of me, but you haven't.

340
00:18:04,145 --> 00:18:05,795
When we run the game,

341
00:18:05,795 --> 00:18:08,875
I noticed something that you can see that I was

342
00:18:08,870 --> 00:18:12,530
wondering why the skeleton wasn't shooting us and if I tried to shoot,

343
00:18:12,530 --> 00:18:14,020
you can see that immediately.

344
00:18:14,015 --> 00:18:16,495
I have the bullet Impact effect.

345
00:18:16,490 --> 00:18:17,950
What's the problem here?

346
00:18:17,945 --> 00:18:21,725
Well, because we are sitting inside of the room collider,

347
00:18:21,725 --> 00:18:24,535
we are shooting and it's immediately interacting with it.

348
00:18:24,530 --> 00:18:28,090
So the problem here is obviously it's the layers.

349
00:18:28,085 --> 00:18:31,145
So what we want to do is we are going to add a layer.

350
00:18:31,145 --> 00:18:35,005
We can call this the untouchables or whatever you wanna call it.

351
00:18:35,000 --> 00:18:37,760
I'll just call it the room layer.

352
00:18:37,759 --> 00:18:39,019
Hit Enter.

353
00:18:39,020 --> 00:18:43,790
And I'm going to go into the matrix and here project settings.

354
00:18:43,790 --> 00:18:47,150
And I'll make sure that the room layer doesn't interact

355
00:18:47,150 --> 00:18:51,030
with the other room layers with the enemy bullets.

356
00:18:51,034 --> 00:18:54,004
And maybe we can even make sure that they don't interact with anything.

357
00:18:54,005 --> 00:18:57,205
Honestly, we don't need them except for the player.

358
00:18:57,200 --> 00:18:58,850
We want to go ahead.

359
00:18:58,850 --> 00:19:01,400
But for now, let's just make sure they don't interact with

360
00:19:01,400 --> 00:19:04,090
the bullets literature on if we do find a problem,

361
00:19:04,085 --> 00:19:06,355
this could be problematic and know what.

362
00:19:06,350 --> 00:19:07,640
Just for that reason,

363
00:19:07,640 --> 00:19:10,370
let's turn everything off, save that.

364
00:19:10,370 --> 00:19:12,560
Closed down from the game.

365
00:19:12,560 --> 00:19:14,320
The good doors should close.

366
00:19:14,315 --> 00:19:17,345
And if we shoot, something is still wrong.

367
00:19:17,345 --> 00:19:22,285
Oh, obviously we need to set it as the room layer yes.

368
00:19:22,280 --> 00:19:25,220
Changed children if you want to run the game or no,

369
00:19:25,220 --> 00:19:27,230
maybe the children shouldn't have been changed.

370
00:19:27,230 --> 00:19:30,260
Okay. So the door closes and we can shoot normally.

371
00:19:30,260 --> 00:19:32,690
Maybe the children shouldn't have been changed

372
00:19:32,690 --> 00:19:35,740
because I don't want the doors to be affected.

373
00:19:35,735 --> 00:19:37,975
Let's change this to default. Yes.

374
00:19:37,970 --> 00:19:40,720
Changed children. Okay. So now we can shoot the doors,

375
00:19:40,715 --> 00:19:45,115
but we can shoot around should the walls, should the doors.

376
00:19:45,110 --> 00:19:46,780
Yep. Everything is working fine.

377
00:19:46,775 --> 00:19:49,255
So from the future, I'm leaving.

378
00:19:49,250 --> 00:19:52,380
See you in the future future.

