1
00:00:00,000 --> 00:00:03,380
Welcome back, my fellow game developers.

2
00:00:03,375 --> 00:00:07,805
In this video, what we've done is when we run our game,

3
00:00:07,800 --> 00:00:10,880
you'll notice that as we are walking around,

4
00:00:10,875 --> 00:00:14,885
we can go through all the room and the camera keeps following us.

5
00:00:14,880 --> 00:00:18,150
And we do this using something called the Senate machine,

6
00:00:18,150 --> 00:00:24,840
which is an extremely powerful tool that we are going to be implementing in this video.

7
00:00:24,840 --> 00:00:26,660
So let's not waste any more time.

8
00:00:26,655 --> 00:00:29,105
And let's get to creating these cinema.

9
00:00:29,105 --> 00:00:31,215
Whoo, Look how cool that is now,

10
00:00:31,215 --> 00:00:32,615
our game is much,

11
00:00:32,610 --> 00:00:36,180
much nicer, feels much more professional, doesn't it?

12
00:00:36,180 --> 00:00:39,060
When you have a camera following, Let's not waste any more time.

13
00:00:39,060 --> 00:00:40,870
Let's get started.

14
00:00:40,900 --> 00:00:44,860
Okay, so welcome back.

15
00:00:44,855 --> 00:00:49,205
As you can see, I've created a sort of a,

16
00:00:49,205 --> 00:00:50,545
kind of a map.

17
00:00:50,540 --> 00:00:53,960
I think that just make this bigger me.

18
00:00:53,960 --> 00:00:56,080
Please undock it, please.

19
00:00:56,075 --> 00:00:57,185
Okay, there you go.

20
00:00:57,185 --> 00:00:57,995
Open this up.

21
00:00:57,995 --> 00:01:01,475
Okay, So this is the level that I created.

22
00:01:01,475 --> 00:01:03,715
It's not much, but it works.

23
00:01:03,710 --> 00:01:04,820
So as you can see,

24
00:01:04,820 --> 00:01:06,980
I've added these couple of windows.

25
00:01:06,980 --> 00:01:11,980
I hope you took the time to play around and understand how all of this works.

26
00:01:11,975 --> 00:01:16,015
It took me around two to three hours of playing around,

27
00:01:16,010 --> 00:01:19,850
making sure how everything looks and works and so on and so forth.

28
00:01:19,850 --> 00:01:22,780
But this is the result that we have.

29
00:01:22,775 --> 00:01:26,185
You can see I have a couple of, okay,

30
00:01:26,180 --> 00:01:28,300
this is a mistake right here, for example,

31
00:01:28,295 --> 00:01:31,285
you can see I've added a lot of black and the background.

32
00:01:31,280 --> 00:01:33,190
You'll know why in just a bit.

33
00:01:33,185 --> 00:01:36,965
I've made the walls right here that we cannot cross.

34
00:01:36,965 --> 00:01:39,445
And I've made a couple of walls right here are

35
00:01:39,440 --> 00:01:43,010
infused a couple of things together to create all of these.

36
00:01:43,010 --> 00:01:44,630
So a couple of black walls,

37
00:01:44,630 --> 00:01:46,540
a couple of natural causes,

38
00:01:46,535 --> 00:01:50,785
scholar, even reddish walls and so on and so forth.

39
00:01:50,780 --> 00:01:56,540
But the problem is if I make this window smaller, put it right here.

40
00:01:56,540 --> 00:01:59,120
Phi 12, run the game.

41
00:01:59,120 --> 00:02:00,370
So there you go.

42
00:02:00,365 --> 00:02:01,795
If I run the game,

43
00:02:01,790 --> 00:02:04,100
I can walk around and this whole map,

44
00:02:04,100 --> 00:02:08,510
but I cannot see myself in the game view.

45
00:02:08,510 --> 00:02:11,570
So imagine if we didn't have the scene view,

46
00:02:11,570 --> 00:02:14,060
how would we be able to see ourselves?

47
00:02:14,060 --> 00:02:15,440
And actually you can test it out.

48
00:02:15,440 --> 00:02:17,150
You can maximize on play.

49
00:02:17,150 --> 00:02:18,770
So when we run the game,

50
00:02:18,770 --> 00:02:20,200
we will have a full-screen.

51
00:02:20,195 --> 00:02:21,805
Okay, so now I want to walk away,

52
00:02:21,800 --> 00:02:23,330
but there you go.

53
00:02:23,330 --> 00:02:24,820
You cannot see anything.

54
00:02:24,815 --> 00:02:27,355
Whereas the player, please, oh, there you go.

55
00:02:27,350 --> 00:02:29,690
There we are. And now we try to shoot.

56
00:02:29,690 --> 00:02:30,950
There is a bit of a delay,

57
00:02:30,950 --> 00:02:33,530
a bit of a lag, but no worries about that.

58
00:02:33,530 --> 00:02:37,160
Anyways, how are we going to fix that?

59
00:02:37,160 --> 00:02:40,040
Well, what we can do is we can go ahead and attach

60
00:02:40,040 --> 00:02:42,830
the camera to the doom player and make it a child.

61
00:02:42,830 --> 00:02:47,570
And remember that the camera or a child always moves with the player.

62
00:02:47,570 --> 00:02:49,640
So if I run the game right now,

63
00:02:49,640 --> 00:02:53,300
there you go, problem fixed now we have a fall camp.

64
00:02:53,300 --> 00:02:55,870
I hope you enjoyed the video and I'll see you in the next one.

65
00:02:55,865 --> 00:02:57,005
I'm just getting.

66
00:02:57,005 --> 00:02:59,615
And what we're going to do is use

67
00:02:59,615 --> 00:03:04,415
a much more sophisticated technique in order to have our follicle.

68
00:03:04,415 --> 00:03:08,215
So I'm just going to remove the main camera from the doom player,

69
00:03:08,210 --> 00:03:12,220
child or parent, whatever you wanna call it, save that.

70
00:03:12,215 --> 00:03:14,935
And then we are going to go into the window.

71
00:03:14,930 --> 00:03:20,200
The package manager wait for Riunite to fetch our packages.

72
00:03:20,195 --> 00:03:22,225
And any day now.

73
00:03:22,220 --> 00:03:25,730
And in here we are going to go into

74
00:03:25,730 --> 00:03:30,250
the Unity Registry and we are going to find this machine right here.

75
00:03:30,245 --> 00:03:31,735
When you find some machines,

76
00:03:31,730 --> 00:03:33,130
simply click on Install,

77
00:03:33,125 --> 00:03:35,045
wait for it to install.

78
00:03:35,045 --> 00:03:39,655
And when it's finished installing,

79
00:03:39,650 --> 00:03:41,300
you can read more about.

80
00:03:41,300 --> 00:03:47,260
So you can see right here it's a smart camera tool for passionate creators. Very nice.

81
00:03:47,255 --> 00:03:49,915
So we'll have this extra tab appear,

82
00:03:49,910 --> 00:03:51,530
which is the cinema machine.

83
00:03:51,530 --> 00:03:55,520
And you can see that we can create a lot of things with cinema machine.

84
00:03:55,520 --> 00:03:59,950
And the one that we really want is to create a virtual camera.

85
00:03:59,945 --> 00:04:01,435
So let's do that.

86
00:04:01,430 --> 00:04:03,560
We're going to create a virtual camera.

87
00:04:03,560 --> 00:04:04,670
You'll see it right here.

88
00:04:04,670 --> 00:04:10,210
The C and V Canvas just call it the virtual camera.

89
00:04:10,205 --> 00:04:11,405
Hit Enter.

90
00:04:11,405 --> 00:04:14,695
I'm going to set it right here next to the main camera.

91
00:04:14,690 --> 00:04:16,090
And on the main camera,

92
00:04:16,085 --> 00:04:18,365
I'm going to go into the inspector.

93
00:04:18,365 --> 00:04:21,025
And immediately I can see right here that

94
00:04:21,020 --> 00:04:23,930
we've added something called the cinema machine brain.

95
00:04:23,930 --> 00:04:26,780
And if you still don't have this component on your camera,

96
00:04:26,780 --> 00:04:32,770
make sure to add it because this is what will allow us to use the virtual camera.

97
00:04:32,765 --> 00:04:35,425
So what is the virtual camera?

98
00:04:35,420 --> 00:04:39,040
You can see that it's just a transform with this component,

99
00:04:39,035 --> 00:04:41,995
which is a center machine virtual camera.

100
00:04:41,990 --> 00:04:45,590
Keep this in mind. I'm going to open up and you can see

101
00:04:45,590 --> 00:04:49,490
that we have a lot of things that we can add,

102
00:04:49,490 --> 00:04:51,620
we can change, we can play around.

103
00:04:51,620 --> 00:04:56,930
I'm not going to go into every single detail in here because there is a lot.

104
00:04:56,930 --> 00:05:00,460
What I'm going to do is I'm going to first of all,

105
00:05:00,455 --> 00:05:03,485
right-click and the hierarchy.

106
00:05:03,485 --> 00:05:08,785
And I'm going to actually set this all 200 000.

107
00:05:08,780 --> 00:05:12,410
And you can see that we have something that just disappeared.

108
00:05:12,410 --> 00:05:18,730
And what seems to be the problem in here, virtual camera.

109
00:05:18,725 --> 00:05:21,275
So the main camera.

110
00:05:21,275 --> 00:05:24,715
Okay, so if I go into the 3D mode,

111
00:05:24,710 --> 00:05:29,000
you'll notice that when the z is 0 means it's in front,

112
00:05:29,000 --> 00:05:31,280
so we can't, we actually are looking from behind.

113
00:05:31,280 --> 00:05:33,710
What I need to do is just move it slightly.

114
00:05:33,710 --> 00:05:39,050
Back so we can see the view and you can see the camera in 3D right here.

115
00:05:39,050 --> 00:05:41,560
These white lines represent what the camera sees.

116
00:05:41,555 --> 00:05:43,535
I'm going to go back into 2D,

117
00:05:43,535 --> 00:05:45,805
and then I'm going in the virtual camera.

118
00:05:45,800 --> 00:05:49,340
You can see right here that we have an option for the follow and the

119
00:05:49,340 --> 00:05:53,440
object that the camera wants to move with or the body and target.

120
00:05:53,435 --> 00:05:58,285
So what is the object that I want to move with the doom player?

121
00:05:58,280 --> 00:06:00,550
So I'm going to add the doom player,

122
00:06:00,545 --> 00:06:02,945
and I'm going to save all of that.

123
00:06:02,945 --> 00:06:06,445
Let's also make sure that we have these cameras nicely feathered.

124
00:06:06,440 --> 00:06:09,160
So I'm going to create an empty game object,

125
00:06:09,155 --> 00:06:14,585
reset its position is going to be the cameras.

126
00:06:14,585 --> 00:06:20,165
And let's just make sure that these two cameras are a child of the cameras.

127
00:06:20,165 --> 00:06:22,705
And now we have them set up properly.

128
00:06:22,700 --> 00:06:25,460
Save that when I run the game, There you go.

129
00:06:25,460 --> 00:06:27,080
You can see that now I have

130
00:06:27,080 --> 00:06:32,290
a very nice follow cam that follows the player anywhere he goes.

131
00:06:32,285 --> 00:06:37,345
But there are a lot of things that we can change using this camera.

132
00:06:37,340 --> 00:06:39,460
So I'm going to first of all,

133
00:06:39,455 --> 00:06:40,705
get out of clay mold,

134
00:06:40,700 --> 00:06:43,130
make sure that we don't maximize on play.

135
00:06:43,130 --> 00:06:45,620
And I'm going to go into the virtual camera.

136
00:06:45,620 --> 00:06:48,550
And what are all of these things right here?

137
00:06:48,545 --> 00:06:52,525
You can see that we can change this from transpose to other things.

138
00:06:52,520 --> 00:06:57,130
As I've said, Go and look up what all of these things.

139
00:06:57,125 --> 00:07:01,855
But one of the things that we mainly want to change is decomposed right here.

140
00:07:01,850 --> 00:07:03,850
And you can see the look is required.

141
00:07:03,845 --> 00:07:06,055
You can choose something different.

142
00:07:06,050 --> 00:07:08,780
You can choose to do nothing with the aim.

143
00:07:08,780 --> 00:07:11,200
These are all options that you can use.

144
00:07:11,195 --> 00:07:16,565
And in here you can see that we can change this to framing transpose.

145
00:07:16,565 --> 00:07:18,985
So change the body to framing transpose.

146
00:07:18,980 --> 00:07:20,380
If you add the lookahead,

147
00:07:20,375 --> 00:07:23,345
if I add the dome player and the look ahead, look what changes.

148
00:07:23,345 --> 00:07:25,085
So now when I play the game,

149
00:07:25,085 --> 00:07:27,635
you'll see something just a little bit different.

150
00:07:27,635 --> 00:07:32,065
I think know until now seems to be the same.

151
00:07:32,060 --> 00:07:33,620
You can keep the look ahead.

152
00:07:33,620 --> 00:07:35,780
You can change, play around with the options.

153
00:07:35,780 --> 00:07:39,230
I'm just going to show you the main things in here.

154
00:07:39,230 --> 00:07:41,510
So in the body, first of all,

155
00:07:41,510 --> 00:07:43,820
you can see the windows right here,

156
00:07:43,820 --> 00:07:45,320
the different colors in the game.

157
00:07:45,320 --> 00:07:48,320
It's because the game Windows guide right here in the Inspector,

158
00:07:48,320 --> 00:07:50,690
I can turn them on and off.

159
00:07:50,690 --> 00:07:52,450
So what do we have?

160
00:07:52,445 --> 00:07:54,515
First of all, we have the look ahead,

161
00:07:54,515 --> 00:07:55,945
we have the lookahead smoothing,

162
00:07:55,940 --> 00:07:57,670
we have the x damping,

163
00:07:57,665 --> 00:07:59,455
damping and so on and so forth.

164
00:07:59,450 --> 00:08:02,960
I don't even know most of the things what they do exactly.

165
00:08:02,960 --> 00:08:07,340
But a very good trick that you can do is you can actually go ahead and

166
00:08:07,340 --> 00:08:12,350
increase this to its maximum and then play the game and see what happens.

167
00:08:12,350 --> 00:08:15,200
So as you can see, yep, there we go.

168
00:08:15,200 --> 00:08:18,040
So the camera is faster than the player.

169
00:08:18,035 --> 00:08:20,855
And this is because the look ahead is very strong.

170
00:08:20,855 --> 00:08:23,395
So if I smooth down the look ahead,

171
00:08:23,390 --> 00:08:27,340
you'll notice that as we are walking the cameras starts moving

172
00:08:27,335 --> 00:08:31,315
in front of the player and it's represented by this yellow small dot.

173
00:08:31,310 --> 00:08:36,470
And here you can see that the dot predicts where the player is about to go and

174
00:08:36,470 --> 00:08:41,660
sets the camera to go there just a little bit faster than the player.

175
00:08:41,660 --> 00:08:46,130
If I set it to 0, it will simply move with the player as he's going.

176
00:08:46,130 --> 00:08:50,960
We can increase the smoothing a little bit increased look ahead smoothing.

177
00:08:50,960 --> 00:08:53,980
So now you can see it's a little bit smoother,

178
00:08:53,975 --> 00:08:55,375
a little bit nicer.

179
00:08:55,370 --> 00:08:57,340
And that, There you go.

180
00:08:57,335 --> 00:08:58,585
What else do we have?

181
00:08:58,580 --> 00:09:00,080
We can ignore the y,

182
00:09:00,080 --> 00:09:04,660
so that will change the way it looks in the y direction.

183
00:09:04,655 --> 00:09:07,105
And let's see what else do we have?

184
00:09:07,100 --> 00:09:08,510
We have the x damping,

185
00:09:08,510 --> 00:09:11,510
so let's put this to 20 and see what happens.

186
00:09:11,510 --> 00:09:12,230
So there you go.

187
00:09:12,230 --> 00:09:17,840
You can see that when the player hits the red side of this square or rectangle,

188
00:09:17,840 --> 00:09:20,750
you can see that then the camera starts moving and if not,

189
00:09:20,750 --> 00:09:25,750
it's slowly, slowly goes to the x, or you can set it to 0.

190
00:09:25,745 --> 00:09:27,965
And in that case, whenever we are moving,

191
00:09:27,965 --> 00:09:30,685
it's immediately following the layer.

192
00:09:30,680 --> 00:09:32,450
Let's set it back to one.

193
00:09:32,450 --> 00:09:33,890
Let's see what else we have.

194
00:09:33,890 --> 00:09:36,190
We have the y damping, V, z damping.

195
00:09:36,185 --> 00:09:38,095
Let's see, we have the screen x.

196
00:09:38,090 --> 00:09:43,160
Let's see if we move it so we can play our game with the player being able to the right.

197
00:09:43,160 --> 00:09:45,730
We can set it to be in the middle,

198
00:09:45,725 --> 00:09:48,715
or we can set the widescreen to be at the bottom.

199
00:09:48,710 --> 00:09:50,050
So there you go.

200
00:09:50,045 --> 00:09:51,445
We have the camera distance,

201
00:09:51,440 --> 00:09:53,320
which is a very nice touch,

202
00:09:53,315 --> 00:09:54,985
and it's currently not working.

203
00:09:54,980 --> 00:09:59,360
Maybe it's because the camera right here should have a bigger size.

204
00:09:59,360 --> 00:10:01,570
I'm not sure what the problem here is.

205
00:10:01,565 --> 00:10:03,985
And let's reset it.

206
00:10:03,980 --> 00:10:07,100
So back in here, reset everything.

207
00:10:07,100 --> 00:10:08,620
So let's keep it at 10.

208
00:10:08,615 --> 00:10:10,955
We have the dead zone width.

209
00:10:10,955 --> 00:10:15,575
So if I increase the dead zone width on the y and on the x, look what happens.

210
00:10:15,575 --> 00:10:17,905
If I move up and down and left and right,

211
00:10:17,900 --> 00:10:19,010
it stays in place.

212
00:10:19,010 --> 00:10:21,040
And if I go outside the bounds,

213
00:10:21,035 --> 00:10:25,615
then we start going while the camera starts going with the player.

214
00:10:25,610 --> 00:10:29,450
So this is also something that you can tweak and play around.

215
00:10:29,450 --> 00:10:33,040
And actually I'd like to make it just a little bit small.

216
00:10:33,035 --> 00:10:35,485
So for example, if I walk around,

217
00:10:35,480 --> 00:10:38,140
nothing happens and then when I start moving,

218
00:10:38,135 --> 00:10:41,035
the camera starts following the player.

219
00:10:41,030 --> 00:10:46,540
Okay, let's make it around zero-point two by 0.2.

220
00:10:46,535 --> 00:10:47,425
And there we go.

221
00:10:47,420 --> 00:10:49,400
So we can move a little bit around.

222
00:10:49,400 --> 00:10:53,680
But when we go outside the bounds than the cameras starts following us.

223
00:10:53,675 --> 00:10:54,685
Okay, Very nice.

224
00:10:54,680 --> 00:10:55,610
What else do we have?

225
00:10:55,610 --> 00:11:01,790
We have the zone depth that's tried to put it to 100, see what happens.

226
00:11:01,789 --> 00:11:04,879
Not sure what exactly does.

227
00:11:04,880 --> 00:11:07,070
But let's keep it at 0.

228
00:11:07,070 --> 00:11:08,510
See what happens now?

229
00:11:08,510 --> 00:11:09,020
Yep.

230
00:11:09,020 --> 00:11:09,950
Oh, okay.

231
00:11:09,950 --> 00:11:12,400
Seems to change a lot.

232
00:11:12,395 --> 00:11:14,425
I think Let's put it to 20.

233
00:11:14,420 --> 00:11:15,920
Nothing, nothing happens.

234
00:11:15,920 --> 00:11:17,390
Let's keep it at 20.

235
00:11:17,390 --> 00:11:19,360
The soft zone width,

236
00:11:19,355 --> 00:11:21,745
I think the South Zone is the red square.

237
00:11:21,740 --> 00:11:23,270
So if I set it to,

238
00:11:23,270 --> 00:11:25,930
let's say, being small, what happens then?

239
00:11:25,925 --> 00:11:30,895
I can't even get outside because of the heart or the dead zone width.

240
00:11:30,890 --> 00:11:32,570
Okay, no worries about that.

241
00:11:32,570 --> 00:11:33,850
Reset the position.

242
00:11:33,845 --> 00:11:35,695
Let's see we have the bias.

243
00:11:35,690 --> 00:11:41,290
So what happens? Okay, So now the red zone is biased towards the blue zone,

244
00:11:41,285 --> 00:11:44,795
and you can go ahead and search all of these yourself.

245
00:11:44,795 --> 00:11:49,885
And the only thing here is that virtual camera as a whole world by itself.

246
00:11:49,880 --> 00:11:52,100
So if I want to go into every single detail,

247
00:11:52,100 --> 00:11:55,370
I think I need a whole section by itself.

248
00:11:55,370 --> 00:11:58,960
But using Cinema machine as an incredibly powerful

249
00:11:58,955 --> 00:12:03,175
and one of the most modern tools that we have in our possession.

250
00:12:03,170 --> 00:12:08,270
So I do recommend what you do is play around with all these settings.

251
00:12:08,270 --> 00:12:10,100
See what works, see what doesn't.

252
00:12:10,100 --> 00:12:11,900
But remember as you saw right now,

253
00:12:11,900 --> 00:12:15,320
all the changes that we made went back or got reset.

254
00:12:15,320 --> 00:12:15,560
Why?

255
00:12:15,560 --> 00:12:18,670
Because all the changes that we make inside of

256
00:12:18,665 --> 00:12:23,095
the game mode are then reset when we stop playing the game.

257
00:12:23,090 --> 00:12:26,180
With that information, I recommend that you go

258
00:12:26,180 --> 00:12:29,290
through Unity's documentation of the Senate machine,

259
00:12:29,285 --> 00:12:31,645
see what happens, see what you can use.

260
00:12:31,640 --> 00:12:33,920
So for example, we have something called the noise,

261
00:12:33,920 --> 00:12:37,240
which we will be using in a couple of videos to make

262
00:12:37,235 --> 00:12:41,245
our shooting mechanics just a little bit more impactful.

263
00:12:41,240 --> 00:12:44,320
And was that done before I go,

264
00:12:44,315 --> 00:12:46,615
let me issue you a small challenge and

265
00:12:46,610 --> 00:12:49,760
your challenge is going to be to set up your machine.

266
00:12:49,760 --> 00:12:53,470
So play around with all the settings you have on the same machine.

267
00:12:53,465 --> 00:12:56,435
The best way to know what each thing does is by

268
00:12:56,435 --> 00:13:00,235
taking it to the max and see what happens then.

269
00:13:00,230 --> 00:13:02,810
Well, that information, I hope you enjoy it.

270
00:13:02,810 --> 00:13:04,330
And in the next video,

271
00:13:04,325 --> 00:13:08,365
we are going to be creating the doors or whatever you wanna call them,

272
00:13:08,360 --> 00:13:09,590
you can call them doors,

273
00:13:09,590 --> 00:13:12,530
or you can call them the places where we move from

274
00:13:12,530 --> 00:13:15,890
one level to the next to the exit levels, whatever you wanna call them.

275
00:13:15,890 --> 00:13:16,940
So well that done.

276
00:13:16,940 --> 00:13:20,940
I hope you enjoy it and I'll see you in the next video.

