1
00:00:00,000 --> 00:00:03,510
Hey, welcome back, my fellow game developers.

2
00:00:03,510 --> 00:00:05,880
So as you can see what I've promised you

3
00:00:05,880 --> 00:00:08,550
that we are going to make it a little bit better.

4
00:00:08,550 --> 00:00:10,470
I've delivered on my promise.

5
00:00:10,470 --> 00:00:11,880
Now when we run the game,

6
00:00:11,880 --> 00:00:16,410
you'll notice that there are no blue spots, no blue lines.

7
00:00:16,410 --> 00:00:17,610
And if I walked through,

8
00:00:17,610 --> 00:00:18,830
I tried to walk through this.

9
00:00:18,825 --> 00:00:21,435
It's a wall. If I walk up, It's a wall.

10
00:00:21,435 --> 00:00:24,255
Obviously, we have a couple of things that we can change.

11
00:00:24,255 --> 00:00:25,895
If you look closely in Scene mode,

12
00:00:25,890 --> 00:00:28,200
obviously, it's not perfect yet,

13
00:00:28,200 --> 00:00:30,000
but you can see when I shoot a wall,

14
00:00:30,000 --> 00:00:31,710
it is a wall from the back,

15
00:00:31,710 --> 00:00:34,490
from the front, and the enemy still chases us.

16
00:00:34,485 --> 00:00:37,215
Everything is good, everything works fine.

17
00:00:37,215 --> 00:00:41,995
So let's not waste any more time and let's get started.

18
00:00:41,990 --> 00:00:44,200
Oh, case.

19
00:00:44,200 --> 00:00:50,530
So now that we have set up everything time to use it in a proper way.

20
00:00:50,530 --> 00:00:53,800
So the first thing that we need to understand is

21
00:00:53,800 --> 00:00:57,990
the tile map and what the inspector of that tile map does.

22
00:00:57,985 --> 00:01:00,945
So we've created the walls, the ground,

23
00:01:00,940 --> 00:01:03,690
and you can see that they also have,

24
00:01:03,685 --> 00:01:08,715
each one of them has a tile map component and a tile map renderer.

25
00:01:08,710 --> 00:01:13,180
Because the tile map renderer works just like the sprite renderer,

26
00:01:13,180 --> 00:01:14,950
we can also choose a layer.

27
00:01:14,950 --> 00:01:19,500
So for example, I can go to the ground and choose the layer background,

28
00:01:19,495 --> 00:01:21,835
the walls, the layer background.

29
00:01:21,835 --> 00:01:23,325
And I can make, for example,

30
00:01:23,320 --> 00:01:27,080
the walls one and the Ground Zero.

31
00:01:27,080 --> 00:01:28,610
You can play around if you want.

32
00:01:28,610 --> 00:01:31,670
You can even create your own sorting layer depending on

33
00:01:31,670 --> 00:01:35,210
how many things you want to be in the foreground or background.

34
00:01:35,210 --> 00:01:37,640
So I'm going to, first of all,

35
00:01:37,640 --> 00:01:41,150
delete everything or erase everything, should I say?

36
00:01:41,150 --> 00:01:46,670
So I erase everything and you can see why is this not getting erased.

37
00:01:46,670 --> 00:01:49,310
So let me just make the screen bigger.

38
00:01:49,310 --> 00:01:51,610
Why is this not getting a raise?

39
00:01:51,605 --> 00:01:55,705
Well, because we are using where is it?

40
00:01:55,700 --> 00:01:57,620
The active tile map is the ground.

41
00:01:57,620 --> 00:02:00,850
So we can only delete things that are on the ground.

42
00:02:00,845 --> 00:02:02,485
If I choose the walls.

43
00:02:02,480 --> 00:02:09,020
There you go. I can now delete it because when I created this, I used walls.

44
00:02:09,020 --> 00:02:11,110
So let's just do a little test.

45
00:02:11,105 --> 00:02:13,835
Now that we have the sorting layers setup,

46
00:02:13,835 --> 00:02:16,675
I'm going to create this big square right here,

47
00:02:16,670 --> 00:02:18,790
which is, oops, not the ground,

48
00:02:18,785 --> 00:02:20,585
excuse me, the ground.

49
00:02:20,585 --> 00:02:25,525
And now I'm going to create this little ground right here.

50
00:02:25,520 --> 00:02:30,650
And now if I go into the walls and let's go ahead and add this one.

51
00:02:30,650 --> 00:02:34,310
So you remember why did we have the blue lines before?

52
00:02:34,310 --> 00:02:36,650
Because we had these outlines right here.

53
00:02:36,650 --> 00:02:38,380
You can see that they are transparent,

54
00:02:38,375 --> 00:02:41,045
so they only reflect what was behind.

55
00:02:41,045 --> 00:02:42,985
So now because these are,

56
00:02:42,980 --> 00:02:44,290
let me click on this one.

57
00:02:44,285 --> 00:02:49,135
So now because this is the walls and the walls are rendered in front of the background.

58
00:02:49,130 --> 00:02:51,200
When I put them here, there you go,

59
00:02:51,200 --> 00:02:53,290
you can see that there are no longer

60
00:02:53,285 --> 00:02:58,225
any blue lines behind which represent the color of the background of the camera.

61
00:02:58,220 --> 00:03:00,470
I can also do this right here.

62
00:03:00,470 --> 00:03:01,970
So I'm going to select them.

63
00:03:01,970 --> 00:03:04,210
And you can see because they are walls,

64
00:03:04,205 --> 00:03:07,255
I can immediately draw on top of them.

65
00:03:07,250 --> 00:03:09,730
But you can see right now to inconsistency,

66
00:03:09,725 --> 00:03:11,365
how do I, for example,

67
00:03:11,360 --> 00:03:15,500
drought is to have a continuous third wall and fourth wall.

68
00:03:15,500 --> 00:03:16,990
Well, in that case,

69
00:03:16,985 --> 00:03:19,075
we'll need to select something different,

70
00:03:19,070 --> 00:03:22,540
which is these lines right here.

71
00:03:22,535 --> 00:03:27,785
And now we can add the illusion or create the illusion that we have.

72
00:03:27,785 --> 00:03:32,975
Let me just create the illusion that we have these all connected together.

73
00:03:32,975 --> 00:03:34,555
And if you look in the game,

74
00:03:34,550 --> 00:03:35,740
if I run the game,

75
00:03:35,735 --> 00:03:37,795
Also, it doesn't matter.

76
00:03:37,790 --> 00:03:40,760
Let me just make this game window bigger. There you go.

77
00:03:40,760 --> 00:03:43,280
You can see how all of that looks at,

78
00:03:43,280 --> 00:03:45,890
looks as if we have everything normally

79
00:03:45,890 --> 00:03:49,220
setup and we can just run the game and walk around.

80
00:03:49,220 --> 00:03:53,650
And then you go, you can see that I can walk around on top of this.

81
00:03:53,645 --> 00:03:55,735
Everything works perfectly fine.

82
00:03:55,730 --> 00:03:59,120
But the problem is that now I can walk through

83
00:03:59,120 --> 00:04:02,810
the walls and this is usually not a huge problem,

84
00:04:02,810 --> 00:04:06,260
but having your player leave forever plus,

85
00:04:06,260 --> 00:04:08,260
plus when we are shooting,

86
00:04:08,255 --> 00:04:11,305
you can see that the bullets will keep on going

87
00:04:11,300 --> 00:04:14,570
forever because they are not interacting with anything.

88
00:04:14,570 --> 00:04:16,340
Or we don't have any more walls,

89
00:04:16,340 --> 00:04:18,380
they are not interacting with the walls.

90
00:04:18,380 --> 00:04:21,100
So how are we going to fix this?

91
00:04:21,095 --> 00:04:26,015
Well, we can go ahead and start adding colliders and all of that good stuff.

92
00:04:26,015 --> 00:04:31,325
But obviously this is not the most efficient solution of solving the problem.

93
00:04:31,325 --> 00:04:33,235
What we can do, on the other hand,

94
00:04:33,230 --> 00:04:36,610
add something called a tile map collider.

95
00:04:36,605 --> 00:04:38,245
So if I go onto the walls,

96
00:04:38,240 --> 00:04:40,190
and that is why we've created walls,

97
00:04:40,190 --> 00:04:41,500
not just the ground.

98
00:04:41,495 --> 00:04:43,145
Go to the Inspector.

99
00:04:43,145 --> 00:04:46,195
I can add a component in here which is going to be

100
00:04:46,190 --> 00:04:51,190
the tile map collider 2D. And there you go.

101
00:04:51,185 --> 00:04:57,835
You can see that now everything under the walls has the green collider on him.

102
00:04:57,830 --> 00:04:59,800
And you can see that they are intersecting.

103
00:04:59,795 --> 00:05:02,215
Why? Because we made them just a little bit

104
00:05:02,210 --> 00:05:05,330
bigger than where's the picture? There you go.

105
00:05:05,330 --> 00:05:09,350
We made them just a little bit bigger than 16. We made them 15.

106
00:05:09,350 --> 00:05:15,370
If I make them 16, I think we can start seeing cracks in between each sprite.

107
00:05:15,365 --> 00:05:17,795
Now you know what? It looks good enough.

108
00:05:17,795 --> 00:05:19,915
I think there is no discrepancy in.

109
00:05:19,910 --> 00:05:21,890
Okay, so let's keep it at 16.

110
00:05:21,890 --> 00:05:25,000
So I changed the pixels per unit to 16.

111
00:05:24,995 --> 00:05:26,875
And now if I choose the walls,

112
00:05:26,870 --> 00:05:28,640
there is still an intersection,

113
00:05:28,640 --> 00:05:31,880
but that's okay, that's not a huge problem.

114
00:05:31,880 --> 00:05:33,880
Let me just demonstrate that this works.

115
00:05:33,875 --> 00:05:35,395
So now if I run,

116
00:05:35,390 --> 00:05:39,830
you can see that I hit a wall and I cannot go through it anymore.

117
00:05:39,830 --> 00:05:41,680
Excellent, everything is working.

118
00:05:41,675 --> 00:05:43,315
They are on the default layer.

119
00:05:43,310 --> 00:05:46,940
You can change the layer if you want also of each tile map.

120
00:05:46,940 --> 00:05:49,940
But now there is something that we need to add this,

121
00:05:49,940 --> 00:05:52,490
adding this glider is not enough.

122
00:05:52,490 --> 00:05:56,900
What we do is we need to add something called a composite glider.

123
00:05:56,899 --> 00:06:02,689
Why? Let me show you how that will change everything and you'll understand by yourself.

124
00:06:02,690 --> 00:06:05,910
So now that I've added a composite Collider,

125
00:06:05,914 --> 00:06:09,814
you'll notice that I also added a automatically a rigid body.

126
00:06:09,815 --> 00:06:13,475
So a rigid body is required when you have a composite collider.

127
00:06:13,474 --> 00:06:16,924
And if you look right here in the tile map collider,

128
00:06:16,924 --> 00:06:20,374
you can see that we have something called used by compass.

129
00:06:20,375 --> 00:06:23,185
If I turn this on, there you go.

130
00:06:23,180 --> 00:06:26,900
You see that we no longer have a lot of gliders.

131
00:06:26,900 --> 00:06:28,130
That means just do that again,

132
00:06:28,130 --> 00:06:32,500
uncheck the US by composite will notice that we have a lot of colliders.

133
00:06:32,495 --> 00:06:34,475
When I do use the composite,

134
00:06:34,474 --> 00:06:38,184
we only have one collider on all the shapes.

135
00:06:38,180 --> 00:06:40,640
This is extremely helpful.

136
00:06:40,640 --> 00:06:44,390
I cannot emphasize the fact how much this saves

137
00:06:44,390 --> 00:06:48,740
energy and computational power from our compute.

138
00:06:48,740 --> 00:06:54,800
This will allow us to create a single collider around a lot of entangled gliders.

139
00:06:54,799 --> 00:06:59,809
So make sure that you add a composite collider 2D with that.

140
00:06:59,810 --> 00:07:00,610
Understood.

141
00:07:00,605 --> 00:07:03,545
Now, it's time for a small challenge.

142
00:07:03,545 --> 00:07:04,835
Or before we do that,

143
00:07:04,835 --> 00:07:10,265
I just want to run the game to maybe make you understand what the challenges.

144
00:07:10,265 --> 00:07:11,755
If I run the game.

145
00:07:11,750 --> 00:07:13,400
And there you go,

146
00:07:13,400 --> 00:07:20,720
you can see that something is definitely seriously make this part of your game some,

147
00:07:20,720 --> 00:07:22,400
at some kinds of mechanics of the game.

148
00:07:22,400 --> 00:07:26,050
So the player plays around with the game and with the map.

149
00:07:26,045 --> 00:07:30,445
So hey, the, let me just zoom out a bit so you can see that

150
00:07:30,440 --> 00:07:35,060
the map isn't behaving completely how it should be.

151
00:07:35,060 --> 00:07:36,820
I think that's an understatement.

152
00:07:36,815 --> 00:07:39,895
Let me just try to push that off and there you go.

153
00:07:39,890 --> 00:07:46,010
So now we no longer have a map and it keeps falling so well that understood.

154
00:07:46,010 --> 00:07:51,280
Out of the way, that thing we'd think I'm not fix the problem was the following map.

155
00:07:51,275 --> 00:07:52,795
If you don't want any hints,

156
00:07:52,790 --> 00:07:53,810
you know how to fix this.

157
00:07:53,810 --> 00:07:56,060
Pause the video right now, go to the challenge.

158
00:07:56,060 --> 00:07:59,420
If not, check in the inspector on the tile map,

159
00:07:59,420 --> 00:08:01,100
you'll see a rigid body.

160
00:08:01,100 --> 00:08:04,430
This means that we have a gravity being applied.

161
00:08:04,430 --> 00:08:07,420
Either remove the gravity scale or even better,

162
00:08:07,415 --> 00:08:11,825
you can make the whole object either kinematic or static.

163
00:08:11,825 --> 00:08:15,235
I would recommend static because static means it will never move

164
00:08:15,230 --> 00:08:19,460
and obviously our map shouldn't move unless you want to,

165
00:08:19,460 --> 00:08:22,000
I don't know, add the rotating map.

166
00:08:21,995 --> 00:08:24,325
Weird thing that we just experienced.

167
00:08:24,320 --> 00:08:25,630
So with that done,

168
00:08:25,625 --> 00:08:27,095
pause the video right now,

169
00:08:27,095 --> 00:08:30,005
go do the Chaldean.

170
00:08:30,005 --> 00:08:32,245
Okay, welcome back.

171
00:08:32,240 --> 00:08:34,490
So how did you get on with that?

172
00:08:34,490 --> 00:08:44,680
I'm going to go ahead and whereas the walls rigid body make the static, run the game.

173
00:08:44,675 --> 00:08:48,595
And now we should see that there is nothing falling anymore

174
00:08:48,590 --> 00:08:52,460
and all the colliders work perfectly fine.

175
00:08:52,460 --> 00:08:55,180
Okay, with that done, I hope you enjoy it.

176
00:08:55,175 --> 00:08:56,395
And in the next video,

177
00:08:56,390 --> 00:08:58,610
make sure to create some kind of map.

178
00:08:58,610 --> 00:09:02,950
It should be bigger than the camera because we will be implementing a fall camp.

179
00:09:02,945 --> 00:09:04,435
So why is that?

180
00:09:04,430 --> 00:09:07,810
Well, if I let's say add a bit more ground here,

181
00:09:07,805 --> 00:09:10,015
make sure that we have the ground selected.

182
00:09:10,010 --> 00:09:11,150
I add the ground.

183
00:09:11,150 --> 00:09:13,670
Let's see if I make this a huge ground.

184
00:09:13,670 --> 00:09:18,680
I run the game. I want to be able to walk around our map and runway,

185
00:09:18,680 --> 00:09:20,870
just like the game that we saw in the beginning.

186
00:09:20,870 --> 00:09:23,600
So I want to have the freedom to walk around.

187
00:09:23,600 --> 00:09:26,500
But obviously, if I look in the game menu,

188
00:09:26,495 --> 00:09:28,135
I cannot see anything.

189
00:09:28,130 --> 00:09:29,650
I can see it in the scene mode.

190
00:09:29,645 --> 00:09:32,665
I can not see it in our game. Why?

191
00:09:32,660 --> 00:09:34,280
Because the camera right here,

192
00:09:34,280 --> 00:09:37,640
you can see, let me just this is the camera,

193
00:09:37,640 --> 00:09:39,160
this is the main camera,

194
00:09:39,155 --> 00:09:43,915
so we will have to move it around so we can always follow the player.

195
00:09:43,910 --> 00:09:48,250
And that is something that we'll learn in the next video when it comes to cinema cine,

196
00:09:48,245 --> 00:09:49,615
I hope you are enjoying,

197
00:09:49,610 --> 00:09:52,830
I hope you are always committing your changes.

198
00:09:52,834 --> 00:09:57,294
And I hope you've left a review because it helps me out a lot.

199
00:09:57,290 --> 00:09:59,760
See you in the next video.

