Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,000 --> 00:00:01,000
Unreal Engine is a 3D computer Graphics
2
00:00:02,460 --> 00:00:03,460
game engine that has been used to create
3
00:00:04,440 --> 00:00:05,440
many popular games in this full course
4
00:00:06,839 --> 00:00:07,839
for beginners tsurav will teach you how
5
00:00:09,000 --> 00:00:10,000
to use Unreal Engine 5. surov has seven
6
00:00:11,639 --> 00:00:12,639
years of game development experience and
7
00:00:13,799 --> 00:00:14,799
has developed multiple games hi there
8
00:00:16,260 --> 00:00:17,260
game devs welcome to my beginner to
9
00:00:18,779 --> 00:00:19,779
Advanced game development course on
10
00:00:21,300 --> 00:00:22,300
Unreal Engine 5. in this course we'll be
11
00:00:24,480 --> 00:00:25,480
taking a deep dive into the engine and
12
00:00:27,240 --> 00:00:28,240
hopefully by the end of this course you
13
00:00:29,400 --> 00:00:30,400
would be able to create a game
14
00:00:30,840 --> 00:00:31,840
completely by yourself
15
00:00:33,660 --> 00:00:34,660
foreign
16
00:00:36,140 --> 00:00:37,140
start developing a game in Unreal Engine
17
00:00:38,760 --> 00:00:39,760
some of you guys may have a question on
18
00:00:41,280 --> 00:00:42,280
what sort of a system to get for Unreal
19
00:00:43,500 --> 00:00:44,500
Engine now the docs is a bit outdated on
20
00:00:46,200 --> 00:00:47,200
this page however uh this page whatever
21
00:00:50,399 --> 00:00:51,399
is there is uh insufficient in my
22
00:00:53,640 --> 00:00:54,640
opinion I have been working on Unreal
23
00:00:56,399 --> 00:00:57,399
Engine for almost 7 years now and I feel
24
00:00:59,280 --> 00:01:00,280
this system isn't going to be handling
25
00:01:02,160 --> 00:01:03,160
anything
26
00:01:03,300 --> 00:01:04,300
so
27
00:01:04,920 --> 00:01:05,920
8 gigs of RAM isn't enough and for the
28
00:01:08,760 --> 00:01:09,760
video card I would recommend at least
29
00:01:11,460 --> 00:01:12,460
going for something like a 1650 or an
30
00:01:15,900 --> 00:01:16,900
RTX 3050 if you were to ask me I have
31
00:01:18,840 --> 00:01:19,840
worked in unreal for about four to five
32
00:01:21,540 --> 00:01:22,540
years with a 1050 TI that totally works
33
00:01:24,960 --> 00:01:25,960
however your experience isn't going to
34
00:01:27,420 --> 00:01:28,420
be that great and you will have to turn
35
00:01:30,119 --> 00:01:31,119
down all the settings as well
36
00:01:32,460 --> 00:01:33,460
and for the CPU a ryzen 5 or an Intel i7
37
00:01:36,720 --> 00:01:37,720
would do six cores or higher uh
38
00:01:40,200 --> 00:01:41,200
preferably eight or even 12 cores would
39
00:01:42,600 --> 00:01:43,600
be better but make sure if you do get
40
00:01:45,360 --> 00:01:46,360
more number of cores you scale up the
41
00:01:47,520 --> 00:01:48,520
other components as well there are a
42
00:01:50,100 --> 00:01:51,100
couple of things for example in Visual
43
00:01:52,619 --> 00:01:53,619
Studio
44
00:01:53,640 --> 00:01:54,640
uh when you compile a program
45
00:01:56,939 --> 00:01:57,939
you will actually need more RAM as
46
00:02:00,540 --> 00:02:01,540
you scale up the number of cores on your
47
00:02:02,700 --> 00:02:03,700
CPU so that's one thing to note
48
00:02:05,520 --> 00:02:06,520
and if you scroll it down you would see
49
00:02:08,099 --> 00:02:09,099
this list over here although the system
50
00:02:10,679 --> 00:02:11,679
is highly Overkill and the GPU is
51
00:02:12,840 --> 00:02:13,840
outdated of course one noteworthy thing
52
00:02:15,360 --> 00:02:16,360
is a solid state drive which I highly
53
00:02:18,060 --> 00:02:19,060
recommend
54
00:02:19,440 --> 00:02:20,440
do not use a hard drive for your active
55
00:02:22,560 --> 00:02:23,560
projects the experience isn't going to
56
00:02:25,200 --> 00:02:26,200
be that great so with that all being
57
00:02:27,480 --> 00:02:28,480
said let's actually start by talking
58
00:02:30,599 --> 00:02:31,599
about the installation process
59
00:02:33,950 --> 00:02:34,950
[Music]
60
00:02:37,940 --> 00:02:38,940
now there are two ways in which you can
61
00:02:40,200 --> 00:02:41,200
get hands on Unreal Engine one is
62
00:02:42,840 --> 00:02:43,840
through the epic games launcher so just
63
00:02:44,940 --> 00:02:45,940
search epic games launcher download the
64
00:02:46,920 --> 00:02:47,920
launcher and once you actually log in
65
00:02:49,379 --> 00:02:50,379
and do the regular sign up stuff you can
66
00:02:51,840 --> 00:02:52,840
go ahead and click on Unreal Engine
67
00:02:54,420 --> 00:02:55,420
and head into library and you should be
68
00:02:56,819 --> 00:02:57,819
able to add an engine version now as of
69
00:02:59,400 --> 00:03:00,400
this date the the latest table build is
70
00:03:02,060 --> 00:03:03,060
5.0.3 however 5.1 is in preview and we
71
00:03:06,300 --> 00:03:07,300
we shall hopefully upgrade to that it
72
00:03:08,400 --> 00:03:09,400
has quite a few exciting features which
73
00:03:10,860 --> 00:03:11,860
I would love to show
74
00:03:12,379 --> 00:03:13,379
and the other way is to download the
75
00:03:16,200 --> 00:03:17,200
source code now you could use git or
76
00:03:18,180 --> 00:03:19,180
something and copy the link and clone it
77
00:03:21,959 --> 00:03:22,959
like that or you could just download the
78
00:03:24,000 --> 00:03:25,000
zip file from here and then there are a
79
00:03:27,239 --> 00:03:28,239
bunch of steps to actually install it uh
80
00:03:30,120 --> 00:03:31,120
we'll be going through this later in the
81
00:03:32,220 --> 00:03:33,220
course and also for more advanced users
82
00:03:36,420 --> 00:03:37,420
those of you who will be working with
83
00:03:38,099 --> 00:03:39,099
dedicated servers might need the source
84
00:03:40,860 --> 00:03:41,860
build as well now if you guys don't have
85
00:03:43,080 --> 00:03:44,080
access to this repository you just have
86
00:03:45,000 --> 00:03:46,000
to request the permission this is a
87
00:03:47,819 --> 00:03:48,819
private repository by default and it's
88
00:03:50,459 --> 00:03:51,459
pretty easy to get it
89
00:03:52,260 --> 00:03:53,260
and once you do get access to it you
90
00:03:54,599 --> 00:03:55,599
will be able to view this page there are
91
00:03:57,180 --> 00:03:58,180
quite a few tutorials on YouTube on how
92
00:03:59,519 --> 00:04:00,519
to do that so you guys could check any
93
00:04:01,620 --> 00:04:02,620
one of those out
94
00:04:03,599 --> 00:04:04,599
once you install the unreal editor
95
00:04:06,360 --> 00:04:07,360
through the epic games launcher uh
96
00:04:09,060 --> 00:04:10,060
you'll also need a code editor in order
97
00:04:11,220 --> 00:04:12,220
to work with the c plus files so
98
00:04:14,360 --> 00:04:15,360
generally you use visual studio for it
99
00:04:18,000 --> 00:04:19,000
now the documentation goes pretty well
100
00:04:20,220 --> 00:04:21,220
on what components you need and stuff
101
00:04:22,079 --> 00:04:23,079
and if you do need any additional
102
00:04:24,240 --> 00:04:25,240
components the installer is going to
103
00:04:27,180 --> 00:04:28,180
prompt you and it's pretty
104
00:04:29,340 --> 00:04:30,340
straightforward to be honest
105
00:04:31,440 --> 00:04:32,440
now you don't require vs 2019 you could
106
00:04:34,560 --> 00:04:35,560
use 2022 there is absolutely no issues
107
00:04:37,800 --> 00:04:38,800
uh I'll be showing you guys how to set
108
00:04:40,080 --> 00:04:41,080
the default code Editor to be vs2022 as
109
00:04:43,620 --> 00:04:44,620
well a bit later
110
00:04:45,000 --> 00:04:46,000
so that's about it for the code editor I
111
00:04:47,880 --> 00:04:48,880
guess now we can go ahead and create a
112
00:04:49,860 --> 00:04:50,860
project and let's create a game
113
00:04:53,880 --> 00:04:54,880
so I'm in the epic games launcher right
114
00:04:56,220 --> 00:04:57,220
now and before we actually launch the
115
00:04:59,100 --> 00:05:00,100
engine I just wanted to talk about the
116
00:05:00,960 --> 00:05:01,960
installation options
117
00:05:02,820 --> 00:05:03,820
try your best even though it looks large
118
00:05:05,759 --> 00:05:06,759
to have debugging symbols those are
119
00:05:08,639 --> 00:05:09,639
going to help us out later
120
00:05:12,300 --> 00:05:13,300
[Music]
121
00:05:16,500 --> 00:05:17,500
now you can go ahead and click launch
122
00:05:19,080 --> 00:05:20,080
once the loading is done you should be
123
00:05:21,180 --> 00:05:22,180
inside the unreal project browser where
124
00:05:23,340 --> 00:05:24,340
you can create your projects now yours
125
00:05:26,520 --> 00:05:27,520
might look a bit different I haven't
126
00:05:28,080 --> 00:05:29,080
selected templates so I don't see first
127
00:05:30,539 --> 00:05:31,539
person third person and all that however
128
00:05:32,880 --> 00:05:33,880
Our intention here is to learn so we
129
00:05:35,100 --> 00:05:36,100
aren't really going to use those
130
00:05:36,419 --> 00:05:37,419
templates we might look into them a bit
131
00:05:38,880 --> 00:05:39,880
later on but for now we'll be starting
132
00:05:41,039 --> 00:05:42,039
with a blank project and a couple of
133
00:05:43,740 --> 00:05:44,740
noteworthy things
134
00:05:45,120 --> 00:05:46,120
two things actually the first thing is
135
00:05:48,000 --> 00:05:49,000
the project location I always suggest
136
00:05:50,699 --> 00:05:51,699
having an unreal projects folder in your
137
00:05:54,180 --> 00:05:55,180
solid state drive and maybe move them to
138
00:05:57,419 --> 00:05:58,419
a secondary drive if you're not working
139
00:05:59,280 --> 00:06:00,280
on them
140
00:06:00,300 --> 00:06:01,300
now for the project defaults everything
141
00:06:02,880 --> 00:06:03,880
is fine except blueprint and C plus plus
142
00:06:06,979 --> 00:06:07,979
basically every C plus plus project will
143
00:06:10,680 --> 00:06:11,680
have blueprint and everything else that
144
00:06:13,259 --> 00:06:14,259
you will need to work with the editor
145
00:06:15,300 --> 00:06:16,300
however when you select a blueprint
146
00:06:17,580 --> 00:06:18,580
project there is one additional step if
147
00:06:19,860 --> 00:06:20,860
you want to start working with C plus
148
00:06:21,419 --> 00:06:22,419
plus as well please note that blueprint
149
00:06:24,240 --> 00:06:25,240
and C plus plus work complementary with
150
00:06:26,639 --> 00:06:27,639
each other and every project in my
151
00:06:29,039 --> 00:06:30,039
opinion should use a combination of the
152
00:06:30,900 --> 00:06:31,900
two and shouldn't be purely C plus plus
153
00:06:33,479 --> 00:06:34,479
nor should be purely blueprint so let's
154
00:06:36,840 --> 00:06:37,840
create a c plus project and let's leave
155
00:06:39,479 --> 00:06:40,479
it at desktop maximum and we didn't
156
00:06:43,560 --> 00:06:44,560
download the starter content so we don't
157
00:06:45,660 --> 00:06:46,660
have it but that's totally fine we can
158
00:06:48,000 --> 00:06:49,000
add it later on now
159
00:06:50,819 --> 00:06:51,819
for the project name we can go ahead and
160
00:06:54,180 --> 00:06:55,180
name it let's call it beginner to
161
00:06:57,660 --> 00:06:58,660
Advanced course
162
00:06:59,880 --> 00:07:00,880
or I'll just call it beginner course
163
00:07:04,440 --> 00:07:05,440
so let's create that
164
00:07:08,039 --> 00:07:09,039
once you open your project a visual
165
00:07:10,560 --> 00:07:11,560
studio window like this with your
166
00:07:12,479 --> 00:07:13,479
project solution open should be open by
167
00:07:15,720 --> 00:07:16,720
default if not head into the editor go
168
00:07:18,900 --> 00:07:19,900
to tools and click on open Visual Studio
169
00:07:21,380 --> 00:07:22,380
2022 and here's where I'll just show you
170
00:07:24,479 --> 00:07:25,479
guys how to change the default code
171
00:07:26,340 --> 00:07:27,340
editor let's say you have a slower
172
00:07:28,020 --> 00:07:29,020
computer head into editor preferences
173
00:07:30,979 --> 00:07:31,979
and over here type in code editor
174
00:07:35,099 --> 00:07:36,099
and you should be able to change it to
175
00:07:37,500 --> 00:07:38,500
visual studio code or whatever let's say
176
00:07:39,900 --> 00:07:40,900
you do change it to vs code
177
00:07:42,780 --> 00:07:43,780
over here under Tools again you should
178
00:07:45,660 --> 00:07:46,660
be able to find refresh Visual Studio
179
00:07:48,000 --> 00:07:49,000
code project
180
00:07:49,500 --> 00:07:50,500
once you do that you should be good to
181
00:07:52,259 --> 00:07:53,259
go
182
00:07:53,880 --> 00:07:54,880
one thing that you will immediately
183
00:07:55,740 --> 00:07:56,740
notice is my editor layout does not look
184
00:07:58,860 --> 00:07:59,860
exactly like yours the reason is I have
185
00:08:01,680 --> 00:08:02,680
set mine to the Unreal Engine 4 layout
186
00:08:04,500 --> 00:08:05,500
so the way you do that is by heading
187
00:08:07,080 --> 00:08:08,080
into Windows load layout and this is the
188
00:08:10,080 --> 00:08:11,080
one you will probably have
189
00:08:11,699 --> 00:08:12,699
and you can hit
190
00:08:14,039 --> 00:08:15,039
control space in order to get your
191
00:08:16,680 --> 00:08:17,680
content drawer but I feel like it just
192
00:08:19,919 --> 00:08:20,919
adds an additional step in viewing your
193
00:08:22,080 --> 00:08:23,080
content and
194
00:08:24,120 --> 00:08:25,120
I honestly prefer the Unreal Engine 4
195
00:08:26,759 --> 00:08:27,759
layout but it's completely up to you
196
00:08:28,620 --> 00:08:29,620
everything else should be in the same
197
00:08:31,020 --> 00:08:32,020
place so I'm going to be using the ue4
198
00:08:33,479 --> 00:08:34,479
layout you can choose to use the default
199
00:08:35,459 --> 00:08:36,459
one if you wish
200
00:08:36,899 --> 00:08:37,899
and in case you want to go full screen
201
00:08:38,820 --> 00:08:39,820
here in the ue4 layout just get your
202
00:08:42,060 --> 00:08:43,060
viewport into Focus just in case you're
203
00:08:44,279 --> 00:08:45,279
wondering the middle large portion of
204
00:08:47,040 --> 00:08:48,040
the screen is called the viewport once
205
00:08:49,200 --> 00:08:50,200
you get it into Focus hit f11 on your
206
00:08:51,600 --> 00:08:52,600
keyboard to go full screen
207
00:08:54,670 --> 00:08:55,670
[Music]
208
00:08:58,399 --> 00:08:59,399
let's start talking about the actual GUI
209
00:09:03,000 --> 00:09:04,000
of the unreal editor so the first thing
210
00:09:06,000 --> 00:09:07,000
is your menu bar which contains file
211
00:09:08,300 --> 00:09:09,300
edit window tools build select and so on
212
00:09:12,000 --> 00:09:13,000
these are just the normal options that
213
00:09:14,339 --> 00:09:15,339
you would see on in any other computer
214
00:09:16,019 --> 00:09:17,019
software so let's say you wanted to save
215
00:09:18,540 --> 00:09:19,540
everything you would go go ahead and
216
00:09:20,580 --> 00:09:21,580
click save all however there's a key
217
00:09:22,560 --> 00:09:23,560
over here as well on the content browser
218
00:09:24,779 --> 00:09:25,779
which you will be using more often in
219
00:09:26,640 --> 00:09:27,640
this editor and under edit you also have
220
00:09:30,240 --> 00:09:31,240
a couple of important things
221
00:09:32,459 --> 00:09:33,459
obviously for undo redo and
222
00:09:35,040 --> 00:09:36,040
functionality like that you'd prefer the
223
00:09:37,200 --> 00:09:38,200
shortcut keys so for example let's say I
224
00:09:40,500 --> 00:09:41,500
add in a light over here
225
00:09:42,300 --> 00:09:43,300
and I go to edit you could undo that but
226
00:09:46,260 --> 00:09:47,260
I just prefer using Ctrl Z and Ctrl y
227
00:09:49,620 --> 00:09:50,620
and editor preferences project settings
228
00:09:52,920 --> 00:09:53,920
and plugins are a couple of options
229
00:09:55,980 --> 00:09:56,980
which you will use quite a bit we will
230
00:09:58,620 --> 00:09:59,620
be getting into all of those in detail
231
00:10:00,480 --> 00:10:01,480
later on
232
00:10:01,500 --> 00:10:02,500
now window as the name suggests has to
233
00:10:04,560 --> 00:10:05,560
do with uh your actual GUI so here for
234
00:10:10,019 --> 00:10:11,019
example if I wanted to know what game
235
00:10:11,880 --> 00:10:12,880
mode I have and again we will be getting
236
00:10:14,220 --> 00:10:15,220
into all of that so I can just go to
237
00:10:16,740 --> 00:10:17,740
world settings which contains the game
238
00:10:19,019 --> 00:10:20,019
mode info so it says game mode override
239
00:10:21,480 --> 00:10:22,480
none we can set that to be game mode for
240
00:10:24,060 --> 00:10:25,060
example and stuff like that
241
00:10:26,880 --> 00:10:27,880
it all depends on what you exactly need
242
00:10:28,980 --> 00:10:29,980
you could grab in a second viewport as
243
00:10:31,380 --> 00:10:32,380
well in case you needed it
244
00:10:33,839 --> 00:10:34,839
stuff like that and under Tools the only
245
00:10:37,380 --> 00:10:38,380
thing which we'll probably use here is
246
00:10:39,899 --> 00:10:40,899
going to be creating a new C plus plus
247
00:10:41,880 --> 00:10:42,880
class and occasionally we might need to
248
00:10:44,339 --> 00:10:45,339
refresh our project file
249
00:10:46,320 --> 00:10:47,320
and nothing else actually find in
250
00:10:48,480 --> 00:10:49,480
blueprints is something handy so in case
251
00:10:51,420 --> 00:10:52,420
you have written some blueprint code and
252
00:10:53,760 --> 00:10:54,760
you want to find it
253
00:10:55,320 --> 00:10:56,320
like in your entire project then it's a
254
00:10:59,040 --> 00:11:00,040
useful thing
255
00:11:00,600 --> 00:11:01,600
and build is for building your lighting
256
00:11:03,899 --> 00:11:04,899
and stuff basically uh baking your
257
00:11:06,360 --> 00:11:07,360
lighting
258
00:11:07,579 --> 00:11:08,579
select not really sure who would use
259
00:11:11,279 --> 00:11:12,279
that because most of the operations are
260
00:11:13,920 --> 00:11:14,920
there can be done by shortcut keys
261
00:11:16,860 --> 00:11:17,860
so that's your menu bar
262
00:11:19,019 --> 00:11:20,019
and under this there's another panel
263
00:11:21,600 --> 00:11:22,600
over here
264
00:11:22,680 --> 00:11:23,680
where you have another save button
265
00:11:25,440 --> 00:11:26,440
and under this select mode option
266
00:11:28,800 --> 00:11:29,800
over here you have quite a few options
267
00:11:31,880 --> 00:11:32,880
landscape is something which you will
268
00:11:34,740 --> 00:11:35,740
use when you're working with you know
269
00:11:37,320 --> 00:11:38,320
larger Maps so you can go ahead and
270
00:11:39,060 --> 00:11:40,060
create landscapes
271
00:11:40,620 --> 00:11:41,620
so what I'll do is I'll create a brand
272
00:11:42,779 --> 00:11:43,779
new level to Showcase those things and
273
00:11:45,600 --> 00:11:46,600
over here in blueprints this is where
274
00:11:47,640 --> 00:11:48,640
you'd access your level blueprint and I
275
00:11:50,339 --> 00:11:51,339
will get to what is that a bit later
276
00:11:52,399 --> 00:11:53,399
this option right here is mostly for
277
00:11:55,079 --> 00:11:56,079
cinematics so let's say I'm making a
278
00:11:57,360 --> 00:11:58,360
trailer for your game or something these
279
00:11:59,940 --> 00:12:00,940
are the things which you would use
280
00:12:01,620 --> 00:12:02,620
and this is just to play your game so if
281
00:12:03,899 --> 00:12:04,899
I hit play I can see what the game looks
282
00:12:06,959 --> 00:12:07,959
like while you're playing it
283
00:12:09,120 --> 00:12:10,120
one more thing let's say you wanted to
284
00:12:11,760 --> 00:12:12,760
look at how your game looked while
285
00:12:13,500 --> 00:12:14,500
you're playing without actually playing
286
00:12:15,180 --> 00:12:16,180
it you can press G on your keyboard and
287
00:12:18,300 --> 00:12:19,300
it it's going to go into game mode which
288
00:12:20,880 --> 00:12:21,880
will show you exactly how your game will
289
00:12:22,740 --> 00:12:23,740
look when it is being played
290
00:12:25,560 --> 00:12:26,560
and next up you have this button right
291
00:12:29,940 --> 00:12:30,940
here where it allows you to launch the
292
00:12:32,339 --> 00:12:33,339
game and stuff will be going into this a
293
00:12:35,100 --> 00:12:36,100
bit in detail later on
294
00:12:37,200 --> 00:12:38,200
now for those of you guys who have
295
00:12:39,660 --> 00:12:40,660
slower computers you can head into
296
00:12:42,180 --> 00:12:43,180
settings over here engine scalability
297
00:12:44,820 --> 00:12:45,820
settings and you can set Yours to low
298
00:12:48,300 --> 00:12:49,300
now how do you check your frame rate you
299
00:12:51,300 --> 00:12:52,300
may ask because that's a major concern I
300
00:12:54,120 --> 00:12:55,120
feel like you do require about 50 to 60
301
00:12:57,600 --> 00:12:58,600
FPS in order to have a smooth editor
302
00:13:01,079 --> 00:13:02,079
experience so the way you check that is
303
00:13:03,959 --> 00:13:04,959
by hitting your tailed key under your
304
00:13:06,360 --> 00:13:07,360
Escape key that is if you guys aren't
305
00:13:07,980 --> 00:13:08,980
familiar
306
00:13:09,300 --> 00:13:10,300
once you do that your focus should be in
307
00:13:12,420 --> 00:13:13,420
this enter console command window at the
308
00:13:14,700 --> 00:13:15,700
bottom of your screen type in stat FPS
309
00:13:19,860 --> 00:13:20,860
and you might see that it's locked at
310
00:13:23,040 --> 00:13:24,040
120 if you have a fast computer so what
311
00:13:25,860 --> 00:13:26,860
I'll do is I'll type in t dot Max FPS
312
00:13:29,279 --> 00:13:30,279
and you can just type in a crazy value
313
00:13:31,620 --> 00:13:32,620
like 999. so this is my actual uncapped
314
00:13:35,880 --> 00:13:36,880
frame rate
315
00:13:36,899 --> 00:13:37,899
now this introduces us to another window
316
00:13:41,399 --> 00:13:42,399
this is known as the console now the
317
00:13:44,820 --> 00:13:45,820
console is really useful
318
00:13:47,160 --> 00:13:48,160
basically almost every setting you see
319
00:13:50,279 --> 00:13:51,279
over here and quite a few other settings
320
00:13:52,860 --> 00:13:53,860
which we will talk about later can be
321
00:13:55,200 --> 00:13:56,200
set using the console
322
00:13:57,360 --> 00:13:58,360
it's quite handy let's say you're
323
00:13:59,459 --> 00:14:00,459
debugging your game and you don't have
324
00:14:02,880 --> 00:14:03,880
an actual button to change your graphic
325
00:14:04,740 --> 00:14:05,740
settings you could use the console and
326
00:14:06,959 --> 00:14:07,959
change it as well there are many other
327
00:14:08,940 --> 00:14:09,940
uses for it for example in multiplayer
328
00:14:11,399 --> 00:14:12,399
you can simulate lag and stuff like that
329
00:14:14,579 --> 00:14:15,579
in order to represent an actual
330
00:14:16,800 --> 00:14:17,800
multiplayer game
331
00:14:18,060 --> 00:14:19,060
so that's the console and your output
332
00:14:21,120 --> 00:14:22,120
log is your output log so let's say I've
333
00:14:23,519 --> 00:14:24,519
printed something
334
00:14:25,019 --> 00:14:26,019
it's going to stay on your screen for
335
00:14:27,240 --> 00:14:28,240
about two seconds or how much ever you
336
00:14:29,700 --> 00:14:30,700
set the duration
337
00:14:31,019 --> 00:14:32,019
but the output log is always going to
338
00:14:33,959 --> 00:14:34,959
have
339
00:14:35,040 --> 00:14:36,040
the print so for example
340
00:14:38,100 --> 00:14:39,100
now we haven't gone into blueprints but
341
00:14:40,079 --> 00:14:41,079
I'll just print something and show you
342
00:14:41,579 --> 00:14:42,579
guys
343
00:14:43,079 --> 00:14:44,079
if I just type in print string hello
344
00:14:46,920 --> 00:14:47,920
you see you get hello over here but it's
345
00:14:50,940 --> 00:14:51,940
gone after two seconds
346
00:14:52,980 --> 00:14:53,980
however in the output log you should be
347
00:14:56,160 --> 00:14:57,160
able to still see Hello it should be all
348
00:14:58,620 --> 00:14:59,620
the way down
349
00:15:00,420 --> 00:15:01,420
as you see
350
00:15:03,060 --> 00:15:04,060
you get hello
351
00:15:04,860 --> 00:15:05,860
now don't worry about all these errors
352
00:15:07,800 --> 00:15:08,800
it's really nothing to worry about
353
00:15:10,920 --> 00:15:11,920
so that's about it and on the left hand
354
00:15:13,980 --> 00:15:14,980
side you have the place actors panel
355
00:15:17,060 --> 00:15:18,060
where you know you have various options
356
00:15:20,160 --> 00:15:21,160
you'll really not be using this you will
357
00:15:22,740 --> 00:15:23,740
generally just drag those from the
358
00:15:25,199 --> 00:15:26,199
content browser
359
00:15:26,519 --> 00:15:27,519
it just contains the same old things and
360
00:15:29,699 --> 00:15:30,699
the recent step may be helpful if you're
361
00:15:31,980 --> 00:15:32,980
placing the same object over and over
362
00:15:34,139 --> 00:15:35,139
again
363
00:15:35,579 --> 00:15:36,579
one thing that you might use this for is
364
00:15:37,620 --> 00:15:38,620
for a player start player start is
365
00:15:40,079 --> 00:15:41,079
basically where your player is going to
366
00:15:41,760 --> 00:15:42,760
spawn
367
00:15:43,500 --> 00:15:44,500
just press G on your keyboard if it ever
368
00:15:45,660 --> 00:15:46,660
disappears you're probably in game mode
369
00:15:47,459 --> 00:15:48,459
if you don't see it
370
00:15:49,199 --> 00:15:50,199
and if you want to get close to it like
371
00:15:51,779 --> 00:15:52,779
how I did
372
00:15:52,920 --> 00:15:53,920
uh make sure that is selected and press
373
00:15:55,620 --> 00:15:56,620
F on your keyboard
374
00:15:57,420 --> 00:15:58,420
F stands for focus and it's going to go
375
00:16:00,540 --> 00:16:01,540
near it the camera is going to go near
376
00:16:02,820 --> 00:16:03,820
that
377
00:16:03,779 --> 00:16:04,779
now once that's done let's talk about
378
00:16:07,139 --> 00:16:08,139
this massive chunk of the screen
379
00:16:10,139 --> 00:16:11,139
this is known as the viewport this is
380
00:16:13,260 --> 00:16:14,260
where you will actually arrange your
381
00:16:15,300 --> 00:16:16,300
level and do stuff
382
00:16:17,519 --> 00:16:18,519
so for example if you want to place
383
00:16:19,260 --> 00:16:20,260
something you drag that in the viewport
384
00:16:21,240 --> 00:16:22,240
and that's going to be added into your
385
00:16:23,279 --> 00:16:24,279
level
386
00:16:25,500 --> 00:16:26,500
now in order to navigate your viewport
387
00:16:27,779 --> 00:16:28,779
there are quite a few methods which you
388
00:16:29,880 --> 00:16:30,880
can use one is known as the Maya style
389
00:16:31,560 --> 00:16:32,560
navigation where you use alt and your
390
00:16:33,899 --> 00:16:34,899
mouse buttons and there are many other
391
00:16:36,899 --> 00:16:37,899
styles which I won't get into it's kind
392
00:16:39,240 --> 00:16:40,240
of pointless but there is one style
393
00:16:41,820 --> 00:16:42,820
which I personally prefer and I feel
394
00:16:44,100 --> 00:16:45,100
almost everyone is going to prefer that
395
00:16:46,320 --> 00:16:47,320
that is by using your right Mouse button
396
00:16:49,079 --> 00:16:50,079
and your wasd this is similar to how you
397
00:16:51,899 --> 00:16:52,899
move in video games except you're
398
00:16:53,759 --> 00:16:54,759
holding the right Mouse button here so
399
00:16:56,040 --> 00:16:57,040
hold down your right Mouse button and
400
00:16:58,740 --> 00:16:59,740
you can use your w a s and D keys and
401
00:17:01,980 --> 00:17:02,980
move your mouse so this gives you all
402
00:17:04,559 --> 00:17:05,559
degrees of freedom so you can rotate you
403
00:17:06,959 --> 00:17:07,959
can pan around you can do everything
404
00:17:09,839 --> 00:17:10,839
so this is my favorite way of navigating
405
00:17:12,660 --> 00:17:13,660
just try it a couple of times it's just
406
00:17:15,900 --> 00:17:16,900
a matter of getting the feel of it and
407
00:17:18,480 --> 00:17:19,480
if I want to speed up the camera which I
408
00:17:20,220 --> 00:17:21,220
will get into later you can use your
409
00:17:22,020 --> 00:17:23,020
scroll wheel along with this and your
410
00:17:23,880 --> 00:17:24,880
camera speed is going to change
411
00:17:27,419 --> 00:17:28,419
there are a couple of options again here
412
00:17:29,940 --> 00:17:30,940
now here uh instead of the console
413
00:17:32,460 --> 00:17:33,460
command you could use this as well to
414
00:17:34,500 --> 00:17:35,500
show your FPS
415
00:17:36,179 --> 00:17:37,179
and there are quite a few other options
416
00:17:38,100 --> 00:17:39,100
which you would generally not use screen
417
00:17:40,200 --> 00:17:41,200
percentage is basically a resolution
418
00:17:41,940 --> 00:17:42,940
scale you could set that all the way up
419
00:17:44,700 --> 00:17:45,700
there
420
00:17:45,660 --> 00:17:46,660
I'd leave mine at 100.
421
00:17:48,240 --> 00:17:49,240
and this is to change between
422
00:17:50,580 --> 00:17:51,580
perspective and orthographic views let's
423
00:17:53,400 --> 00:17:54,400
say you're aligning something from the
424
00:17:55,320 --> 00:17:56,320
top you would go to your top
425
00:17:57,000 --> 00:17:58,000
orthographic View
426
00:17:59,640 --> 00:18:00,640
now you might see everything is
427
00:18:02,840 --> 00:18:03,840
wireframe so you can change that here as
428
00:18:05,580 --> 00:18:06,580
well go to lit let's say there are
429
00:18:07,919 --> 00:18:08,919
shadows interrupting your work you could
430
00:18:10,020 --> 00:18:11,020
head into unlit there are many other
431
00:18:12,360 --> 00:18:13,360
view modes which you generally use for
432
00:18:14,220 --> 00:18:15,220
optimization and things like that
433
00:18:17,700 --> 00:18:18,700
but generally you'd stay in lit unlit or
434
00:18:21,059 --> 00:18:22,059
wireframe itself
435
00:18:22,980 --> 00:18:23,980
maybe a couple of times you might use
436
00:18:25,260 --> 00:18:26,260
one of these uh other settings but I've
437
00:18:30,360 --> 00:18:31,360
never found myself needing those
438
00:18:32,580 --> 00:18:33,580
so that's there
439
00:18:34,620 --> 00:18:35,620
and scalability is basically the same
440
00:18:36,960 --> 00:18:37,960
thing which we saw over here
441
00:18:39,600 --> 00:18:40,600
I can set that to cinematic for example
442
00:18:42,360 --> 00:18:43,360
in my case it shouldn't really matter
443
00:18:45,900 --> 00:18:46,900
that's about it and in these options on
444
00:18:50,340 --> 00:18:51,340
the right hand side
445
00:18:52,140 --> 00:18:53,140
this one basically allows you to select
446
00:18:55,380 --> 00:18:56,380
objects so let's say I click on this I
447
00:18:58,679 --> 00:18:59,679
select this now let me get closer a bit
448
00:19:02,580 --> 00:19:03,580
set into perspective
449
00:19:04,500 --> 00:19:05,500
so if I click on this I can select it
450
00:19:08,400 --> 00:19:09,400
now when I click on something now I'll
451
00:19:12,900 --> 00:19:13,900
create another Point light when I click
452
00:19:15,000 --> 00:19:16,000
on something and I have it selected
453
00:19:17,760 --> 00:19:18,760
if I want to move it I can press W on
454
00:19:20,220 --> 00:19:21,220
the keyboard
455
00:19:21,660 --> 00:19:22,660
or if I want to rotate it I can press e
456
00:19:24,179 --> 00:19:25,179
on the keyboard
457
00:19:25,679 --> 00:19:26,679
and if I want to scale it for a light
458
00:19:28,500 --> 00:19:29,500
it's kind of useless but it is going to
459
00:19:30,419 --> 00:19:31,419
scale the radius I believe
460
00:19:32,700 --> 00:19:33,700
so for that I can hit r on my keyboard
461
00:19:36,000 --> 00:19:37,000
in order to scale things or you could
462
00:19:38,640 --> 00:19:39,640
use these buttons over here
463
00:19:41,760 --> 00:19:42,760
so this is for move
464
00:19:43,740 --> 00:19:44,740
this is for rotate
465
00:19:45,900 --> 00:19:46,900
and this is for scale
466
00:19:48,720 --> 00:19:49,720
all right so once that said
467
00:19:51,200 --> 00:19:52,200
this button right here changes between
468
00:19:54,679 --> 00:19:55,679
uh local and World space
469
00:19:57,900 --> 00:19:58,900
now over here if I just drag in a cube
470
00:20:00,780 --> 00:20:01,780
for example under shapes you should find
471
00:20:02,880 --> 00:20:03,880
Cube
472
00:20:04,200 --> 00:20:05,200
and if I change this
473
00:20:07,740 --> 00:20:08,740
to local space
474
00:20:11,039 --> 00:20:12,039
now when I rotate this Cube you see the
475
00:20:14,400 --> 00:20:15,400
Gizmo rotates along with it and now I
476
00:20:16,500 --> 00:20:17,500
can move it along its rotation
477
00:20:18,840 --> 00:20:19,840
but let's say I wanted to rotate it
478
00:20:20,880 --> 00:20:21,880
along with the world's XYZ the way I do
479
00:20:24,000 --> 00:20:25,000
that is by heading into World space
480
00:20:26,280 --> 00:20:27,280
so now you see it's aligned to the
481
00:20:28,740 --> 00:20:29,740
world's XYZ that is your actual
482
00:20:31,620 --> 00:20:32,620
coordinate axis
483
00:20:33,480 --> 00:20:34,480
but this cube is rotated as you can see
484
00:20:35,820 --> 00:20:36,820
so if I want to move it along that
485
00:20:38,640 --> 00:20:39,640
rotation I can head into local space
486
00:20:42,419 --> 00:20:43,419
again if you are familiar with 3D
487
00:20:44,100 --> 00:20:45,100
modeling software these will sound
488
00:20:46,320 --> 00:20:47,320
pretty familiar to you
489
00:20:48,000 --> 00:20:49,000
the next thing is grid snapping
490
00:20:51,000 --> 00:20:52,000
now if I were to come close enough you
491
00:20:53,820 --> 00:20:54,820
would see that it's moving in increments
492
00:20:55,860 --> 00:20:56,860
it's not moving smoothly that's because
493
00:20:58,200 --> 00:20:59,200
grid snapping is enabled and snapping
494
00:21:00,600 --> 00:21:01,600
distance is set to 10. so I can just
495
00:21:03,120 --> 00:21:04,120
click on this button and disable grid
496
00:21:05,160 --> 00:21:06,160
snapping and now you see the object
497
00:21:07,440 --> 00:21:08,440
moves smoothly same goes with rotation
498
00:21:09,720 --> 00:21:10,720
if I disable that I can smoothly rotate
499
00:21:12,480 --> 00:21:13,480
the object
500
00:21:13,740 --> 00:21:14,740
if I enable that it's going to rotate in
501
00:21:15,960 --> 00:21:16,960
increments of 10
502
00:21:17,640 --> 00:21:18,640
same with the scale as well
503
00:21:20,400 --> 00:21:21,400
now this map is pretty huge and it's
504
00:21:24,000 --> 00:21:25,000
taking quite a while for me to actually
505
00:21:27,080 --> 00:21:28,080
go this far
506
00:21:29,700 --> 00:21:30,700
so the way I can actually
507
00:21:32,460 --> 00:21:33,460
move faster is by using this camera
508
00:21:35,760 --> 00:21:36,760
speed button so if I head into 8
509
00:21:39,600 --> 00:21:40,600
as you see we are moving very fast one
510
00:21:42,780 --> 00:21:43,780
more thing
511
00:21:43,919 --> 00:21:44,919
is if you scroll while using your right
512
00:21:48,240 --> 00:21:49,240
click and wasd basically I'm using that
513
00:21:51,840 --> 00:21:52,840
to move
514
00:21:52,799 --> 00:21:53,799
if you use right click and wasd and you
515
00:21:56,460 --> 00:21:57,460
scroll at the same time you can actually
516
00:21:58,140 --> 00:21:59,140
adjust your camera speed so I have my
517
00:22:00,780 --> 00:22:01,780
right Mouse button held I have wasd to
518
00:22:03,659 --> 00:22:04,659
move and if I scroll forward I'm going
519
00:22:06,240 --> 00:22:07,240
to move real fast
520
00:22:07,860 --> 00:22:08,860
now let's say scroll backwards I'm going
521
00:22:10,140 --> 00:22:11,140
to go slower
522
00:22:12,120 --> 00:22:13,120
so you can adjust your camera speed with
523
00:22:14,460 --> 00:22:15,460
your scroll wheel as well and of course
524
00:22:16,620 --> 00:22:17,620
you can adjust it over here and if you
525
00:22:18,780 --> 00:22:19,780
want the camera to be even faster you
526
00:22:20,760 --> 00:22:21,760
can go ahead and set this multiplier
527
00:22:22,860 --> 00:22:23,860
thing
528
00:22:23,760 --> 00:22:24,760
and that's about it
529
00:22:27,540 --> 00:22:28,540
[Music]
530
00:22:32,039 --> 00:22:33,039
now let's actually start creating
531
00:22:34,200 --> 00:22:35,200
something so the way you would actually
532
00:22:36,960 --> 00:22:37,960
go about doing stuff is creating
533
00:22:38,940 --> 00:22:39,940
something under your content folder now
534
00:22:41,640 --> 00:22:42,640
you might have some things over here if
535
00:22:43,620 --> 00:22:44,620
you have enabled starter content and
536
00:22:45,360 --> 00:22:46,360
stuff but in our case we don't have
537
00:22:47,400 --> 00:22:48,400
anything
538
00:22:48,600 --> 00:22:49,600
so one thing is whenever you create new
539
00:22:52,380 --> 00:22:53,380
levels it's always advisable to have a
540
00:22:55,500 --> 00:22:56,500
Maps folder in your content folder where
541
00:22:58,919 --> 00:22:59,919
you actually put all your Maps
542
00:23:01,260 --> 00:23:02,260
so head into this folder and in order to
543
00:23:04,320 --> 00:23:05,320
actually create a blank level where you
544
00:23:06,539 --> 00:23:07,539
can start making your own right click
545
00:23:10,620 --> 00:23:11,620
click on create basic asset level or you
546
00:23:14,640 --> 00:23:15,640
can head into file new level anyway is
547
00:23:17,520 --> 00:23:18,520
okay
548
00:23:18,679 --> 00:23:19,679
and we can call this one
549
00:23:22,200 --> 00:23:23,200
beginner course level you could call it
550
00:23:25,320 --> 00:23:26,320
anything you want
551
00:23:27,419 --> 00:23:28,419
double click on it to open it up
552
00:23:30,440 --> 00:23:31,440
and I've already saved it
553
00:23:33,780 --> 00:23:34,780
uh it's asking us to save this map
554
00:23:36,240 --> 00:23:37,240
actually so actually don't save this
555
00:23:40,500 --> 00:23:41,500
now head into your project settings
556
00:23:43,260 --> 00:23:44,260
and this is where we start talking about
557
00:23:45,419 --> 00:23:46,419
some of the things which you might need
558
00:23:47,640 --> 00:23:48,640
the first thing is maps and modes
559
00:23:50,640 --> 00:23:51,640
so in order to decide which level is
560
00:23:53,039 --> 00:23:54,039
going to open when you start the editor
561
00:23:54,960 --> 00:23:55,960
this is where you actually set it so
562
00:23:57,360 --> 00:23:58,360
anything associated with your project
563
00:23:59,340 --> 00:24:00,340
will be over here so for example your
564
00:24:02,340 --> 00:24:03,340
input bindings is something which you'll
565
00:24:03,960 --> 00:24:04,960
use a lot so all of those are there in
566
00:24:06,179 --> 00:24:07,179
the project settings so we can change
567
00:24:08,280 --> 00:24:09,280
the editor startup map to be beginner
568
00:24:10,440 --> 00:24:11,440
course level
569
00:24:11,640 --> 00:24:12,640
and we can set this to be beginner
570
00:24:13,679 --> 00:24:14,679
course level as well
571
00:24:15,360 --> 00:24:16,360
close that
572
00:24:16,860 --> 00:24:17,860
and if you were to notice there is
573
00:24:19,080 --> 00:24:20,080
actually a small note here
574
00:24:21,000 --> 00:24:22,000
it says
575
00:24:22,520 --> 00:24:23,520
these settings are saved in default
576
00:24:25,980 --> 00:24:26,980
engine dot ini which is currently
577
00:24:28,860 --> 00:24:29,860
writable what do I mean by that is if I
578
00:24:32,340 --> 00:24:33,340
head into my project directory
579
00:24:35,220 --> 00:24:36,220
and if I head into config there are
580
00:24:38,640 --> 00:24:39,640
actually many config files so for
581
00:24:40,860 --> 00:24:41,860
example if I open up default engine.ini
582
00:24:44,280 --> 00:24:45,280
it says editor startup map equals and it
583
00:24:47,940 --> 00:24:48,940
has the relative path of the map
584
00:24:50,700 --> 00:24:51,700
and you have a bunch of other settings
585
00:24:52,740 --> 00:24:53,740
as you can see these are useful we will
586
00:24:56,460 --> 00:24:57,460
actually talk about console config files
587
00:24:58,740 --> 00:24:59,740
in detail later on
588
00:25:01,860 --> 00:25:02,860
there are other config files as well
589
00:25:04,200 --> 00:25:05,200
most of which you won't use you would
590
00:25:06,419 --> 00:25:07,419
mostly just use default engine.ini
591
00:25:09,840 --> 00:25:10,840
now heading back to our level you see
592
00:25:12,720 --> 00:25:13,720
everything is completely empty
593
00:25:16,020 --> 00:25:17,020
now one of the first things that you
594
00:25:17,940 --> 00:25:18,940
will need is a sky actually so if you
595
00:25:20,880 --> 00:25:21,880
just search in sky
596
00:25:22,559 --> 00:25:23,559
you're going to find a skylight Sky
597
00:25:24,960 --> 00:25:25,960
atmosphere we are just going to be using
598
00:25:27,840 --> 00:25:28,840
a skylight for now
599
00:25:29,940 --> 00:25:30,940
and if you just type in atmosphere you'd
600
00:25:32,640 --> 00:25:33,640
you get the same Sky atmosphere here
601
00:25:35,640 --> 00:25:36,640
so you can go ahead and drag that as
602
00:25:37,679 --> 00:25:38,679
well
603
00:25:39,059 --> 00:25:40,059
and if you type in fog you'll be able to
604
00:25:42,059 --> 00:25:43,059
get exponential height fog
605
00:25:44,580 --> 00:25:45,580
now you will see the effects of it if
606
00:25:47,159 --> 00:25:48,159
you Tinker around with this yourself
607
00:25:50,039 --> 00:25:51,039
basically all of these things just do
608
00:25:52,559 --> 00:25:53,559
what they say so exponential height fog
609
00:25:54,900 --> 00:25:55,900
is going to add fog and if you want to
610
00:25:58,320 --> 00:25:59,320
change the properties of this always
611
00:26:00,779 --> 00:26:01,779
head into your details panel and this is
612
00:26:03,419 --> 00:26:04,419
where you will adjust all the properties
613
00:26:05,279 --> 00:26:06,279
now for something like fog the location
614
00:26:07,380 --> 00:26:08,380
and stuff doesn't matter
615
00:26:09,840 --> 00:26:10,840
so anything you place the location of it
616
00:26:12,659 --> 00:26:13,659
is going to be stored here location
617
00:26:14,220 --> 00:26:15,220
rotation and scale just know that
618
00:26:17,220 --> 00:26:18,220
location rotation and scale combined in
619
00:26:19,679 --> 00:26:20,679
Unreal Engine is known as a transform
620
00:26:22,020 --> 00:26:23,020
we'll be using that a lot
621
00:26:24,779 --> 00:26:25,779
now let's say you had a light which was
622
00:26:27,779 --> 00:26:28,779
fixed and you want the Shadows to just
623
00:26:30,480 --> 00:26:31,480
be baked in and you have nothing to
624
00:26:32,460 --> 00:26:33,460
calculate dynamically you could set your
625
00:26:34,919 --> 00:26:35,919
light to be static or it it goes the
626
00:26:37,799 --> 00:26:38,799
same with any other object if you're not
627
00:26:39,539 --> 00:26:40,539
going to be moving it it's going to be
628
00:26:41,460 --> 00:26:42,460
static
629
00:26:42,720 --> 00:26:43,720
stationary is almost like static but
630
00:26:46,260 --> 00:26:47,260
there are a couple of things which
631
00:26:47,820 --> 00:26:48,820
dynamically changes
632
00:26:49,740 --> 00:26:50,740
it's generally used for your directional
633
00:26:52,559 --> 00:26:53,559
lights which acts as your sun basically
634
00:26:54,779 --> 00:26:55,779
so we can drag that as well so if I type
635
00:26:57,299 --> 00:26:58,299
in directional light
636
00:26:59,340 --> 00:27:00,340
you see we get everything else that we
637
00:27:02,700 --> 00:27:03,700
need
638
00:27:04,080 --> 00:27:05,080
if I remove the fog you'd see that the
639
00:27:07,080 --> 00:27:08,080
fog went
640
00:27:08,460 --> 00:27:09,460
now for example here I have lost my
641
00:27:12,480 --> 00:27:13,480
directional light and
642
00:27:14,460 --> 00:27:15,460
or any other component so in order to
643
00:27:16,799 --> 00:27:17,799
navigate to that you can use this
644
00:27:18,360 --> 00:27:19,360
outliner window which will have a list
645
00:27:20,279 --> 00:27:21,279
of all the objects that are in your
646
00:27:22,140 --> 00:27:23,140
scene you can do quite a few things
647
00:27:24,059 --> 00:27:25,059
actually if you want you could select
648
00:27:26,159 --> 00:27:27,159
these and you could actually put those
649
00:27:28,980 --> 00:27:29,980
in one folder so I can go ahead and
650
00:27:32,340 --> 00:27:33,340
right click create a folder and I can
651
00:27:35,820 --> 00:27:36,820
just drag those inside this folder you
652
00:27:38,640 --> 00:27:39,640
could do that as well in the outliner so
653
00:27:41,460 --> 00:27:42,460
now let's say you lose your directional
654
00:27:43,260 --> 00:27:44,260
light you can head over here and let's
655
00:27:45,659 --> 00:27:46,659
just call this one
656
00:27:47,460 --> 00:27:48,460
sky for example
657
00:27:51,179 --> 00:27:52,179
let's just call it Sky actors I'll tell
658
00:27:54,000 --> 00:27:55,000
you guys why we call them actors a bit
659
00:27:56,460 --> 00:27:57,460
later on so you can drag in a sky
660
00:27:58,620 --> 00:27:59,620
atmosphere Skylight and stuff like that
661
00:28:01,140 --> 00:28:02,140
so these are the basic components of
662
00:28:03,120 --> 00:28:04,120
your Sky now if I go ahead and zoom into
663
00:28:05,520 --> 00:28:06,520
my directional light
664
00:28:07,200 --> 00:28:08,200
press e on my keyboard and rotate it you
665
00:28:10,200 --> 00:28:11,200
see the sun moves along with it
666
00:28:12,960 --> 00:28:13,960
so let's say we wanted an evening Sky we
667
00:28:15,179 --> 00:28:16,179
would use something like this
668
00:28:17,460 --> 00:28:18,460
and if you would notice the mobilities
669
00:28:20,340 --> 00:28:21,340
that set to stationary
670
00:28:22,860 --> 00:28:23,860
you could set it to movable then
671
00:28:25,080 --> 00:28:26,080
everything will be calculated
672
00:28:26,520 --> 00:28:27,520
dynamically and you won't have to build
673
00:28:28,320 --> 00:28:29,320
the lighting
674
00:28:30,000 --> 00:28:31,000
you could set it to stationary as well
675
00:28:33,419 --> 00:28:34,419
you could set it to static if you don't
676
00:28:35,880 --> 00:28:36,880
have any moving objects in your level
677
00:28:40,620 --> 00:28:41,620
now let's go ahead and just save
678
00:28:43,679 --> 00:28:44,679
everything
679
00:28:45,360 --> 00:28:46,360
now let's start actually creating
680
00:28:48,179 --> 00:28:49,179
something in our level
681
00:28:50,370 --> 00:28:51,370
[Music]
682
00:28:54,900 --> 00:28:55,900
so first of all remember I told you
683
00:28:57,360 --> 00:28:58,360
about the landscape tab this is what you
684
00:28:59,880 --> 00:29:00,880
would use if you have a larger world but
685
00:29:02,820 --> 00:29:03,820
for our purposes I'll just show you guys
686
00:29:05,220 --> 00:29:06,220
how to work with Landscapes even though
687
00:29:07,919 --> 00:29:08,919
we aren't really looking for a large
688
00:29:10,500 --> 00:29:11,500
world
689
00:29:11,820 --> 00:29:12,820
so here you can select your landscape
690
00:29:13,740 --> 00:29:14,740
material but you can change it anytime
691
00:29:15,900 --> 00:29:16,900
anyways and let's say you wanted a water
692
00:29:18,659 --> 00:29:19,659
body or something or let's say you
693
00:29:21,600 --> 00:29:22,600
wanted to have multiple multiple layers
694
00:29:24,419 --> 00:29:25,419
you know in your landscape you can click
695
00:29:26,399 --> 00:29:27,399
on enable edit layers
696
00:29:28,860 --> 00:29:29,860
uh and these things are basically a
697
00:29:32,220 --> 00:29:33,220
transform and stuff like that and these
698
00:29:35,279 --> 00:29:36,279
things are just these options number of
699
00:29:37,380 --> 00:29:38,380
components and the overall resolution
700
00:29:39,899 --> 00:29:40,899
adjust the size of your landscape so you
701
00:29:43,140 --> 00:29:44,140
can play around with that
702
00:29:44,820 --> 00:29:45,820
to see uh what the Precision or rather I
703
00:29:49,020 --> 00:29:50,020
should say the detail level of the
704
00:29:50,340 --> 00:29:51,340
landscape and the size should be
705
00:29:52,080 --> 00:29:53,080
depending on that you can increase that
706
00:29:55,080 --> 00:29:56,080
or you can go ahead and use a height map
707
00:29:57,240 --> 00:29:58,240
I actually have a chart on my channel on
708
00:29:59,880 --> 00:30:00,880
how to use height Maps properly in
709
00:30:01,980 --> 00:30:02,980
Unreal Engine
710
00:30:03,240 --> 00:30:04,240
but for our purposes we'll just create
711
00:30:05,279 --> 00:30:06,279
our own
712
00:30:06,419 --> 00:30:07,419
so let's just create everything with the
713
00:30:08,279 --> 00:30:09,279
default options
714
00:30:09,539 --> 00:30:10,539
and let's hit on create
715
00:30:13,740 --> 00:30:14,740
so it is going to take a while
716
00:30:20,940 --> 00:30:21,940
and once we are done with that we have a
717
00:30:23,580 --> 00:30:24,580
landscape
718
00:30:24,539 --> 00:30:25,539
now if I go ahead and press play as you
719
00:30:27,419 --> 00:30:28,419
can see I can navigate around this
720
00:30:29,760 --> 00:30:30,760
landscape just like you can navigate in
721
00:30:32,880 --> 00:30:33,880
any other level
722
00:30:34,980 --> 00:30:35,980
so now what I'm going to do is I'm going
723
00:30:37,799 --> 00:30:38,799
to edit the landscape now these are the
724
00:30:40,200 --> 00:30:41,200
tools that we'll be using to edit our
725
00:30:42,480 --> 00:30:43,480
landscape
726
00:30:43,620 --> 00:30:44,620
so you have to be under landscape mode
727
00:30:45,779 --> 00:30:46,779
and under this section over here you
728
00:30:48,240 --> 00:30:49,240
would find sculpt
729
00:30:49,919 --> 00:30:50,919
you can increase the tool strength you
730
00:30:52,320 --> 00:30:53,320
can get the brush type over here as well
731
00:30:54,500 --> 00:30:55,500
uh one thing that you will use is
732
00:30:57,059 --> 00:30:58,059
probably the alpha brush basically you
733
00:30:59,460 --> 00:31:00,460
can have your own mask and stuff but for
734
00:31:02,159 --> 00:31:03,159
our purposes we are going to be using
735
00:31:03,840 --> 00:31:04,840
the regular old Circle brush so I'll
736
00:31:06,059 --> 00:31:07,059
just increase the size now this need not
737
00:31:08,520 --> 00:31:09,520
be the limit actually I can set this to
738
00:31:10,860 --> 00:31:11,860
10 000 as well
739
00:31:12,720 --> 00:31:13,720
so if I go ahead and do that Let's see
740
00:31:15,720 --> 00:31:16,720
we have kind of a mountain here
741
00:31:18,360 --> 00:31:19,360
now what if I wanted to randomize the
742
00:31:21,059 --> 00:31:22,059
bumpiness in the map I could use noise
743
00:31:24,960 --> 00:31:25,960
so you see it's going to be like this
744
00:31:26,880 --> 00:31:27,880
but this is overkill so I can go ahead
745
00:31:29,279 --> 00:31:30,279
and change the tool strength to
746
00:31:30,600 --> 00:31:31,600
something like 0.05
747
00:31:32,460 --> 00:31:33,460
and as you see this is a lot more
748
00:31:34,620 --> 00:31:35,620
reasonable
749
00:31:36,059 --> 00:31:37,059
so this is what noise does flatten as
750
00:31:39,000 --> 00:31:40,000
the name suggests is going to flatten
751
00:31:40,880 --> 00:31:41,880
your landscape at that level so let's
752
00:31:43,860 --> 00:31:44,860
say select this level everything else is
753
00:31:46,500 --> 00:31:47,500
going to go to that level if I use
754
00:31:48,120 --> 00:31:49,120
flatten now obviously I can increase
755
00:31:50,279 --> 00:31:51,279
your tool strength if you wish
756
00:31:53,100 --> 00:31:54,100
completely up to you and there are many
757
00:31:56,700 --> 00:31:57,700
other things such as the brush fall off
758
00:31:58,260 --> 00:31:59,260
so basically if you want a softer brush
759
00:32:01,140 --> 00:32:02,140
so you could use the brush fall off and
760
00:32:03,299 --> 00:32:04,299
increase that if you want a completely
761
00:32:05,460 --> 00:32:06,460
hard brush you could go ahead and use
762
00:32:07,380 --> 00:32:08,380
this but as you can see it produces
763
00:32:09,299 --> 00:32:10,299
harsh effects so we aren't going to be
764
00:32:11,460 --> 00:32:12,460
using that
765
00:32:12,840 --> 00:32:13,840
again completely up to you
766
00:32:15,120 --> 00:32:16,120
and erosion is basically if you wanted
767
00:32:18,059 --> 00:32:19,059
to create natural looking slopes and
768
00:32:20,220 --> 00:32:21,220
stuff so for example
769
00:32:22,980 --> 00:32:23,980
so I'll just reset some of these
770
00:32:24,840 --> 00:32:25,840
settings here
771
00:32:26,760 --> 00:32:27,760
so something like this you could
772
00:32:28,799 --> 00:32:29,799
experiment and find out what what each
773
00:32:31,559 --> 00:32:32,559
one does
774
00:32:32,520 --> 00:32:33,520
but generally you would stick to sculpt
775
00:32:34,940 --> 00:32:35,940
smooth flatten Ram
776
00:32:38,220 --> 00:32:39,220
and maybe sometimes you would use
777
00:32:40,380 --> 00:32:41,380
erosion and you would use noise
778
00:32:43,980 --> 00:32:44,980
and let me show what ramp does real
779
00:32:46,200 --> 00:32:47,200
quick
780
00:32:47,279 --> 00:32:48,279
so if I select ramp
781
00:32:50,279 --> 00:32:51,279
and if I go ahead
782
00:32:52,580 --> 00:32:53,580
and click somewhere and click in another
783
00:32:57,360 --> 00:32:58,360
place and click on ADD ramp
784
00:33:00,120 --> 00:33:01,120
you see it Bridges those two locations
785
00:33:03,659 --> 00:33:04,659
with a straight line and this is going
786
00:33:06,480 --> 00:33:07,480
to be a ramp
787
00:33:07,860 --> 00:33:08,860
you could add a ram
788
00:33:09,779 --> 00:33:10,779
anywhere like this so I can go ahead and
789
00:33:12,600 --> 00:33:13,600
do this
790
00:33:13,860 --> 00:33:14,860
and I can click enter or I can press add
791
00:33:16,919 --> 00:33:17,919
ramp on the menu over there and it's
792
00:33:19,200 --> 00:33:20,200
going to add a ramp now if you had a
793
00:33:21,360 --> 00:33:22,360
character or something you can walk over
794
00:33:22,919 --> 00:33:23,919
it
795
00:33:23,760 --> 00:33:24,760
now again we can use the smooth tool in
796
00:33:26,640 --> 00:33:27,640
order to smoothen this out
797
00:33:29,940 --> 00:33:30,940
so now these two in this intersection
798
00:33:32,580 --> 00:33:33,580
looks seamless
799
00:33:34,799 --> 00:33:35,799
so these are basically a landscape
800
00:33:36,779 --> 00:33:37,779
editing tools there is not much depth to
801
00:33:39,659 --> 00:33:40,659
it and not sure what it is does actually
802
00:33:44,159 --> 00:33:45,159
so I've never used eres to be honest you
803
00:33:47,460 --> 00:33:48,460
just undo changes if you really had to
804
00:33:51,299 --> 00:33:52,299
and one more thing if you wanted to do
805
00:33:53,820 --> 00:33:54,820
the inverse of an operation so let's say
806
00:33:56,460 --> 00:33:57,460
I am sculpting a landscape so let's say
807
00:33:59,519 --> 00:34:00,519
I wanted something like this so I'll
808
00:34:02,399 --> 00:34:03,399
increase the tool strength
809
00:34:05,399 --> 00:34:06,399
so make that let's say 0.14
810
00:34:09,000 --> 00:34:10,000
now this is one way but what if you
811
00:34:11,580 --> 00:34:12,580
wanted a pit instead of a hill the way
812
00:34:14,280 --> 00:34:15,280
you do that is by holding shift it's
813
00:34:16,560 --> 00:34:17,560
going to reverse the operation and it is
814
00:34:18,839 --> 00:34:19,839
going to make a pit
815
00:34:20,820 --> 00:34:21,820
same goes for the other tools as well
816
00:34:22,679 --> 00:34:23,679
shift is going to be the inverse of the
817
00:34:24,960 --> 00:34:25,960
operation
818
00:34:27,179 --> 00:34:28,179
so that's about what you'll use in the
819
00:34:29,580 --> 00:34:30,580
unreal editor most of the time so now we
820
00:34:32,280 --> 00:34:33,280
can start creating our own assets make
821
00:34:34,440 --> 00:34:35,440
sure you first of all go into select
822
00:34:36,060 --> 00:34:37,060
mode again don't forget that and now we
823
00:34:39,179 --> 00:34:40,179
can go ahead and start talking about
824
00:34:40,859 --> 00:34:41,859
blueprints
825
00:34:42,719 --> 00:34:43,719
[Music]
826
00:34:44,099 --> 00:34:45,099
foreign
827
00:34:47,339 --> 00:34:48,339
so let's start talking about blueprint
828
00:34:50,060 --> 00:34:51,060
blueprint basically is the visual
829
00:34:52,919 --> 00:34:53,919
scripting language which is used to
830
00:34:54,839 --> 00:34:55,839
write game logic in Unreal Engine
831
00:34:57,480 --> 00:34:58,480
so blueprint code can be written in many
832
00:35:00,660 --> 00:35:01,660
types of assets if you right click go to
833
00:35:02,820 --> 00:35:03,820
blueprint class you can write blueprint
834
00:35:04,680 --> 00:35:05,680
code in most of these assets
835
00:35:07,020 --> 00:35:08,020
and we will get to some of the important
836
00:35:09,060 --> 00:35:10,060
ones a bit later for example act upon
837
00:35:11,280 --> 00:35:12,280
character player controller game mode
838
00:35:13,260 --> 00:35:14,260
there are few others such as the game
839
00:35:15,060 --> 00:35:16,060
State player State and so on we'll be
840
00:35:17,400 --> 00:35:18,400
getting into all that now the most basic
841
00:35:20,160 --> 00:35:21,160
type of blueprint is going to be a level
842
00:35:21,960 --> 00:35:22,960
blueprint so if you head into this menu
843
00:35:24,119 --> 00:35:25,119
over here click on open level blueprint
844
00:35:27,660 --> 00:35:28,660
you would say you'd get a blueprint
845
00:35:29,400 --> 00:35:30,400
associated with your level
846
00:35:31,740 --> 00:35:32,740
now begin play is as the name suggests
847
00:35:34,500 --> 00:35:35,500
something which is called as soon as the
848
00:35:36,839 --> 00:35:37,839
game begins or in this case as soon as
849
00:35:39,420 --> 00:35:40,420
you open the level
850
00:35:40,920 --> 00:35:41,920
please do not interpret begin play as
851
00:35:43,320 --> 00:35:44,320
when you click on the play button
852
00:35:46,440 --> 00:35:47,440
this is only called once you load into
853
00:35:48,960 --> 00:35:49,960
the level so let's say you load it into
854
00:35:51,000 --> 00:35:52,000
another level the begin play for that
855
00:35:53,700 --> 00:35:54,700
level will be called as well in order to
856
00:35:56,099 --> 00:35:57,099
actually start writing code you would
857
00:35:58,440 --> 00:35:59,440
use some built-in functions or you could
858
00:36:00,599 --> 00:36:01,599
write your own so the way you do it is
859
00:36:03,780 --> 00:36:04,780
if you right click for example and if
860
00:36:06,960 --> 00:36:07,960
you just type in I don't know let's say
861
00:36:09,300 --> 00:36:10,300
set location
862
00:36:10,740 --> 00:36:11,740
now let's say you wanted to set the
863
00:36:12,839 --> 00:36:13,839
location of something in your level
864
00:36:14,040 --> 00:36:15,040
let's actually do that
865
00:36:15,839 --> 00:36:16,839
uh since this is object oriented you
866
00:36:19,740 --> 00:36:20,740
will need context for everything so you
867
00:36:22,619 --> 00:36:23,619
need to know for Which object you're
868
00:36:24,359 --> 00:36:25,359
actually moving so for example let's say
869
00:36:26,520 --> 00:36:27,520
we have a point light here now one handy
870
00:36:29,220 --> 00:36:30,220
thing which I forgot to mention before
871
00:36:30,720 --> 00:36:31,720
let's say it's up over here and you want
872
00:36:33,240 --> 00:36:34,240
to snap it to the ground you can hit end
873
00:36:35,579 --> 00:36:36,579
on your keyboard and it's going to go to
874
00:36:37,380 --> 00:36:38,380
the ground level
875
00:36:38,820 --> 00:36:39,820
now we have this
876
00:36:41,520 --> 00:36:42,520
have that selected and head back into
877
00:36:43,560 --> 00:36:44,560
your level blueprint if you right click
878
00:36:46,140 --> 00:36:47,140
you get an option create a reference to
879
00:36:48,359 --> 00:36:49,359
point light now
880
00:36:50,339 --> 00:36:51,339
internally this is a pointer to this
881
00:36:53,700 --> 00:36:54,700
object or rather I should say to this
882
00:36:56,099 --> 00:36:57,099
actor anything that can be placed in a
883
00:36:58,140 --> 00:36:59,140
level is called an actor just remember
884
00:37:00,300 --> 00:37:01,300
that
885
00:37:01,380 --> 00:37:02,380
now if I drag off of this now I want to
886
00:37:03,960 --> 00:37:04,960
get its location let's say for example
887
00:37:06,079 --> 00:37:07,079
now the search bar is really useful for
888
00:37:09,540 --> 00:37:10,540
that you don't really need to know the
889
00:37:11,160 --> 00:37:12,160
function names especially in blueprints
890
00:37:13,140 --> 00:37:14,140
so just type in get location and you see
891
00:37:16,380 --> 00:37:17,380
get actor location
892
00:37:18,900 --> 00:37:19,900
now I can go ahead and print it for
893
00:37:21,839 --> 00:37:22,839
example so if I right click and type in
894
00:37:24,359 --> 00:37:25,359
print you see print string now this is
895
00:37:28,440 --> 00:37:29,440
called a function
896
00:37:29,940 --> 00:37:30,940
even this will be called a function so
897
00:37:31,740 --> 00:37:32,740
let's say I drag off of this and I type
898
00:37:34,020 --> 00:37:35,020
in set actor location
899
00:37:37,260 --> 00:37:38,260
again every getter will usually have its
900
00:37:40,500 --> 00:37:41,500
own Setter if it can be set
901
00:37:43,320 --> 00:37:44,320
so what we are saying what we are
902
00:37:45,060 --> 00:37:46,060
implying by this
903
00:37:46,500 --> 00:37:47,500
is
904
00:37:48,480 --> 00:37:49,480
set the location of this point light to
905
00:37:52,200 --> 00:37:53,200
be zero
906
00:37:53,940 --> 00:37:54,940
which is what you've defined over here
907
00:37:56,280 --> 00:37:57,280
now let's say we just wanted to move it
908
00:37:58,500 --> 00:37:59,500
up a bit so we can do plus
909
00:38:01,339 --> 00:38:02,339
and on the Z we can do 200 because Z is
910
00:38:05,339 --> 00:38:06,339
the up Axis in Unreal Engine
911
00:38:07,560 --> 00:38:08,560
and we can set that to be the new
912
00:38:09,420 --> 00:38:10,420
location
913
00:38:10,680 --> 00:38:11,680
so if I go ahead and press play
914
00:38:15,540 --> 00:38:16,540
don't see much uh see mobility of the
915
00:38:20,040 --> 00:38:21,040
light is set to stationary so we have to
916
00:38:22,980 --> 00:38:23,980
make it movable of course uh remember
917
00:38:25,079 --> 00:38:26,079
what I was telling you guys earlier with
918
00:38:27,599 --> 00:38:28,599
static and stationary you would assume
919
00:38:29,700 --> 00:38:30,700
it to be in the same place but with
920
00:38:31,740 --> 00:38:32,740
movable it's fully Dynamic so now if I
921
00:38:33,960 --> 00:38:34,960
press play you see it became dimmer in
922
00:38:36,720 --> 00:38:37,720
case you guys wanted to see the change
923
00:38:38,220 --> 00:38:39,220
if you just press D on your keyboard and
924
00:38:41,700 --> 00:38:42,700
left click you get a delay node or you
925
00:38:43,740 --> 00:38:44,740
could right click and search for delay
926
00:38:46,680 --> 00:38:47,680
but I prefer using D if you press D and
927
00:38:49,740 --> 00:38:50,740
left click you get a delay node let's
928
00:38:51,960 --> 00:38:52,960
just keep a delay of two seconds and
929
00:38:53,760 --> 00:38:54,760
then let's move it up
930
00:38:55,500 --> 00:38:56,500
so if I press play
931
00:38:58,079 --> 00:38:59,079
as you see it got dimmer because it went
932
00:39:00,839 --> 00:39:01,839
up
933
00:39:01,740 --> 00:39:02,740
now this blueprint function has a couple
934
00:39:05,220 --> 00:39:06,220
of pins on the left so these are called
935
00:39:07,560 --> 00:39:08,560
pins the stuff from which you can drag
936
00:39:10,020 --> 00:39:11,020
off of
937
00:39:11,280 --> 00:39:12,280
now the Triangular one or the pentagonal
938
00:39:15,480 --> 00:39:16,480
one I don't know what shape this is the
939
00:39:17,579 --> 00:39:18,579
one which drags off the white wires
940
00:39:19,740 --> 00:39:20,740
these ones are called execution pins so
941
00:39:23,040 --> 00:39:24,040
this function will be executed only when
942
00:39:25,980 --> 00:39:26,980
this pin goes from left to right so only
943
00:39:27,900 --> 00:39:28,900
when you connect something to it from
944
00:39:29,400 --> 00:39:30,400
the left and when this is executed this
945
00:39:32,400 --> 00:39:33,400
is going to be called and once this is
946
00:39:34,740 --> 00:39:35,740
done this is going to be executed now
947
00:39:38,220 --> 00:39:39,220
this one is a function as well get actor
948
00:39:40,500 --> 00:39:41,500
location is a function too however it
949
00:39:43,619 --> 00:39:44,619
does not have an execution pin you might
950
00:39:45,480 --> 00:39:46,480
notice the reason is this is a pure
951
00:39:48,240 --> 00:39:49,240
function you can define a pure function
952
00:39:51,060 --> 00:39:52,060
whenever you need a function to return
953
00:39:53,880 --> 00:39:54,880
immediate values
954
00:39:55,740 --> 00:39:56,740
so what I mean by that so for example if
955
00:39:59,040 --> 00:40:00,040
I have this hit result and let's say I
956
00:40:02,400 --> 00:40:03,400
print this out
957
00:40:04,079 --> 00:40:05,079
so I can't print out a hit result I
958
00:40:06,420 --> 00:40:07,420
figured so let's just take location now
959
00:40:09,960 --> 00:40:10,960
this is just a sweep hit result so let's
960
00:40:12,180 --> 00:40:13,180
say we move it somewhere and it collides
961
00:40:14,339 --> 00:40:15,339
with something in between it's going to
962
00:40:16,380 --> 00:40:17,380
return a hit result if you have sweep
963
00:40:18,240 --> 00:40:19,240
enabled
964
00:40:19,680 --> 00:40:20,680
uh now if I print this out this value
965
00:40:22,680 --> 00:40:23,680
right here is actually cached so let's
966
00:40:25,680 --> 00:40:26,680
say I copy a print string and let's say
967
00:40:27,660 --> 00:40:28,660
I print this out again
968
00:40:30,180 --> 00:40:31,180
set actor location is not going to be
969
00:40:32,940 --> 00:40:33,940
called once again
970
00:40:34,440 --> 00:40:35,440
this value what you had is going to be
971
00:40:37,079 --> 00:40:38,079
cached in your memory however over here
972
00:40:40,859 --> 00:40:41,859
if I just drag off of get actor location
973
00:40:46,980 --> 00:40:47,980
and let's drag off of this once again so
974
00:40:50,760 --> 00:40:51,760
let me drag this over here this value is
975
00:40:54,780 --> 00:40:55,780
not cached what I mean is get actor
976
00:40:57,720 --> 00:40:58,720
location is executed each time I'm
977
00:41:00,540 --> 00:41:01,540
calling this print string wherever I am
978
00:41:03,300 --> 00:41:04,300
referring to this value the entire
979
00:41:06,720 --> 00:41:07,720
function is going to be called once
980
00:41:08,760 --> 00:41:09,760
again and in this case it makes sense
981
00:41:10,980 --> 00:41:11,980
because whenever we execute get actor
982
00:41:13,500 --> 00:41:14,500
location we want at the live location of
983
00:41:16,680 --> 00:41:17,680
of the actor not the location which it
984
00:41:19,079 --> 00:41:20,079
was in previously if we go by that logic
985
00:41:21,960 --> 00:41:22,960
we would get the location before it was
986
00:41:24,599 --> 00:41:25,599
set so we will get the live data using a
987
00:41:28,020 --> 00:41:29,020
pure function
988
00:41:29,400 --> 00:41:30,400
and the target Works in a similar way we
989
00:41:32,460 --> 00:41:33,460
are getting the point lights location so
990
00:41:35,160 --> 00:41:36,160
the target is point light
991
00:41:37,680 --> 00:41:38,680
now one more thing you might notice is
992
00:41:39,359 --> 00:41:40,359
event tick tick is basically a function
993
00:41:41,820 --> 00:41:42,820
which is called on every frame so if I
994
00:41:44,280 --> 00:41:45,280
just hit print and if I just print out
995
00:41:47,160 --> 00:41:48,160
tick for example
996
00:41:49,140 --> 00:41:50,140
you'd see it prints it a bunch of times
997
00:41:51,000 --> 00:41:52,000
basically every time a new frame is
998
00:41:53,160 --> 00:41:54,160
drawn uh the tick function is called
999
00:41:56,800 --> 00:41:57,800
[Music]
1000
00:42:00,560 --> 00:42:01,560
now whatever I told you guys is just a
1001
00:42:03,420 --> 00:42:04,420
vague overview of how blueprint works so
1002
00:42:05,460 --> 00:42:06,460
I just talked about execution pins and
1003
00:42:07,680 --> 00:42:08,680
that it's object oriented and types are
1004
00:42:10,079 --> 00:42:11,079
color coded but now let's actually start
1005
00:42:12,780 --> 00:42:13,780
talking about them one by one so the
1006
00:42:15,180 --> 00:42:16,180
first thing you would want to do in any
1007
00:42:17,460 --> 00:42:18,460
sort of a programming language or if
1008
00:42:19,440 --> 00:42:20,440
you're writing any code is first of all
1009
00:42:22,440 --> 00:42:23,440
be able to store data and that's done
1010
00:42:24,599 --> 00:42:25,599
through variables now the way you create
1011
00:42:26,760 --> 00:42:27,760
a new variable in Blueprint is by
1012
00:42:28,859 --> 00:42:29,859
clicking on this little plus icon on the
1013
00:42:30,960 --> 00:42:31,960
left hand side
1014
00:42:32,099 --> 00:42:33,099
this menu is available in almost every
1015
00:42:34,859 --> 00:42:35,859
blueprint so click on the plus icon and
1016
00:42:37,920 --> 00:42:38,920
you can create a variable
1017
00:42:40,079 --> 00:42:41,079
now let's just call it my variable for
1018
00:42:42,780 --> 00:42:43,780
example
1019
00:42:43,980 --> 00:42:44,980
now over here since blueprint is based
1020
00:42:47,640 --> 00:42:48,640
on C plus plus obviously you you have to
1021
00:42:51,000 --> 00:42:52,000
define a type for it so by default it's
1022
00:42:53,760 --> 00:42:54,760
set to Boolean but you can select any
1023
00:42:55,560 --> 00:42:56,560
one of the other types I'll go over some
1024
00:42:57,660 --> 00:42:58,660
of the important ones if you are
1025
00:42:59,579 --> 00:43:00,579
familiar with C plus plus these things
1026
00:43:01,319 --> 00:43:02,319
will seem pretty simple to you guys so
1027
00:43:05,040 --> 00:43:06,040
Boolean is basically a true or false
1028
00:43:07,260 --> 00:43:08,260
value so for example
1029
00:43:09,000 --> 00:43:10,000
if I drag my variable and let's say you
1030
00:43:11,579 --> 00:43:12,579
want to get the value of a variable you
1031
00:43:13,560 --> 00:43:14,560
can drag it and hit get so this is going
1032
00:43:16,380 --> 00:43:17,380
to be the value so off of this pin let's
1033
00:43:19,319 --> 00:43:20,319
say I I type in if
1034
00:43:21,420 --> 00:43:22,420
we'll get to branching and stuff a bit
1035
00:43:23,460 --> 00:43:24,460
later but I can do stuff like this since
1036
00:43:26,940 --> 00:43:27,940
this is a true or false value if this
1037
00:43:29,280 --> 00:43:30,280
variable is true this execution pin is
1038
00:43:31,740 --> 00:43:32,740
going to come out if the value is false
1039
00:43:34,200 --> 00:43:35,200
this execution pin is going to come out
1040
00:43:37,020 --> 00:43:38,020
so that's basically how it works same
1041
00:43:40,020 --> 00:43:41,020
way with all the other types so I can
1042
00:43:42,119 --> 00:43:43,119
click on this variable and change the
1043
00:43:43,560 --> 00:43:44,560
type to integer
1044
00:43:45,119 --> 00:43:46,119
which is basically a non-fractional
1045
00:43:47,160 --> 00:43:48,160
number N64 is basically 64 but integer
1046
00:43:50,940 --> 00:43:51,940
so let's say you have larger numbers so
1047
00:43:53,280 --> 00:43:54,280
you would use integer 64. however I
1048
00:43:56,040 --> 00:43:57,040
don't really find many use cases for it
1049
00:43:58,560 --> 00:43:59,560
float is a decimal number and then you
1050
00:44:02,220 --> 00:44:03,220
have name String and text all of which
1051
00:44:04,140 --> 00:44:05,140
are string types most of the times you
1052
00:44:06,480 --> 00:44:07,480
would be using string
1053
00:44:08,099 --> 00:44:09,099
however in some cases you would use name
1054
00:44:10,380 --> 00:44:11,380
as well for example in tags which we
1055
00:44:12,780 --> 00:44:13,780
will talk about later and text is mostly
1056
00:44:16,140 --> 00:44:17,140
used for UI and stuff like that so if
1057
00:44:20,220 --> 00:44:21,220
whatever you see in menus and things
1058
00:44:22,140 --> 00:44:23,140
like that uh the text the strings over
1059
00:44:25,140 --> 00:44:26,140
there are stored as text so that's the
1060
00:44:28,920 --> 00:44:29,920
data type you'll use now a vector is a
1061
00:44:32,760 --> 00:44:33,760
struct with three floats in it x y and z
1062
00:44:36,660 --> 00:44:37,660
now obviously if you don't know what a
1063
00:44:39,540 --> 00:44:40,540
struct is we will again talk about that
1064
00:44:41,640 --> 00:44:42,640
no issues Rotator is a similar thing
1065
00:44:44,940 --> 00:44:45,940
except uh there is a limitation on what
1066
00:44:47,940 --> 00:44:48,940
values you can have you can only have a
1067
00:44:50,220 --> 00:44:51,220
value of 0 up until 360. beyond that the
1068
00:44:54,119 --> 00:44:55,119
Rotator is going to be invalid
1069
00:44:56,480 --> 00:44:57,480
and transform is basically a struct
1070
00:45:00,000 --> 00:45:01,000
again which contains a vector
1071
00:45:03,420 --> 00:45:04,420
a rotator and a vector so location
1072
00:45:07,500 --> 00:45:08,500
rotation and scale so this is
1073
00:45:10,980 --> 00:45:11,980
transformed these are the fundamental
1074
00:45:12,900 --> 00:45:13,900
types which you use most of the time
1075
00:45:15,540 --> 00:45:16,540
however if you go undestruct you would
1076
00:45:18,300 --> 00:45:19,300
see there are a lot more you will not
1077
00:45:20,460 --> 00:45:21,460
use most of these uh some of the common
1078
00:45:22,800 --> 00:45:23,800
ones that you will use are things such
1079
00:45:24,599 --> 00:45:25,599
as hit result so hit result is a common
1080
00:45:27,119 --> 00:45:28,119
one that you'll use now if I compile
1081
00:45:29,220 --> 00:45:30,220
this and if I go ahead and drag this out
1082
00:45:34,260 --> 00:45:35,260
and if I go ahead and break and one more
1083
00:45:37,079 --> 00:45:38,079
thing if you want to get this variable
1084
00:45:38,700 --> 00:45:39,700
there's a shortcut if you hold Ctrl and
1085
00:45:41,700 --> 00:45:42,700
drag it you will get the value and if
1086
00:45:43,980 --> 00:45:44,980
you want to set this variable you can
1087
00:45:45,599 --> 00:45:46,599
all drag it so that's just a small tip I
1088
00:45:48,540 --> 00:45:49,540
can give you guys
1089
00:45:49,859 --> 00:45:50,859
so now bracket result is going to show
1090
00:45:52,619 --> 00:45:53,619
us all the different
1091
00:45:54,599 --> 00:45:55,599
variables inside this now similarly you
1092
00:45:57,180 --> 00:45:58,180
can do that with any other struct if you
1093
00:45:59,040 --> 00:46:00,040
just drag off of this and try type in
1094
00:46:00,720 --> 00:46:01,720
break you can do that or with some
1095
00:46:03,359 --> 00:46:04,359
structs you can you can even do split
1096
00:46:05,940 --> 00:46:06,940
struct pin
1097
00:46:07,200 --> 00:46:08,200
or actually with all structs
1098
00:46:09,300 --> 00:46:10,300
so that's basically another way to see
1099
00:46:11,700 --> 00:46:12,700
what members are there in the struct so
1100
00:46:14,040 --> 00:46:15,040
for example uh similar to this this was
1101
00:46:16,800 --> 00:46:17,800
the same struct over here so you see
1102
00:46:19,380 --> 00:46:20,380
initial overlap so this is going to be
1103
00:46:21,180 --> 00:46:22,180
their blocking hit location and things
1104
00:46:24,000 --> 00:46:25,000
like that so that's basically your
1105
00:46:26,339 --> 00:46:27,339
struct that's how it works in Blueprint
1106
00:46:29,000 --> 00:46:30,000
and one
1107
00:46:31,140 --> 00:46:32,140
different type is going to be our object
1108
00:46:33,900 --> 00:46:34,900
type variable so for example if I select
1109
00:46:35,819 --> 00:46:36,819
an actor and this was an object type as
1110
00:46:38,339 --> 00:46:39,339
well if I drag off of this the variable
1111
00:46:41,160 --> 00:46:42,160
which is color coded in your sky blue or
1112
00:46:44,220 --> 00:46:45,220
your light blue color so these are
1113
00:46:47,520 --> 00:46:48,520
basically object references
1114
00:46:49,859 --> 00:46:50,859
internally when you write these in C
1115
00:46:52,619 --> 00:46:53,619
plus plus so let's say you create an
1116
00:46:55,020 --> 00:46:56,020
object reference for blueprint in C plus
1117
00:46:57,599 --> 00:46:58,599
you can expose C plus plus variables to
1118
00:46:59,880 --> 00:47:00,880
blueprint by the way they are stored as
1119
00:47:02,099 --> 00:47:03,099
pointers so basically it's the memory
1120
00:47:04,500 --> 00:47:05,500
address to that object now if some of
1121
00:47:07,740 --> 00:47:08,740
these things sound confusing to you just
1122
00:47:10,020 --> 00:47:11,020
stick along and watch the course till
1123
00:47:14,099 --> 00:47:15,099
the end and if you guys still have any
1124
00:47:16,680 --> 00:47:17,680
confusions make sure you guys do check
1125
00:47:18,480 --> 00:47:19,480
out a video on pointers and I will go
1126
00:47:22,380 --> 00:47:23,380
over actors and stuff like that
1127
00:47:24,440 --> 00:47:25,440
basically uh this variable is going to
1128
00:47:27,839 --> 00:47:28,839
refer to an actor and since this is a
1129
00:47:30,359 --> 00:47:31,359
pointer and the default value is none so
1130
00:47:32,760 --> 00:47:33,760
if I go ahead and click on this you see
1131
00:47:34,380 --> 00:47:35,380
it says None so what this means is this
1132
00:47:37,020 --> 00:47:38,020
is not a valid pointer and if we
1133
00:47:39,480 --> 00:47:40,480
actually had some logic in C plus plus
1134
00:47:41,880 --> 00:47:42,880
it would throw an exception so that's
1135
00:47:45,420 --> 00:47:46,420
basically how object types work and you
1136
00:47:47,760 --> 00:47:48,760
all also have enumerations which are are
1137
00:47:51,480 --> 00:47:52,480
in in some disguise just your byte which
1138
00:47:56,220 --> 00:47:57,220
is an unsigned 8-bit integer so
1139
00:47:58,920 --> 00:47:59,920
basically uh for example if I just grab
1140
00:48:01,920 --> 00:48:02,920
a random enum over here I can do a
1141
00:48:05,220 --> 00:48:06,220
switch which we'll talk about
1142
00:48:07,319 --> 00:48:08,319
so basically depending on the value of
1143
00:48:10,079 --> 00:48:11,079
this variable you can perform your logic
1144
00:48:13,560 --> 00:48:14,560
so a common thing that you would use it
1145
00:48:15,720 --> 00:48:16,720
for is let's say you have a weapon in a
1146
00:48:17,940 --> 00:48:18,940
game and depending on the type so let's
1147
00:48:20,760 --> 00:48:21,760
say a weapon is fully automatic you
1148
00:48:22,619 --> 00:48:23,619
would have an enumeration so one of
1149
00:48:25,319 --> 00:48:26,319
these enumerators is going to be full
1150
00:48:27,960 --> 00:48:28,960
auto the other one is going to be
1151
00:48:29,520 --> 00:48:30,520
semi-auto the other one is going to be
1152
00:48:31,319 --> 00:48:32,319
bolt action and depending on that you
1153
00:48:33,720 --> 00:48:34,720
would execute the appropriate logic so
1154
00:48:35,640 --> 00:48:36,640
that's one way of using enums there are
1155
00:48:37,500 --> 00:48:38,500
many applications of course we will get
1156
00:48:39,240 --> 00:48:40,240
to most of them later
1157
00:48:42,490 --> 00:48:43,490
[Music]
1158
00:48:46,400 --> 00:48:47,400
now that's about how you basically
1159
00:48:49,140 --> 00:48:50,140
create variables so now let's actually
1160
00:48:51,780 --> 00:48:52,780
talk about a few special types of
1161
00:48:54,180 --> 00:48:55,180
variables namely structs and enums now I
1162
00:48:57,119 --> 00:48:58,119
did show you what's a struct and Anum
1163
00:48:59,099 --> 00:49:00,099
but I'm pretty sure it went all over
1164
00:49:01,079 --> 00:49:02,079
your head if you're a beginner so let's
1165
00:49:02,940 --> 00:49:03,940
just delete that and click on this
1166
00:49:04,920 --> 00:49:05,920
variable and hit delete to delete that
1167
00:49:06,599 --> 00:49:07,599
as well compile and save that
1168
00:49:08,760 --> 00:49:09,760
now go ahead and right click create a
1169
00:49:12,180 --> 00:49:13,180
new folder and call it structs and I'm
1170
00:49:15,420 --> 00:49:16,420
doing this in my content folder uh you
1171
00:49:18,060 --> 00:49:19,060
could do it in the same place if you
1172
00:49:19,680 --> 00:49:20,680
want to follow along
1173
00:49:21,119 --> 00:49:22,119
right click go ahead into Blueprints and
1174
00:49:25,619 --> 00:49:26,619
create a structure
1175
00:49:27,300 --> 00:49:28,300
and for now let's just call it my struct
1176
00:49:32,640 --> 00:49:33,640
now
1177
00:49:34,140 --> 00:49:35,140
structs by definition in C plus plus is
1178
00:49:37,920 --> 00:49:38,920
going to be similar to your classes
1179
00:49:40,079 --> 00:49:41,079
so basically you wrap a bunch of data
1180
00:49:43,020 --> 00:49:44,020
and methods
1181
00:49:44,760 --> 00:49:45,760
into a single unit
1182
00:49:46,740 --> 00:49:47,740
however in Blueprint as a structure
1183
00:49:50,339 --> 00:49:51,339
purely refers to a collection of
1184
00:49:52,500 --> 00:49:53,500
variables you cannot have functions for
1185
00:49:55,079 --> 00:49:56,079
structs in Blueprint sadly however you
1186
00:49:58,920 --> 00:49:59,920
could just create a library for that so
1187
00:50:01,319 --> 00:50:02,319
you have blueprint function libraries
1188
00:50:03,000 --> 00:50:04,000
and you could just create functions for
1189
00:50:04,859 --> 00:50:05,859
your structs
1190
00:50:06,839 --> 00:50:07,839
anyways so the way you work with this is
1191
00:50:10,079 --> 00:50:11,079
you can create a bunch of member
1192
00:50:11,760 --> 00:50:12,760
variables a very simple example is going
1193
00:50:15,060 --> 00:50:16,060
to be a 2d Vector Unreal Engine already
1194
00:50:18,119 --> 00:50:19,119
has a 2d Vector type but just for
1195
00:50:20,760 --> 00:50:21,760
demonstration purposes let's just create
1196
00:50:22,980 --> 00:50:23,980
one so let's just call this X and make
1197
00:50:26,819 --> 00:50:27,819
this of type float because it's a
1198
00:50:28,980 --> 00:50:29,980
decimal number
1199
00:50:30,180 --> 00:50:31,180
add in another variable
1200
00:50:32,460 --> 00:50:33,460
make it of type Y and make this of type
1201
00:50:36,359 --> 00:50:37,359
float once again so basically my struct
1202
00:50:40,020 --> 00:50:41,020
is going to contain these two variables
1203
00:50:42,420 --> 00:50:43,420
now if I head back into my level make
1204
00:50:44,520 --> 00:50:45,520
sure you save this
1205
00:50:46,380 --> 00:50:47,380
and if I go ahead and right click
1206
00:50:48,720 --> 00:50:49,720
somewhere and type in Maestra
1207
00:50:52,260 --> 00:50:53,260
you see you get an option called Break
1208
00:50:54,359 --> 00:50:55,359
make and set members so if I go ahead
1209
00:50:57,480 --> 00:50:58,480
and press break you see you get options
1210
00:50:59,520 --> 00:51:00,520
X and Y now just like how you create an
1211
00:51:02,460 --> 00:51:03,460
integer or any other variable you can
1212
00:51:04,200 --> 00:51:05,200
create a struct as well so let's just
1213
00:51:06,599 --> 00:51:07,599
call this one I don't know maybe my
1214
00:51:09,420 --> 00:51:10,420
variable once again
1215
00:51:13,160 --> 00:51:14,160
and it's going to be of type my struct
1216
00:51:16,260 --> 00:51:17,260
so my struct is the type so this is our
1217
00:51:19,079 --> 00:51:20,079
user defined data type
1218
00:51:21,480 --> 00:51:22,480
now I can go ahead and get this I can
1219
00:51:24,599 --> 00:51:25,599
right click perform split struct pin
1220
00:51:27,180 --> 00:51:28,180
once again
1221
00:51:28,200 --> 00:51:29,200
so this is basically how struct so
1222
00:51:30,000 --> 00:51:31,000
basically you have one variable which
1223
00:51:32,460 --> 00:51:33,460
stores multiple variables within it so
1224
00:51:35,220 --> 00:51:36,220
this can be very handy for example in
1225
00:51:37,800 --> 00:51:38,800
this hit result you have all these
1226
00:51:39,839 --> 00:51:40,839
variables now it did not need not be the
1227
00:51:42,599 --> 00:51:43,599
same type the types can be heterogeneous
1228
00:51:45,599 --> 00:51:46,599
so I could have an integer over here I
1229
00:51:49,079 --> 00:51:50,079
could have a string over here
1230
00:51:51,000 --> 00:51:52,000
so let's say I have a student struct I
1231
00:51:53,700 --> 00:51:54,700
could store name
1232
00:51:55,260 --> 00:51:56,260
his role number and stuff like that so
1233
00:51:57,900 --> 00:51:58,900
just a big example over there
1234
00:52:00,660 --> 00:52:01,660
so that's basically how structs work in
1235
00:52:03,300 --> 00:52:04,300
Blueprint so I'll just delete that we
1236
00:52:05,579 --> 00:52:06,579
don't really need it but we'll keep my
1237
00:52:07,920 --> 00:52:08,920
strength let's actually have something
1238
00:52:10,920 --> 00:52:11,920
more descriptive let's say we have name
1239
00:52:13,500 --> 00:52:14,500
and let's say we have points
1240
00:52:15,960 --> 00:52:16,960
this makes no sense right now but we can
1241
00:52:18,540 --> 00:52:19,540
use this a bit later on
1242
00:52:20,640 --> 00:52:21,640
and you could anytime add a new variable
1243
00:52:23,640 --> 00:52:24,640
but remember avoid removing variables
1244
00:52:26,220 --> 00:52:27,220
from structs sometimes they do cause
1245
00:52:28,800 --> 00:52:29,800
some issues with the blueprint so be
1246
00:52:31,440 --> 00:52:32,440
careful with that in C plus plus though
1247
00:52:33,300 --> 00:52:34,300
it won't be too much of a problem since
1248
00:52:35,460 --> 00:52:36,460
you refer to the members by their names
1249
00:52:37,760 --> 00:52:38,760
so that's one thing to note
1250
00:52:40,680 --> 00:52:41,680
now one more thing if you guys want to
1251
00:52:43,559 --> 00:52:44,559
set the members of a struct what you do
1252
00:52:46,500 --> 00:52:47,500
is you just type in set members
1253
00:52:49,460 --> 00:52:50,460
and you can get the struct name that is
1254
00:52:52,740 --> 00:52:53,740
my struct in our case so we can use this
1255
00:52:55,260 --> 00:52:56,260
and set the members now over here on the
1256
00:52:57,839 --> 00:52:58,839
right hand side under default category
1257
00:52:59,760 --> 00:53:00,760
you can get any one of the variables as
1258
00:53:01,740 --> 00:53:02,740
pins and you can set the value now
1259
00:53:04,440 --> 00:53:05,440
obviously you will need to tell it which
1260
00:53:06,780 --> 00:53:07,780
struct so let's say you created a
1261
00:53:08,400 --> 00:53:09,400
variable of type my struct
1262
00:53:11,040 --> 00:53:12,040
so by struct
1263
00:53:13,740 --> 00:53:14,740
you can go ahead and pass that as the
1264
00:53:16,500 --> 00:53:17,500
struct reference now this is a reference
1265
00:53:18,599 --> 00:53:19,599
because this pin over here is diamond in
1266
00:53:21,660 --> 00:53:22,660
shape or rhombus or whatever that is so
1267
00:53:24,720 --> 00:53:25,720
that means it's a reference so it is
1268
00:53:26,940 --> 00:53:27,940
referring to the actual
1269
00:53:29,660 --> 00:53:30,660
variable that you pass in
1270
00:53:32,160 --> 00:53:33,160
so it is going to adjust the value of
1271
00:53:34,800 --> 00:53:35,800
this variable
1272
00:53:37,000 --> 00:53:38,000
[Music]
1273
00:53:38,579 --> 00:53:39,579
oh
1274
00:53:41,220 --> 00:53:42,220
we will deal with a lot of structs as we
1275
00:53:44,040 --> 00:53:45,040
move on however there's one more special
1276
00:53:46,380 --> 00:53:47,380
type which I would like to mention and
1277
00:53:48,540 --> 00:53:49,540
those are enumeration so I will right
1278
00:53:51,300 --> 00:53:52,300
click create a new folder and I'll call
1279
00:53:53,099 --> 00:53:54,099
this one enums
1280
00:53:54,780 --> 00:53:55,780
open it up and over here I can head into
1281
00:53:57,660 --> 00:53:58,660
blueprints again and type in enumeration
1282
00:54:00,000 --> 00:54:01,000
so this is basically a list of values
1283
00:54:02,640 --> 00:54:03,640
and you could perform your logic
1284
00:54:04,619 --> 00:54:05,619
depending on this list so let's just uh
1285
00:54:08,579 --> 00:54:09,579
create an enum and let's call this one
1286
00:54:11,280 --> 00:54:12,280
my enum again
1287
00:54:13,200 --> 00:54:14,200
now over here you can add enumerators
1288
00:54:15,480 --> 00:54:16,480
which basically are list items so let's
1289
00:54:17,819 --> 00:54:18,819
say add three items so for example let's
1290
00:54:22,380 --> 00:54:23,380
take names of fruits so Apple
1291
00:54:26,940 --> 00:54:27,940
banana let's say and maybe a mango
1292
00:54:31,680 --> 00:54:32,680
now once you do this these are basically
1293
00:54:35,040 --> 00:54:36,040
the enumerators which are there and I
1294
00:54:37,140 --> 00:54:38,140
will show you guys what it actually
1295
00:54:38,520 --> 00:54:39,520
implies
1296
00:54:39,540 --> 00:54:40,540
so I'll just go ahead and create a new
1297
00:54:41,460 --> 00:54:42,460
variable and I'll call this one I don't
1298
00:54:44,819 --> 00:54:45,819
know let's say
1299
00:54:46,260 --> 00:54:47,260
fruits choice for example
1300
00:54:48,900 --> 00:54:49,900
and it's going to be of type my enum
1301
00:54:53,400 --> 00:54:54,400
now internally ultimately an enumeration
1302
00:54:56,579 --> 00:54:57,579
is just a number basically it's a number
1303
00:54:59,160 --> 00:55:00,160
between 0 and 256 so for example
1304
00:55:02,940 --> 00:55:03,940
over here apple is going to be index to
1305
00:55:06,180 --> 00:55:07,180
1. Banana is going to be mapped to 2 and
1306
00:55:09,660 --> 00:55:10,660
mango is going to be mapped to I mean
1307
00:55:11,940 --> 00:55:12,940
one and uh mango is going to be mapped
1308
00:55:14,880 --> 00:55:15,880
to 2 so 0 1 2 so that's how it's going
1309
00:55:18,900 --> 00:55:19,900
to be internally now obviously you can
1310
00:55:20,579 --> 00:55:21,579
give a description as well over here in
1311
00:55:22,079 --> 00:55:23,079
Blueprint
1312
00:55:23,099 --> 00:55:24,099
uh so if I just drag this in now by
1313
00:55:26,579 --> 00:55:27,579
default it is set to Apple you can see
1314
00:55:28,440 --> 00:55:29,440
the default value on the right hand side
1315
00:55:30,240 --> 00:55:31,240
and we will talk about all these options
1316
00:55:32,460 --> 00:55:33,460
a bit later on in the variable section
1317
00:55:34,680 --> 00:55:35,680
so just to be brief uh if you are like
1318
00:55:38,760 --> 00:55:39,760
creating new objects in your scene uh
1319
00:55:42,300 --> 00:55:43,300
you would need some of these and for
1320
00:55:44,339 --> 00:55:45,339
multiplayer and stuff you would need
1321
00:55:45,720 --> 00:55:46,720
replication and we will talk about them
1322
00:55:48,000 --> 00:55:49,000
in depth so nothing to worry about now
1323
00:55:50,700 --> 00:55:51,700
you can cast it to a string so unreal
1324
00:55:54,119 --> 00:55:55,119
has it built in to give this out as a
1325
00:55:56,339 --> 00:55:57,339
string
1326
00:55:57,240 --> 00:55:58,240
so if you see you should get apple
1327
00:55:59,579 --> 00:56:00,579
printed
1328
00:56:01,079 --> 00:56:02,079
oops I have something on tick so let's
1329
00:56:03,240 --> 00:56:04,240
just delete that
1330
00:56:05,940 --> 00:56:06,940
so nothing's printing
1331
00:56:08,520 --> 00:56:09,520
uh okay we have a delay of two seconds
1332
00:56:10,800 --> 00:56:11,800
let's just delete the set actor location
1333
00:56:12,839 --> 00:56:13,839
stuff
1334
00:56:15,599 --> 00:56:16,599
and just print this in
1335
00:56:17,700 --> 00:56:18,700
and we could actually change this as
1336
00:56:20,940 --> 00:56:21,940
well
1337
00:56:23,460 --> 00:56:24,460
you can copy this and paste it by
1338
00:56:26,099 --> 00:56:27,099
hitting Ctrl D so if you click on this
1339
00:56:28,440 --> 00:56:29,440
and hit Ctrl D you can duplicate it and
1340
00:56:31,440 --> 00:56:32,440
if you drag off of this
1341
00:56:33,780 --> 00:56:34,780
you'll see you can perform a switch
1342
00:56:36,300 --> 00:56:37,300
so basically if the value of fruits
1343
00:56:38,940 --> 00:56:39,940
choice is Apple
1344
00:56:40,920 --> 00:56:41,920
it's going to perform this logic so
1345
00:56:43,859 --> 00:56:44,859
let's just say
1346
00:56:46,079 --> 00:56:47,079
held it for example
1347
00:56:49,280 --> 00:56:50,280
and for
1348
00:56:51,540 --> 00:56:52,540
banana let's just give something else
1349
00:56:55,380 --> 00:56:56,380
so it honestly doesn't matter
1350
00:56:58,200 --> 00:56:59,200
copy that over
1351
00:56:59,700 --> 00:57:00,700
and let's say we give tasty for mango
1352
00:57:04,200 --> 00:57:05,200
so if I go ahead and press play you
1353
00:57:07,260 --> 00:57:08,260
should see it says apple and healthy
1354
00:57:10,260 --> 00:57:11,260
now
1355
00:57:11,579 --> 00:57:12,579
if I set this value so if I alt drag it
1356
00:57:14,400 --> 00:57:15,400
and I set this to banana
1357
00:57:19,680 --> 00:57:20,680
now you should be able to see that it
1358
00:57:22,859 --> 00:57:23,859
prints the second string
1359
00:57:25,380 --> 00:57:26,380
so this is basically how enums work and
1360
00:57:29,040 --> 00:57:30,040
this was actually a bit of a lengthy way
1361
00:57:32,400 --> 00:57:33,400
I did it there's actually another
1362
00:57:33,780 --> 00:57:34,780
shortcut you can use in Blueprint in C
1363
00:57:36,359 --> 00:57:37,359
plus plus though this is the only way
1364
00:57:37,920 --> 00:57:38,920
you would just type in switch instead of
1365
00:57:40,680 --> 00:57:41,680
using this node
1366
00:57:42,359 --> 00:57:43,359
so one more shortcut is if you drag off
1367
00:57:45,420 --> 00:57:46,420
of this and type in select
1368
00:57:47,359 --> 00:57:48,359
depending on the value of this enum you
1369
00:57:51,119 --> 00:57:52,119
can make it do certain things so let me
1370
00:57:53,220 --> 00:57:54,220
remove the switch here
1371
00:57:56,700 --> 00:57:57,700
so now what I'm saying is if the value
1372
00:58:00,059 --> 00:58:01,059
of fruits choice is Apple this is the
1373
00:58:02,760 --> 00:58:03,760
value that will be passed so in this
1374
00:58:04,619 --> 00:58:05,619
case I'll just type in one for example
1375
00:58:06,420 --> 00:58:07,420
and over here I'm going to type 2 and 3.
1376
00:58:09,300 --> 00:58:10,300
so what we are saying is if the value of
1377
00:58:12,119 --> 00:58:13,119
this enumeration is Apple it's going to
1378
00:58:14,579 --> 00:58:15,579
print out one so the value which will be
1379
00:58:16,619 --> 00:58:17,619
returned here is going to be this value
1380
00:58:18,960 --> 00:58:19,960
same with the other two choices so if I
1381
00:58:22,740 --> 00:58:23,740
press play you see it says apple and it
1382
00:58:24,960 --> 00:58:25,960
says two that's because we had set our
1383
00:58:27,059 --> 00:58:28,059
choice over here if I change this to
1384
00:58:29,460 --> 00:58:30,460
Mango over here we are going to get
1385
00:58:31,680 --> 00:58:32,680
three so that's basically how
1386
00:58:33,599 --> 00:58:34,599
enumerations work
1387
00:58:35,880 --> 00:58:36,880
[Music]
1388
00:58:43,859 --> 00:58:44,859
real engine let's start talking about
1389
00:58:46,260 --> 00:58:47,260
the core scripting features in Blueprint
1390
00:58:48,420 --> 00:58:49,420
so the first thing that you can do is
1391
00:58:50,940 --> 00:58:51,940
create functions now a function is
1392
00:58:53,700 --> 00:58:54,700
basically a block of code which adds
1393
00:58:57,359 --> 00:58:58,359
functionality to your program so what I
1394
00:58:59,819 --> 00:59:00,819
mean by that so in order to create a new
1395
00:59:01,740 --> 00:59:02,740
function you can go ahead and click on
1396
00:59:03,960 --> 00:59:04,960
this plus icon right here
1397
00:59:05,960 --> 00:59:06,960
and we could call it whatever we want we
1398
00:59:09,119 --> 00:59:10,119
could call this one my function
1399
00:59:12,119 --> 00:59:13,119
and generally speaking you would use
1400
00:59:14,400 --> 00:59:15,400
Pascal case so basically each word is
1401
00:59:18,240 --> 00:59:19,240
going to start with an uppercase
1402
00:59:19,740 --> 00:59:20,740
character
1403
00:59:21,119 --> 00:59:22,119
so generally that's a convention you use
1404
00:59:23,339 --> 00:59:24,339
you could use a space as well in
1405
00:59:25,079 --> 00:59:26,079
Blueprint but generally it's not a good
1406
00:59:26,880 --> 00:59:27,880
practice
1407
00:59:28,680 --> 00:59:29,680
now I can call this function from my
1408
00:59:31,500 --> 00:59:32,500
event graph now if you see you have
1409
00:59:33,180 --> 00:59:34,180
opened two tabs one is the event graph
1410
00:59:35,280 --> 00:59:36,280
and one is my function so I can close my
1411
00:59:38,220 --> 00:59:39,220
function and I can double click on this
1412
00:59:39,839 --> 00:59:40,839
on the left hand side to open it as well
1413
00:59:42,900 --> 00:59:43,900
now if I drag this in
1414
00:59:45,839 --> 00:59:46,839
or if I right click and type in my
1415
00:59:48,359 --> 00:59:49,359
function
1416
00:59:49,319 --> 00:59:50,319
you can go ahead and call it so
1417
00:59:51,180 --> 00:59:52,180
basically this is going to execute my
1418
00:59:53,460 --> 00:59:54,460
function
1419
00:59:54,900 --> 00:59:55,900
so let's go ahead and actually do
1420
00:59:58,260 --> 00:59:59,260
something with it now inside my function
1421
01:00:00,119 --> 01:00:01,119
this is blank right now I can just go
1422
01:00:02,700 --> 01:00:03,700
ahead and print a string
1423
01:00:04,980 --> 01:00:05,980
and we can call this one my function is
1424
01:00:08,339 --> 01:00:09,339
executed
1425
01:00:10,680 --> 01:00:11,680
so I think I butchered the spelling but
1426
01:00:13,020 --> 01:00:14,020
doesn't matter
1427
01:00:14,460 --> 01:00:15,460
so if I go ahead and press play you see
1428
01:00:16,859 --> 01:00:17,859
my function is executed
1429
01:00:19,260 --> 01:00:20,260
now we can also pass in values so I have
1430
01:00:23,160 --> 01:00:24,160
created this points variable here so
1431
01:00:25,619 --> 01:00:26,619
just create a new variable and make it
1432
01:00:27,359 --> 01:00:28,359
of type integer and call it points
1433
01:00:29,760 --> 01:00:30,760
now if you head into your function and
1434
01:00:32,099 --> 01:00:33,099
click on this block right here
1435
01:00:34,440 --> 01:00:35,440
you can actually add input and output
1436
01:00:37,020 --> 01:00:38,020
parameters so if I click on the plus
1437
01:00:38,760 --> 01:00:39,760
icon
1438
01:00:39,839 --> 01:00:40,839
and change the type to integer and I can
1439
01:00:43,020 --> 01:00:44,020
call this one points
1440
01:00:45,540 --> 01:00:46,540
so I can take this points value from
1441
01:00:48,960 --> 01:00:49,960
outside the function so if you look at
1442
01:00:50,819 --> 01:00:51,819
this now
1443
01:00:51,780 --> 01:00:52,780
you see I can pass in points
1444
01:00:55,980 --> 01:00:56,980
so that's pretty handy now I can go
1445
01:00:59,040 --> 01:01:00,040
ahead and print this out as well
1446
01:01:01,559 --> 01:01:02,559
so I can print out my function is
1447
01:01:03,540 --> 01:01:04,540
executed and I can print out points as
1448
01:01:06,359 --> 01:01:07,359
well
1449
01:01:07,079 --> 01:01:08,079
and if you double click on the wire you
1450
01:01:08,760 --> 01:01:09,760
can use the reroute node to keep things
1451
01:01:10,619 --> 01:01:11,619
a bit clean
1452
01:01:13,079 --> 01:01:14,079
now if I press play
1453
01:01:14,880 --> 01:01:15,880
you see you get my function is executed
1454
01:01:17,280 --> 01:01:18,280
and you get 0. now if I change the value
1455
01:01:19,680 --> 01:01:20,680
of points for example
1456
01:01:21,900 --> 01:01:22,900
you see we get that number
1457
01:01:23,940 --> 01:01:24,940
so this is basically how input
1458
01:01:25,980 --> 01:01:26,980
parameters work
1459
01:01:28,020 --> 01:01:29,020
now what if you had some return value
1460
01:01:30,900 --> 01:01:31,900
now let's say instead of points this was
1461
01:01:33,420 --> 01:01:34,420
health so let me just call this one
1462
01:01:35,099 --> 01:01:36,099
Health
1463
01:01:36,059 --> 01:01:37,059
so compile that and over here if I click
1464
01:01:39,180 --> 01:01:40,180
on this once again I can add in an
1465
01:01:41,700 --> 01:01:42,700
output and you see it creates a return
1466
01:01:44,220 --> 01:01:45,220
node for us
1467
01:01:45,540 --> 01:01:46,540
so this is basically like your return
1468
01:01:48,180 --> 01:01:49,180
keyword in C plus plus so when your
1469
01:01:51,119 --> 01:01:52,119
function goes to this it's going to exit
1470
01:01:53,880 --> 01:01:54,880
the function and the value whatever you
1471
01:01:56,520 --> 01:01:57,520
want is going to be returned now you
1472
01:01:58,559 --> 01:01:59,559
need not have it you can have an empty
1473
01:02:00,720 --> 01:02:01,720
return node as well
1474
01:02:02,400 --> 01:02:03,400
now in our case let's just return a
1475
01:02:04,859 --> 01:02:05,859
Boolean and let's just call it
1476
01:02:07,020 --> 01:02:08,020
be killed for example and let's change
1477
01:02:09,599 --> 01:02:10,599
the name of this to be
1478
01:02:11,400 --> 01:02:12,400
Health as well
1479
01:02:14,339 --> 01:02:15,339
and we could do a simple if check we
1480
01:02:16,980 --> 01:02:17,980
will talk about if as soon as we finish
1481
01:02:19,079 --> 01:02:20,079
functions events and stuff like that
1482
01:02:21,960 --> 01:02:22,960
so if
1483
01:02:23,339 --> 01:02:24,339
I can't do that so let me just grab in
1484
01:02:26,160 --> 01:02:27,160
an if
1485
01:02:27,480 --> 01:02:28,480
if this value
1486
01:02:29,280 --> 01:02:30,280
that is our health
1487
01:02:31,099 --> 01:02:32,099
is less than zero
1488
01:02:34,260 --> 01:02:35,260
or less than or equal to 0
1489
01:02:37,619 --> 01:02:38,619
then
1490
01:02:38,880 --> 01:02:39,880
what we can do
1491
01:02:40,680 --> 01:02:41,680
is if it is true and if you type in Ctrl
1492
01:02:43,740 --> 01:02:44,740
D you can have two return nodes
1493
01:02:46,200 --> 01:02:47,200
so if our health is less than zero
1494
01:02:48,960 --> 01:02:49,960
it's going to be true otherwise it's
1495
01:02:51,540 --> 01:02:52,540
going to be a false now you can go ahead
1496
01:02:54,000 --> 01:02:55,000
and print this out over here
1497
01:02:58,859 --> 01:02:59,859
now our health is 32
1498
01:03:01,020 --> 01:03:02,020
so we should have false
1499
01:03:02,819 --> 01:03:03,819
let's say we set our health to be -1
1500
01:03:06,359 --> 01:03:07,359
which is invalid of course but we get
1501
01:03:09,000 --> 01:03:10,000
true
1502
01:03:09,960 --> 01:03:10,960
so this is how you can return values
1503
01:03:11,940 --> 01:03:12,940
outside a function
1504
01:03:13,859 --> 01:03:14,859
now one aspect of functions which I did
1505
01:03:16,440 --> 01:03:17,440
not cover and I'm recording this a bit
1506
01:03:19,079 --> 01:03:20,079
later
1507
01:03:20,160 --> 01:03:21,160
it is going to be local variables so
1508
01:03:23,520 --> 01:03:24,520
what if you had some variable which you
1509
01:03:26,099 --> 01:03:27,099
wanted only within a function
1510
01:03:28,640 --> 01:03:29,640
so let's say for example we have a
1511
01:03:31,920 --> 01:03:32,920
variable temp for example so let's say
1512
01:03:34,200 --> 01:03:35,200
you wanted a number to be stored
1513
01:03:36,359 --> 01:03:37,359
temporarily inside so for that case you
1514
01:03:39,540 --> 01:03:40,540
would use this local variable option
1515
01:03:41,220 --> 01:03:42,220
they work exactly the same as you would
1516
01:03:43,740 --> 01:03:44,740
as it works in C plus plus and one more
1517
01:03:47,099 --> 01:03:48,099
thing the input parameters whatever you
1518
01:03:49,559 --> 01:03:50,559
take are also local variables so you can
1519
01:03:51,720 --> 01:03:52,720
just grab an in and instead of dragging
1520
01:03:55,859 --> 01:03:56,859
this actually you can right click and
1521
01:03:57,420 --> 01:03:58,420
type in in
1522
01:03:58,559 --> 01:03:59,559
and if I just get it so I should find it
1523
01:04:01,559 --> 01:04:02,559
at the very end of somewhere
1524
01:04:04,200 --> 01:04:05,200
or rather let me just type it get in
1525
01:04:08,400 --> 01:04:09,400
so N is a really commonly used word so
1526
01:04:10,920 --> 01:04:11,920
that's the reason we are getting it so
1527
01:04:13,079 --> 01:04:14,079
many times here so let's actually change
1528
01:04:15,240 --> 01:04:16,240
it so let's just type in in one two
1529
01:04:17,640 --> 01:04:18,640
three let's say so n one two three so
1530
01:04:20,400 --> 01:04:21,400
you can get it actually
1531
01:04:22,200 --> 01:04:23,200
so you don't actually have to drag this
1532
01:04:25,440 --> 01:04:26,440
let's say you have a large blueprint
1533
01:04:27,660 --> 01:04:28,660
graph you don't have to drag it actually
1534
01:04:29,220 --> 01:04:30,220
you could you could just do this over
1535
01:04:30,720 --> 01:04:31,720
here that works totally fine as well
1536
01:04:33,720 --> 01:04:34,720
even over here actually you could do
1537
01:04:35,940 --> 01:04:36,940
this and it's totally valid
1538
01:04:38,819 --> 01:04:39,819
so that's about it for local variables
1539
01:04:41,220 --> 01:04:42,220
as you use them you will kind of
1540
01:04:43,200 --> 01:04:44,200
understand their purpose but without a
1541
01:04:45,780 --> 01:04:46,780
solid example we will not actually be
1542
01:04:48,180 --> 01:04:49,180
able to tell the use case however once
1543
01:04:51,420 --> 01:04:52,420
we actually get to the end where we
1544
01:04:52,799 --> 01:04:53,799
actually create something that is when
1545
01:04:54,780 --> 01:04:55,780
we'll get to practical examples
1546
01:04:58,640 --> 01:04:59,640
[Music]
1547
01:05:02,660 --> 01:05:03,660
at the base level those are what
1548
01:05:05,460 --> 01:05:06,460
functions are and we will go a lot more
1549
01:05:08,160 --> 01:05:09,160
in depth about functions events and
1550
01:05:10,319 --> 01:05:11,319
stuff so not to worry about that I'll
1551
01:05:12,299 --> 01:05:13,299
just go ahead and deleted that let's
1552
01:05:13,859 --> 01:05:14,859
create a new one once again and now
1553
01:05:16,559 --> 01:05:17,559
let's talk about the limitations and
1554
01:05:18,420 --> 01:05:19,420
let's talk about the next type of
1555
01:05:20,339 --> 01:05:21,339
scripting feature in Blueprint now one
1556
01:05:23,520 --> 01:05:24,520
limitation that you would see is you
1557
01:05:25,079 --> 01:05:26,079
cannot add a delay so if I right click
1558
01:05:26,880 --> 01:05:27,880
and type in delay you actually don't get
1559
01:05:29,460 --> 01:05:30,460
a delay note the reason is
1560
01:05:32,040 --> 01:05:33,040
you cannot have latent nodes inside a
1561
01:05:34,680 --> 01:05:35,680
function in Blueprint
1562
01:05:36,720 --> 01:05:37,720
so delay is actually a latent function
1563
01:05:39,960 --> 01:05:40,960
so what I mean by that is it actually
1564
01:05:41,819 --> 01:05:42,819
takes some time to execute so let's say
1565
01:05:43,980 --> 01:05:44,980
I cut or copy this and paste it in here
1566
01:05:48,780 --> 01:05:49,780
you see I cannot do that it says one or
1567
01:05:51,059 --> 01:05:52,059
more copied notes could not be pasted
1568
01:05:52,799 --> 01:05:53,799
into this graph
1569
01:05:54,059 --> 01:05:55,059
so the way you can handle this is you
1570
01:05:57,119 --> 01:05:58,119
can use a macro now macros and
1571
01:05:59,760 --> 01:06:00,760
blueprints are more like functions than
1572
01:06:02,640 --> 01:06:03,640
C plus plus macros so they work a little
1573
01:06:05,700 --> 01:06:06,700
bit different
1574
01:06:07,020 --> 01:06:08,020
now if I call this one my macro for
1575
01:06:09,359 --> 01:06:10,359
example
1576
01:06:10,500 --> 01:06:11,500
I can go ahead and add a delay so I I
1577
01:06:13,619 --> 01:06:14,619
can hold down D on my keyboard and left
1578
01:06:15,359 --> 01:06:16,359
click and I can add in a delay one thing
1579
01:06:17,940 --> 01:06:18,940
you'll notice is by default it doesn't
1580
01:06:19,680 --> 01:06:20,680
have any input or output pins you can go
1581
01:06:21,720 --> 01:06:22,720
ahead and add that
1582
01:06:23,220 --> 01:06:24,220
but there is another advantage of macros
1583
01:06:26,520 --> 01:06:27,520
now for example let's say we we have a
1584
01:06:31,020 --> 01:06:32,020
database
1585
01:06:32,160 --> 01:06:33,160
on our server and let's say it takes
1586
01:06:35,280 --> 01:06:36,280
some time to retrieve the data so let's
1587
01:06:37,799 --> 01:06:38,799
say it takes around 0.5 seconds for your
1588
01:06:40,799 --> 01:06:41,799
computer to connect to the database and
1589
01:06:42,900 --> 01:06:43,900
retrieve the data this is just an
1590
01:06:44,940 --> 01:06:45,940
example it could be anything that takes
1591
01:06:47,099 --> 01:06:48,099
time for example uh the prime number
1592
01:06:49,859 --> 01:06:50,859
program takes some time to execute after
1593
01:06:52,559 --> 01:06:53,559
you go to a larger number
1594
01:06:54,660 --> 01:06:55,660
so while this is being executed
1595
01:06:58,380 --> 01:06:59,380
now let's say you just wanted to print
1596
01:07:00,480 --> 01:07:01,480
out something saying that it's starting
1597
01:07:03,480 --> 01:07:04,480
and then you want to do something else
1598
01:07:06,059 --> 01:07:07,059
when it's completed this is where it can
1599
01:07:08,160 --> 01:07:09,160
come handy
1600
01:07:09,900 --> 01:07:10,900
now you can type in print string
1601
01:07:13,020 --> 01:07:14,020
and you can call this one
1602
01:07:15,780 --> 01:07:16,780
starting now
1603
01:07:19,260 --> 01:07:20,260
you could come in here and now you would
1604
01:07:21,480 --> 01:07:22,480
notice this execution pin got
1605
01:07:23,039 --> 01:07:24,039
disconnected you can't do them parallely
1606
01:07:24,780 --> 01:07:25,780
but there's a workaround for that you
1607
01:07:26,819 --> 01:07:27,819
can type in sorry sequence
1608
01:07:30,119 --> 01:07:31,119
and over here you can just print this
1609
01:07:32,640 --> 01:07:33,640
out and then you can go ahead and
1610
01:07:35,099 --> 01:07:36,099
perform this
1611
01:07:36,539 --> 01:07:37,539
and over here in the output as well you
1612
01:07:39,299 --> 01:07:40,299
can drag this in and a handy thing which
1613
01:07:42,599 --> 01:07:43,599
you cannot do in your return node in
1614
01:07:44,339 --> 01:07:45,339
your function is you can have one more
1615
01:07:46,020 --> 01:07:47,020
of these
1616
01:07:47,339 --> 01:07:48,339
so now if I just give a longer delay so
1617
01:07:50,400 --> 01:07:51,400
that we can recognize it
1618
01:07:52,140 --> 01:07:53,140
and if I drag in my macro
1619
01:07:56,160 --> 01:07:57,160
and if I print out strings over here
1620
01:08:00,240 --> 01:08:01,240
and over here
1621
01:08:02,339 --> 01:08:03,339
so we'll call this one done and here
1622
01:08:04,500 --> 01:08:05,500
let's just print
1623
01:08:06,500 --> 01:08:07,500
starting underscore outside for example
1624
01:08:11,819 --> 01:08:12,819
so if I press play starting now and
1625
01:08:14,160 --> 01:08:15,160
starting outside got executed first then
1626
01:08:16,440 --> 01:08:17,440
after two seconds are done was executed
1627
01:08:19,500 --> 01:08:20,500
so things like that can be done by
1628
01:08:21,779 --> 01:08:22,779
macros which you cannot do in functions
1629
01:08:25,420 --> 01:08:26,420
[Music]
1630
01:08:30,480 --> 01:08:31,480
now the whole point of using our own
1631
01:08:33,480 --> 01:08:34,480
macros and functions is of course code
1632
01:08:35,819 --> 01:08:36,819
reusability so let's say I want to call
1633
01:08:38,640 --> 01:08:39,640
this macro once again I can just type in
1634
01:08:40,920 --> 01:08:41,920
my macro
1635
01:08:42,480 --> 01:08:43,480
and I can call it now one difference I
1636
01:08:46,140 --> 01:08:47,140
would like to mention and then we'll
1637
01:08:47,880 --> 01:08:48,880
head into the next one which is collapse
1638
01:08:49,799 --> 01:08:50,799
graphs is with a function let's say I
1639
01:08:53,339 --> 01:08:54,339
call this my function
1640
01:08:56,819 --> 01:08:57,819
my function
1641
01:08:58,259 --> 01:08:59,259
I can actually execute this from another
1642
01:09:01,080 --> 01:09:02,080
blueprint but this is not true for level
1643
01:09:04,080 --> 01:09:05,080
blueprints it's a little more tricky to
1644
01:09:06,299 --> 01:09:07,299
do it from level level blueprints you
1645
01:09:08,279 --> 01:09:09,279
you guys will understand why once we
1646
01:09:10,199 --> 01:09:11,199
actually head into classes and stuff
1647
01:09:12,779 --> 01:09:13,779
but I'll just show you guys a simple
1648
01:09:15,540 --> 01:09:16,540
example so I'll just create a blueprint
1649
01:09:18,060 --> 01:09:19,060
here of type actor and we'll talk in
1650
01:09:20,460 --> 01:09:21,460
depth about this later and let's say I
1651
01:09:23,100 --> 01:09:24,100
create a function as you can see the
1652
01:09:24,960 --> 01:09:25,960
same uh
1653
01:09:26,640 --> 01:09:27,640
features in the blueprint are available
1654
01:09:28,560 --> 01:09:29,560
here and let's just call it warrant test
1655
01:09:31,380 --> 01:09:32,380
for example
1656
01:09:33,120 --> 01:09:34,120
compile that now if I were to get an
1657
01:09:37,259 --> 01:09:38,259
object reference to new blueprint so
1658
01:09:39,660 --> 01:09:40,660
I'll just do that by dragging it into
1659
01:09:41,520 --> 01:09:42,520
the level
1660
01:09:42,839 --> 01:09:43,839
so I'll drag this
1661
01:09:44,640 --> 01:09:45,640
and I'll create a reference
1662
01:09:46,799 --> 01:09:47,799
and if you can notice I can actually
1663
01:09:49,620 --> 01:09:50,620
call test from here however if I create
1664
01:09:52,739 --> 01:09:53,739
a macro
1665
01:09:54,600 --> 01:09:55,600
so let's just call this one test M for
1666
01:09:57,600 --> 01:09:58,600
test macro
1667
01:09:59,040 --> 01:10:00,040
you would see even once I save and
1668
01:10:01,980 --> 01:10:02,980
compile everything
1669
01:10:03,660 --> 01:10:04,660
I cannot call test m i see test but I
1670
01:10:07,260 --> 01:10:08,260
don't see test M so that's one more
1671
01:10:09,480 --> 01:10:10,480
difference between a macro and a
1672
01:10:10,920 --> 01:10:11,920
function you cannot call a macro from
1673
01:10:13,380 --> 01:10:14,380
you know uh other blueprints but you can
1674
01:10:16,620 --> 01:10:17,620
call functions from other blueprints of
1675
01:10:19,199 --> 01:10:20,199
course if you set the axis specifier to
1676
01:10:21,300 --> 01:10:22,300
be private in that then you can't call
1677
01:10:24,060 --> 01:10:25,060
functions either but you can by default
1678
01:10:27,719 --> 01:10:28,719
now what if you didn't want to reuse
1679
01:10:30,780 --> 01:10:31,780
them what if you just had this code but
1680
01:10:34,920 --> 01:10:35,920
this looks a bit messy so you wanted
1681
01:10:37,380 --> 01:10:38,380
them to be shown as one node let's say
1682
01:10:39,960 --> 01:10:40,960
this whole thing did something one you
1683
01:10:42,360 --> 01:10:43,360
could just press C on your keyboard and
1684
01:10:44,219 --> 01:10:45,219
comment it
1685
01:10:45,300 --> 01:10:46,300
however there's another feature in
1686
01:10:47,159 --> 01:10:48,159
unreal called collapsed graphs now you
1687
01:10:50,520 --> 01:10:51,520
can right click and click on collapse
1688
01:10:52,620 --> 01:10:53,620
nodes and it's going to create a
1689
01:10:54,360 --> 01:10:55,360
collapsed graph now you can have inputs
1690
01:10:57,300 --> 01:10:58,300
and outputs here as well but in my
1691
01:11:00,780 --> 01:11:01,780
experience I have never really bothered
1692
01:11:03,239 --> 01:11:04,239
using them
1693
01:11:04,500 --> 01:11:05,500
and let's just call this one my collapse
1694
01:11:08,400 --> 01:11:09,400
graph
1695
01:11:11,280 --> 01:11:12,280
and if I go ahead and type in my
1696
01:11:14,040 --> 01:11:15,040
collapse graph by right clicking
1697
01:11:16,199 --> 01:11:17,199
so let's say I type in my collapse graph
1698
01:11:18,600 --> 01:11:19,600
you see I cannot call it because this is
1699
01:11:21,000 --> 01:11:22,000
not a function this is just all of this
1700
01:11:23,940 --> 01:11:24,940
code
1701
01:11:26,400 --> 01:11:27,400
just stuffed into this collapsed graph
1702
01:11:30,179 --> 01:11:31,179
so I lost my event graph here you can
1703
01:11:32,699 --> 01:11:33,699
head back in or you can click on this
1704
01:11:34,440 --> 01:11:35,440
away
1705
01:11:35,580 --> 01:11:36,580
so that's basically a collapsed craft
1706
01:11:37,800 --> 01:11:38,800
that's about it and when we actually use
1707
01:11:40,380 --> 01:11:41,380
them you will get an idea you can
1708
01:11:41,880 --> 01:11:42,880
actually have further execution so let's
1709
01:11:44,580 --> 01:11:45,580
say I have this
1710
01:11:47,460 --> 01:11:48,460
so it's going to come out of here as
1711
01:11:49,620 --> 01:11:50,620
well
1712
01:11:51,060 --> 01:11:52,060
so stuff like that so I'll go ahead and
1713
01:11:53,400 --> 01:11:54,400
delete that it's not of much relevance
1714
01:11:56,420 --> 01:11:57,420
[Music]
1715
01:12:00,659 --> 01:12:01,659
now that we have studied about functions
1716
01:12:03,300 --> 01:12:04,300
macros and collapse graphs let's
1717
01:12:05,820 --> 01:12:06,820
actually look at implementing the
1718
01:12:07,679 --> 01:12:08,679
various programming constructs inside
1719
01:12:09,840 --> 01:12:10,840
blueprint so we'll use the level
1720
01:12:11,940 --> 01:12:12,940
blueprint again and after this we will
1721
01:12:14,580 --> 01:12:15,580
get to actually working with blueprint
1722
01:12:16,560 --> 01:12:17,560
classes now the first thing that you
1723
01:12:19,620 --> 01:12:20,620
would want to do is do an if check and
1724
01:12:21,840 --> 01:12:22,840
we already did that several times so if
1725
01:12:23,760 --> 01:12:24,760
you right click and type in Branch or
1726
01:12:26,040 --> 01:12:27,040
you could just type in if
1727
01:12:28,020 --> 01:12:29,020
or you could hold down B on your
1728
01:12:30,239 --> 01:12:31,239
keyboard and left click that's another
1729
01:12:31,800 --> 01:12:32,800
shortcut which I like to use you would
1730
01:12:34,199 --> 01:12:35,199
bring up a branch node so a branch node
1731
01:12:37,679 --> 01:12:38,679
takes in a Boolean and depending on its
1732
01:12:40,980 --> 01:12:41,980
value it's either going to go true or
1733
01:12:43,320 --> 01:12:44,320
false this is an execution pin again so
1734
01:12:45,659 --> 01:12:46,659
depending on the value of this variable
1735
01:12:47,580 --> 01:12:48,580
you can go ahead and execute some logic
1736
01:12:49,920 --> 01:12:50,920
so instead of Health let's say I have B
1737
01:12:53,580 --> 01:12:54,580
Alive as a variable so if the player is
1738
01:12:55,920 --> 01:12:56,920
alive for example
1739
01:12:57,960 --> 01:12:58,960
so put that in so if the player is alive
1740
01:13:01,760 --> 01:13:02,760
then we are going to go ahead and run
1741
01:13:06,600 --> 01:13:07,600
this logic otherwise we are going to run
1742
01:13:09,120 --> 01:13:10,120
this
1743
01:13:10,199 --> 01:13:11,199
now there's another thing which you can
1744
01:13:12,239 --> 01:13:13,239
do with booleans which I probably
1745
01:13:14,460 --> 01:13:15,460
mentioned for enums but you can actually
1746
01:13:16,920 --> 01:13:17,920
do a select as well so if I go ahead and
1747
01:13:19,739 --> 01:13:20,739
select
1748
01:13:22,020 --> 01:13:23,020
you can go ahead and do this so again
1749
01:13:24,560 --> 01:13:25,560
you can actually get this return value
1750
01:13:28,320 --> 01:13:29,320
to take it to change depending on the
1751
01:13:30,360 --> 01:13:31,360
value of this variable
1752
01:13:32,159 --> 01:13:33,159
so this comes in pretty handy
1753
01:13:35,219 --> 01:13:36,219
now this is the most basic type and
1754
01:13:37,080 --> 01:13:38,080
there's nothing much to explain really
1755
01:13:38,640 --> 01:13:39,640
so you could go ahead and print
1756
01:13:40,199 --> 01:13:41,199
something and maybe do something else
1757
01:13:42,140 --> 01:13:43,140
and if he's not alive maybe you can go
1758
01:13:45,480 --> 01:13:46,480
ahead and you can quit the game or
1759
01:13:47,880 --> 01:13:48,880
anything like that
1760
01:13:49,320 --> 01:13:50,320
so that's basically it
1761
01:13:51,600 --> 01:13:52,600
[Music]
1762
01:13:55,920 --> 01:13:56,920
now the next construct that you'll use
1763
01:13:58,500 --> 01:13:59,500
is switch now switch is something which
1764
01:14:01,199 --> 01:14:02,199
we already talked about but we are going
1765
01:14:03,719 --> 01:14:04,719
to go a bit more in depth now now I'll
1766
01:14:06,900 --> 01:14:07,900
change this variable to an integer again
1767
01:14:08,640 --> 01:14:09,640
or rather I'll just undo everything so
1768
01:14:10,920 --> 01:14:11,920
that we have our integer back okay I've
1769
01:14:13,620 --> 01:14:14,620
saved it in between so we can't
1770
01:14:15,840 --> 01:14:16,840
so I'll just change the variable type
1771
01:14:18,840 --> 01:14:19,840
and for this we are going to rename this
1772
01:14:22,199 --> 01:14:23,199
to let's say health again
1773
01:14:26,640 --> 01:14:27,640
now I have health
1774
01:14:28,440 --> 01:14:29,440
so oops let's just compile that again
1775
01:14:32,100 --> 01:14:33,100
control drag it now if I drag off of
1776
01:14:35,100 --> 01:14:36,100
this and type in switch
1777
01:14:37,140 --> 01:14:38,140
you would see that I get the switch on
1778
01:14:39,960 --> 01:14:40,960
end node now basically what this means
1779
01:14:43,140 --> 01:14:44,140
is if I just click on ADD pin
1780
01:14:46,320 --> 01:14:47,320
and you can also set the start index so
1781
01:14:48,420 --> 01:14:49,420
let's say you want it to be negative 1
1782
01:14:49,920 --> 01:14:50,920
to start with you could do that as well
1783
01:14:52,260 --> 01:14:53,260
negative 2 for example
1784
01:14:54,000 --> 01:14:55,000
so what you are basically saying is if
1785
01:14:56,219 --> 01:14:57,219
the value of health is 1
1786
01:14:58,500 --> 01:14:59,500
head into this execution pin
1787
01:15:01,260 --> 01:15:02,260
otherwise default is basically like an
1788
01:15:04,320 --> 01:15:05,320
else
1789
01:15:05,159 --> 01:15:06,159
so if none of these corresponds so let's
1790
01:15:08,940 --> 01:15:09,940
say we have one two and three if the
1791
01:15:11,159 --> 01:15:12,159
health is neither one nor two not three
1792
01:15:13,860 --> 01:15:14,860
it's going to head into default
1793
01:15:16,080 --> 01:15:17,080
so for example if I just go ahead and
1794
01:15:18,719 --> 01:15:19,719
print now since our health is 0 and we
1795
01:15:21,060 --> 01:15:22,060
are starting at 1 we should get hello
1796
01:15:23,460 --> 01:15:24,460
printed in theory
1797
01:15:25,500 --> 01:15:26,500
so we get hello
1798
01:15:27,420 --> 01:15:28,420
if I go ahead and drag off of one you're
1799
01:15:32,100 --> 01:15:33,100
not going to get anything
1800
01:15:33,840 --> 01:15:34,840
now the same thing if I just change the
1801
01:15:35,940 --> 01:15:36,940
value to 1
1802
01:15:37,500 --> 01:15:38,500
I change the health variable value to 1.
1803
01:15:39,719 --> 01:15:40,719
now you should get hello
1804
01:15:43,080 --> 01:15:44,080
so this is how switch Works generally I
1805
01:15:45,719 --> 01:15:46,719
would be using this with enumeration so
1806
01:15:47,520 --> 01:15:48,520
for example we have my inner mother
1807
01:15:50,280 --> 01:15:51,280
so let's just delete everything in the
1808
01:15:52,620 --> 01:15:53,620
graph now my enum
1809
01:15:55,920 --> 01:15:56,920
my enum now if I
1810
01:15:58,739 --> 01:15:59,739
grab this into the graph and if I then
1811
01:16:01,500 --> 01:16:02,500
type in switch you see
1812
01:16:04,500 --> 01:16:05,500
you get the options so if health
1813
01:16:08,520 --> 01:16:09,520
okay we can rename that to something a
1814
01:16:10,739 --> 01:16:11,739
little more descriptive so let's just
1815
01:16:12,900 --> 01:16:13,900
type in some enum
1816
01:16:16,800 --> 01:16:17,800
so if our enum if some enum is Apple
1817
01:16:20,880 --> 01:16:21,880
this is going to be executed if some
1818
01:16:24,060 --> 01:16:25,060
enum is banana this is going to be
1819
01:16:26,460 --> 01:16:27,460
executed if some enum is mango this is
1820
01:16:29,580 --> 01:16:30,580
going to be executed so this is
1821
01:16:31,380 --> 01:16:32,380
basically how switch works so that's
1822
01:16:33,840 --> 01:16:34,840
about it actually now
1823
01:16:36,320 --> 01:16:37,320
this was for your selection and to
1824
01:16:41,100 --> 01:16:42,100
evaluate condition
1825
01:16:42,830 --> 01:16:43,830
[Music]
1826
01:16:47,400 --> 01:16:48,400
now coming to the iterative constructs
1827
01:16:49,800 --> 01:16:50,800
let's say you wanted to print numbers
1828
01:16:51,480 --> 01:16:52,480
from 1 to 10 you can use a loop now if
1829
01:16:55,140 --> 01:16:56,140
you guys are familiar with CC plus plus
1830
01:16:56,940 --> 01:16:57,940
these will seem much much easier to deal
1831
01:16:59,400 --> 01:17:00,400
with there are basically two types of
1832
01:17:01,560 --> 01:17:02,560
Loop and there is a version of while
1833
01:17:04,260 --> 01:17:05,260
loop called do while loop so the types
1834
01:17:06,300 --> 01:17:07,300
are while and far
1835
01:17:07,920 --> 01:17:08,920
and there is one more type which you use
1836
01:17:10,500 --> 01:17:11,500
a lot which is for each and we will get
1837
01:17:13,320 --> 01:17:14,320
to that once we start talking out arrays
1838
01:17:15,840 --> 01:17:16,840
now if I right click and type in while
1839
01:17:20,040 --> 01:17:21,040
you see you get while loop
1840
01:17:22,260 --> 01:17:23,260
so what this basically means is as long
1841
01:17:25,080 --> 01:17:26,080
as this Boolean is true
1842
01:17:27,480 --> 01:17:28,480
so I can change this to Boolean once
1843
01:17:29,820 --> 01:17:30,820
again
1844
01:17:30,900 --> 01:17:31,900
as long as this is true
1845
01:17:33,179 --> 01:17:34,179
this value is going this Loop body is
1846
01:17:36,420 --> 01:17:37,420
going to be executed so for example
1847
01:17:39,719 --> 01:17:40,719
uh let's say uh let's actually make this
1848
01:17:43,320 --> 01:17:44,320
a number again let's change this let's
1849
01:17:45,960 --> 01:17:46,960
say I wanted to print numbers from 0 to
1850
01:17:48,719 --> 01:17:49,719
10. so I'd set the sum enum or we'll
1851
01:17:52,260 --> 01:17:53,260
call this one num we can set num to be
1852
01:17:54,659 --> 01:17:55,659
equal to 0 by default
1853
01:17:56,820 --> 01:17:57,820
and now we can do an if check as long as
1854
01:18:00,000 --> 01:18:01,000
number is less than or equal to 0
1855
01:18:03,960 --> 01:18:04,960
or rather 10
1856
01:18:05,520 --> 01:18:06,520
we can go ahead and print our number so
1857
01:18:09,239 --> 01:18:10,239
we can go ahead and type in print string
1858
01:18:11,940 --> 01:18:12,940
and we can just Ctrl D print it out
1859
01:18:17,100 --> 01:18:18,100
now obviously the this is an infinite
1860
01:18:19,679 --> 01:18:20,679
Loop you have to change the value of num
1861
01:18:21,960 --> 01:18:22,960
itself so what I can do is I can set
1862
01:18:27,060 --> 01:18:28,060
num
1863
01:18:28,560 --> 01:18:29,560
to be equal to num Plus 1.
1864
01:18:31,320 --> 01:18:32,320
so this is one way to do it
1865
01:18:33,659 --> 01:18:34,659
also if you were to notice if you just
1866
01:18:36,719 --> 01:18:37,719
drag off of the sentiment plus plus you
1867
01:18:39,120 --> 01:18:40,120
can actually do increment as well so
1868
01:18:41,400 --> 01:18:42,400
this is basically like your num plus
1869
01:18:43,199 --> 01:18:44,199
plus in C plus plus that's how we would
1870
01:18:45,900 --> 01:18:46,900
interpret that
1871
01:18:47,340 --> 01:18:48,340
now if I go ahead and press play you
1872
01:18:50,219 --> 01:18:51,219
should see we get numbers from 0 to 10
1873
01:18:52,440 --> 01:18:53,440
as expected so that's basically how you
1874
01:18:55,260 --> 01:18:56,260
use a while loop and once this Loop is
1875
01:18:57,659 --> 01:18:58,659
done again you can go ahead and print
1876
01:18:59,340 --> 01:19:00,340
something so let's say printed numbers
1877
01:19:03,360 --> 01:19:04,360
printed numbers
1878
01:19:06,840 --> 01:19:07,840
now you see it prints from 0 to 10
1879
01:19:09,540 --> 01:19:10,540
and it just goes to completed this is
1880
01:19:12,900 --> 01:19:13,900
how we would execute your logic one
1881
01:19:15,360 --> 01:19:16,360
thing to note though avoid using Loops
1882
01:19:18,239 --> 01:19:19,239
in your program especially in Blueprint
1883
01:19:20,300 --> 01:19:21,300
unless the array length is you know less
1884
01:19:23,340 --> 01:19:24,340
than about a few hundred it's fine but
1885
01:19:26,580 --> 01:19:27,580
let's say you're dealing with larger
1886
01:19:28,080 --> 01:19:29,080
data sets please refrain from using
1887
01:19:31,080 --> 01:19:32,080
Loops in Blueprint uh try to use as much
1888
01:19:34,560 --> 01:19:35,560
as you can in C plus plus
1889
01:19:37,199 --> 01:19:38,199
because blueprint if I haven't mentioned
1890
01:19:40,679 --> 01:19:41,679
yet is slower compared to C plus plus
1891
01:19:43,620 --> 01:19:44,620
when you call Print string for example
1892
01:19:46,260 --> 01:19:47,260
this is actually a function called in C
1893
01:19:49,380 --> 01:19:50,380
plus plus so the actual function of
1894
01:19:51,540 --> 01:19:52,540
print string is written in C plus plus
1895
01:19:54,719 --> 01:19:55,719
it actually takes a little bit of
1896
01:19:57,600 --> 01:19:58,600
processing to actually switch between
1897
01:20:00,080 --> 01:20:01,080
blueprint and C plus plus blueprint is
1898
01:20:03,120 --> 01:20:04,120
kind of like your jvm where it actually
1899
01:20:06,480 --> 01:20:07,480
runs on a virtual machine so blueprint
1900
01:20:08,699 --> 01:20:09,699
code is going to be comparatively slower
1901
01:20:10,920 --> 01:20:11,920
than C plus plus but in this case this
1902
01:20:13,020 --> 01:20:14,020
code is pretty simple so you don't
1903
01:20:14,760 --> 01:20:15,760
really need to do that we will get to
1904
01:20:17,280 --> 01:20:18,280
where to use blueprint and C plus plus
1905
01:20:18,960 --> 01:20:19,960
much much later there's nothing much to
1906
01:20:21,480 --> 01:20:22,480
worry about for simple games
1907
01:20:23,570 --> 01:20:24,570
[Music]
1908
01:20:28,380 --> 01:20:29,380
now the other type is going to be a for
1909
01:20:30,360 --> 01:20:31,360
Loop
1910
01:20:31,500 --> 01:20:32,500
so if I just type in for Loop you see
1911
01:20:34,140 --> 01:20:35,140
you get for Loop this is how you
1912
01:20:36,360 --> 01:20:37,360
basically execute your for Loop however
1913
01:20:38,760 --> 01:20:39,760
this is a little more or actually much
1914
01:20:41,040 --> 01:20:42,040
more easier than what you have to do in
1915
01:20:42,840 --> 01:20:43,840
C plus plus in C plus plus you give an
1916
01:20:45,360 --> 01:20:46,360
initialization expression an update
1917
01:20:47,340 --> 01:20:48,340
expression and a conditional expression
1918
01:20:50,040 --> 01:20:51,040
I am mixed up the order but anyways you
1919
01:20:52,679 --> 01:20:53,679
get the point and you got to actually
1920
01:20:55,860 --> 01:20:56,860
give the body of the loop like that but
1921
01:20:58,199 --> 01:20:59,199
here in Blueprint you just type in a
1922
01:21:00,120 --> 01:21:01,120
first and the last index which makes it
1923
01:21:01,920 --> 01:21:02,920
very very simple for you to execute a
1924
01:21:04,560 --> 01:21:05,560
for Loop and if you were to just drag
1925
01:21:07,920 --> 01:21:08,920
this in let's say I just type in 0 and
1926
01:21:10,260 --> 01:21:11,260
10. and I just go ahead and print this
1927
01:21:13,140 --> 01:21:14,140
we don't even need a variable at this
1928
01:21:15,120 --> 01:21:16,120
point
1929
01:21:16,140 --> 01:21:17,140
we can just grab this
1930
01:21:18,540 --> 01:21:19,540
and we can go ahead and run this and
1931
01:21:22,020 --> 01:21:23,020
it's going to print 0 to 10. so this is
1932
01:21:24,300 --> 01:21:25,300
how you use a for Loop now there is
1933
01:21:26,699 --> 01:21:27,699
another variation known as the for each
1934
01:21:29,280 --> 01:21:30,280
Loop which is used similar to range
1935
01:21:33,060 --> 01:21:34,060
based for Loop in C plus plus to iterate
1936
01:21:35,760 --> 01:21:36,760
arrays and stuff like that we will talk
1937
01:21:37,620 --> 01:21:38,620
about that now again the completed works
1938
01:21:40,199 --> 01:21:41,199
the same way once this Loop is completed
1939
01:21:42,600 --> 01:21:43,600
executing you can go ahead and print
1940
01:21:44,520 --> 01:21:45,520
something
1941
01:21:46,980 --> 01:21:47,980
or execute whatever logic you have so
1942
01:21:50,159 --> 01:21:51,159
this is your for Loop and there is
1943
01:21:52,500 --> 01:21:53,500
another variant of for Loop called the
1944
01:21:54,900 --> 01:21:55,900
for loop with brick
1945
01:21:56,520 --> 01:21:57,520
so if I just type in for loop with brick
1946
01:21:59,580 --> 01:22:00,580
you see you get this now let's say I
1947
01:22:01,980 --> 01:22:02,980
wanted to stop at a certain point
1948
01:22:05,040 --> 01:22:06,040
let's say
1949
01:22:06,900 --> 01:22:07,900
uh I mean in this case it's kind of
1950
01:22:09,480 --> 01:22:10,480
useless to do it but let's say I wanted
1951
01:22:12,600 --> 01:22:13,600
to stop in between let's say I have some
1952
01:22:15,060 --> 01:22:16,060
logic we can just grab in some random
1953
01:22:17,400 --> 01:22:18,400
logic uh let's say this number divided
1954
01:22:20,760 --> 01:22:21,760
by 15 you know uh we have to make this
1955
01:22:24,120 --> 01:22:25,120
float remember because integer division
1956
01:22:26,340 --> 01:22:27,340
works in a different way
1957
01:22:28,199 --> 01:22:29,199
so let's say this number divided by 15
1958
01:22:31,020 --> 01:22:32,020
if it is greater than 3.5 we want to
1959
01:22:34,620 --> 01:22:35,620
break let's say we have that logic
1960
01:22:37,920 --> 01:22:38,920
so we are going to print as long as this
1961
01:22:40,260 --> 01:22:41,260
number divided by 15 is greater than 3.5
1962
01:22:43,920 --> 01:22:44,920
so do that if this is true we are going
1963
01:22:46,980 --> 01:22:47,980
to break whoops
1964
01:22:49,739 --> 01:22:50,739
and if we go ahead and print this we can
1965
01:22:53,640 --> 01:22:54,640
just go ahead and print the number
1966
01:22:54,719 --> 01:22:55,719
instead
1967
01:22:56,340 --> 01:22:57,340
and once this is completed we can print
1968
01:22:58,679 --> 01:22:59,679
something else now obviously to tidy
1969
01:23:01,020 --> 01:23:02,020
this up you can use a reroute node and
1970
01:23:02,820 --> 01:23:03,820
you can do this
1971
01:23:04,980 --> 01:23:05,980
so this is one way to keep your
1972
01:23:06,540 --> 01:23:07,540
blueprint craft ID
1973
01:23:08,460 --> 01:23:09,460
so we can type in completed
1974
01:23:13,920 --> 01:23:14,920
so that's done
1975
01:23:15,540 --> 01:23:16,540
and we have a compiler error it says
1976
01:23:19,140 --> 01:23:20,140
so
1977
01:23:21,420 --> 01:23:22,420
okay we'll we'll take that in as a float
1978
01:23:24,239 --> 01:23:25,239
so convert this pin to a float
1979
01:23:28,020 --> 01:23:29,020
convert this pin to a float and then
1980
01:23:31,739 --> 01:23:32,739
let's just do that
1981
01:23:34,440 --> 01:23:35,440
and let's compile this again
1982
01:23:36,659 --> 01:23:37,659
save
1983
01:23:38,280 --> 01:23:39,280
and go ahead and press play
1984
01:23:40,620 --> 01:23:41,620
now we would see it's 52
1985
01:23:43,620 --> 01:23:44,620
so if we actually bring up our
1986
01:23:45,360 --> 01:23:46,360
calculator
1987
01:23:46,800 --> 01:23:47,800
so we get 51 by 15 is going to be 3.4
1988
01:23:51,659 --> 01:23:52,659
and 52 divided by 15 is going to be
1989
01:23:56,659 --> 01:23:57,659
3.466 so that should be the last number
1990
01:24:00,179 --> 01:24:01,179
so now if I do 53 divided by 15 you see
1991
01:24:04,260 --> 01:24:05,260
you get 3.53 which is greater than 3.5
1992
01:24:06,719 --> 01:24:07,719
so it did not print that
1993
01:24:09,060 --> 01:24:10,060
foreign
1994
01:24:17,480 --> 01:24:18,480
to head into R for each Loop now for
1995
01:24:22,020 --> 01:24:23,020
this we'll need to learn about another
1996
01:24:23,760 --> 01:24:24,760
data structure now this is a variable
1997
01:24:26,580 --> 01:24:27,580
right over here where you select the
1998
01:24:29,219 --> 01:24:30,219
variable type to the right of it you get
1999
01:24:31,679 --> 01:24:32,679
an option to change it to an array set
2000
01:24:33,780 --> 01:24:34,780
or a map now an array is basically
2001
01:24:37,440 --> 01:24:38,440
a collection of homogeneous elements so
2002
01:24:40,920 --> 01:24:41,920
basically in this case num is now no
2003
01:24:44,820 --> 01:24:45,820
longer a single number
2004
01:24:46,640 --> 01:24:47,640
instead it is a collection of numbers
2005
01:24:49,440 --> 01:24:50,440
and why I say homogeneous is because I
2006
01:24:51,719 --> 01:24:52,719
can only have integers in this list I
2007
01:24:54,120 --> 01:24:55,120
can't have 0 and I can't have a string
2008
01:24:56,340 --> 01:24:57,340
in the next index so basically each item
2009
01:24:59,159 --> 01:25:00,159
is going to be referenced by an index so
2010
01:25:01,199 --> 01:25:02,199
the first item which you put in is going
2011
01:25:03,060 --> 01:25:04,060
to be 0 and stuff like that you can put
2012
01:25:05,699 --> 01:25:06,699
in any number and if I have to iterate
2013
01:25:08,580 --> 01:25:09,580
through this I will use a for each Loop
2014
01:25:12,000 --> 01:25:13,000
now if I go ahead and print this out
2015
01:25:15,600 --> 01:25:16,600
you would be able to see that I print in
2016
01:25:18,600 --> 01:25:19,600
all the elements in that array so I
2017
01:25:21,420 --> 01:25:22,420
printed in 2 and 32.
2018
01:25:23,880 --> 01:25:24,880
which is what exactly what we have so
2019
01:25:26,880 --> 01:25:27,880
that's basically how it works now one
2020
01:25:30,420 --> 01:25:31,420
more thing you can have it of any type
2021
01:25:33,000 --> 01:25:34,000
in case you guys were confused I'll
2022
01:25:34,800 --> 01:25:35,800
create a new one for example uh let's
2023
01:25:37,080 --> 01:25:38,080
just call it one Str array
2024
01:25:40,679 --> 01:25:41,679
and let's make it of type string and
2025
01:25:43,140 --> 01:25:44,140
let's compile that and I can go ahead
2026
01:25:45,600 --> 01:25:46,600
and add a few elements I can I can just
2027
01:25:48,540 --> 01:25:49,540
type in any set of characters
2028
01:25:51,300 --> 01:25:52,300
and I could iterate through this as well
2029
01:25:53,699 --> 01:25:54,699
so I can just drag this in
2030
01:25:56,460 --> 01:25:57,460
compile that and go ahead and run this
2031
01:25:59,460 --> 01:26:00,460
program
2032
01:26:01,440 --> 01:26:02,440
now you see you can print that as well
2033
01:26:04,260 --> 01:26:05,260
so this basically stores multiple of the
2034
01:26:08,280 --> 01:26:09,280
data types elements and one more thing
2035
01:26:11,100 --> 01:26:12,100
since this is an array this is more of a
2036
01:26:13,679 --> 01:26:14,679
theory thing but
2037
01:26:15,380 --> 01:26:16,380
the elements here so this string so
2038
01:26:18,840 --> 01:26:19,840
let's just actually name it one two and
2039
01:26:20,699 --> 01:26:21,699
three for our reference
2040
01:26:22,320 --> 01:26:23,320
so 1 is 1 2 and 3 these are actually
2041
01:26:25,080 --> 01:26:26,080
stored in continuous memory locations so
2042
01:26:27,780 --> 01:26:28,780
iterating through them is actually a
2043
01:26:29,520 --> 01:26:30,520
relatively cheap option now
2044
01:26:31,320 --> 01:26:32,320
unfortunately Unreal Engine does not
2045
01:26:33,600 --> 01:26:34,600
provide us with a linked list structures
2046
01:26:35,580 --> 01:26:36,580
in Blueprint we have to implement that
2047
01:26:37,860 --> 01:26:38,860
ourselves if we needed to but most of
2048
01:26:41,040 --> 01:26:42,040
the times you'll be using arrays and
2049
01:26:42,840 --> 01:26:43,840
Maps you will not be using sets or
2050
01:26:45,120 --> 01:26:46,120
linked lists most of the time however it
2051
01:26:47,760 --> 01:26:48,760
is Handy to use linked lists in some
2052
01:26:49,800 --> 01:26:50,800
very rare occasions but we will not be
2053
01:26:52,260 --> 01:26:53,260
going over that anyways so let's just
2054
01:26:54,960 --> 01:26:55,960
delete all of this we are done with this
2055
01:26:57,780 --> 01:26:58,780
so that's basically our array and your
2056
01:27:00,000 --> 01:27:01,000
for each Loop now you can have an array
2057
01:27:01,620 --> 01:27:02,620
of structures as well it's totally fine
2058
01:27:03,960 --> 01:27:04,960
so I guess we called our my struct if
2059
01:27:06,300 --> 01:27:07,300
I'm not wrong
2060
01:27:07,260 --> 01:27:08,260
we could have an array of those that's
2061
01:27:09,719 --> 01:27:10,719
about it basically you could store any
2062
01:27:11,820 --> 01:27:12,820
type of element now I can go ahead and
2063
01:27:13,920 --> 01:27:14,920
click on the plus icon and I can add the
2064
01:27:17,100 --> 01:27:18,100
name and points and it works just as you
2065
01:27:20,400 --> 01:27:21,400
would expect so I can go ahead and
2066
01:27:22,139 --> 01:27:23,139
delete this we don't need that anymore
2067
01:27:24,550 --> 01:27:25,550
[Music]
2068
01:27:25,860 --> 01:27:26,860
foreign
2069
01:27:28,920 --> 01:27:29,920
now along with your regular if switch
2070
01:27:32,040 --> 01:27:33,040
and your Loops unreal in blueprints
2071
01:27:34,920 --> 01:27:35,920
provides us with a a couple of Handy
2072
01:27:37,440 --> 01:27:38,440
nodes which you might need one of them
2073
01:27:40,080 --> 01:27:41,080
is called flip flop
2074
01:27:42,540 --> 01:27:43,540
so what does it mean so flip flop is
2075
01:27:45,900 --> 01:27:46,900
basically basically this is how a flip
2076
01:27:47,699 --> 01:27:48,699
flop works if this execution pin goes in
2077
01:27:51,600 --> 01:27:52,600
once a is going to be executed otherwise
2078
01:27:55,980 --> 01:27:56,980
if you come here again B is going to be
2079
01:27:58,980 --> 01:27:59,980
executed so let me actually show you
2080
01:28:00,900 --> 01:28:01,900
what I mean
2081
01:28:02,460 --> 01:28:03,460
so if I just drag this in
2082
01:28:05,219 --> 01:28:06,219
and if I print and let's just say a is
2083
01:28:09,780 --> 01:28:10,780
executed
2084
01:28:12,540 --> 01:28:13,540
and now if I just go ahead and given a
2085
01:28:14,760 --> 01:28:15,760
delay of let's say a second
2086
01:28:18,719 --> 01:28:19,719
and if I copy this over and let's just
2087
01:28:21,540 --> 01:28:22,540
type in B is executed give a delay of a
2088
01:28:24,780 --> 01:28:25,780
second and again head back over there so
2089
01:28:27,659 --> 01:28:28,659
I'll just use a reroute to make things a
2090
01:28:29,400 --> 01:28:30,400
little more clear for you guys
2091
01:28:31,980 --> 01:28:32,980
now make sure you guys do comprehend
2092
01:28:33,840 --> 01:28:34,840
this logic correctly
2093
01:28:35,880 --> 01:28:36,880
if I go ahead and press play
2094
01:28:38,100 --> 01:28:39,100
you would see it says a is executed B is
2095
01:28:40,500 --> 01:28:41,500
executed and it's going to be
2096
01:28:42,120 --> 01:28:43,120
alternating like that so that's the use
2097
01:28:44,520 --> 01:28:45,520
of a flip flop you could use this uh for
2098
01:28:47,580 --> 01:28:48,580
key presses so let's say you wanted
2099
01:28:49,380 --> 01:28:50,380
something to happen when you press the
2100
01:28:51,960 --> 01:28:52,960
key once but you wanted something else
2101
01:28:54,239 --> 01:28:55,239
to happen when you press the key again
2102
01:28:55,860 --> 01:28:56,860
so for example let's say you have a
2103
01:28:58,739 --> 01:28:59,739
scoping in uh thing in your game so
2104
01:29:02,159 --> 01:29:03,159
let's say a scoping into your weapon
2105
01:29:03,719 --> 01:29:04,719
let's say the first time when you flip
2106
01:29:06,659 --> 01:29:07,659
flop to a you want the guy to scope in
2107
01:29:09,900 --> 01:29:10,900
and when you flip flop to B you want
2108
01:29:12,840 --> 01:29:13,840
your weapon to scope out so that's
2109
01:29:15,659 --> 01:29:16,659
basically one place where you can use
2110
01:29:17,040 --> 01:29:18,040
flip flop so it's pretty simple
2111
01:29:20,750 --> 01:29:21,750
[Music]
2112
01:29:24,840 --> 01:29:25,840
now one more thing which the engine
2113
01:29:26,760 --> 01:29:27,760
provides is do once
2114
01:29:29,340 --> 01:29:30,340
now do ones and there's also a gate node
2115
01:29:32,340 --> 01:29:33,340
which you might need but I honestly
2116
01:29:35,040 --> 01:29:36,040
never gotten an actual use case for this
2117
01:29:38,520 --> 01:29:39,520
so there's nothing much to really worry
2118
01:29:40,860 --> 01:29:41,860
about this but it's it can come in handy
2119
01:29:43,320 --> 01:29:44,320
depending on your game especially if
2120
01:29:45,060 --> 01:29:46,060
you're going for you know puzzle type
2121
01:29:46,679 --> 01:29:47,679
games maybe
2122
01:29:48,060 --> 01:29:49,060
not really sure so do ones basically as
2123
01:29:52,139 --> 01:29:53,139
the name suggests it just allows you to
2124
01:29:54,960 --> 01:29:55,960
execute this one time so let's say I
2125
01:29:57,420 --> 01:29:58,420
print the string
2126
01:29:59,040 --> 01:30:00,040
and I go back to this this is no longer
2127
01:30:01,980 --> 01:30:02,980
an infinite loop it's just going to
2128
01:30:03,420 --> 01:30:04,420
execute it once
2129
01:30:05,100 --> 01:30:06,100
look it just executed hello and that's
2130
01:30:07,800 --> 01:30:08,800
about it
2131
01:30:09,000 --> 01:30:10,000
now let's say I want to call this
2132
01:30:12,239 --> 01:30:13,239
function just once again so what I can
2133
01:30:14,940 --> 01:30:15,940
do is I can drag this into reset so if
2134
01:30:18,900 --> 01:30:19,900
anything goes into this reset the
2135
01:30:21,179 --> 01:30:22,179
function which goes after completed will
2136
01:30:23,820 --> 01:30:24,820
be allowed to execute once again so
2137
01:30:26,159 --> 01:30:27,159
that's basically how do once works I
2138
01:30:27,719 --> 01:30:28,719
don't think there's any explanation
2139
01:30:28,920 --> 01:30:29,920
required for it so if I do it on tick so
2140
01:30:30,900 --> 01:30:31,900
basically every frame it's going to
2141
01:30:32,400 --> 01:30:33,400
allow you to do it once again and if I
2142
01:30:35,460 --> 01:30:36,460
just go ahead and re-execute this I know
2143
01:30:38,340 --> 01:30:39,340
this is an infinite Loop but we do have
2144
01:30:41,100 --> 01:30:42,100
a little bit of a duration for us in the
2145
01:30:43,440 --> 01:30:44,440
tick
2146
01:30:44,280 --> 01:30:45,280
so that's how it will work
2147
01:30:47,400 --> 01:30:48,400
okay so it did stop the execution over
2148
01:30:49,920 --> 01:30:50,920
there that's a different thing but yeah
2149
01:30:52,199 --> 01:30:53,199
basically reset is going to let you do
2150
01:30:54,540 --> 01:30:55,540
that once again
2151
01:30:55,739 --> 01:30:56,739
so I can actually get a more practical
2152
01:30:58,020 --> 01:30:59,020
example so let's say we have a delay of
2153
01:31:00,600 --> 01:31:01,600
0.2 seconds and we do this I can
2154
01:31:03,239 --> 01:31:04,239
actually use a sequence so sequence
2155
01:31:05,400 --> 01:31:06,400
remember the node which we used before
2156
01:31:08,460 --> 01:31:09,460
so after 0.2 seconds I can go ahead and
2157
01:31:11,400 --> 01:31:12,400
reset that
2158
01:31:12,780 --> 01:31:13,780
and after let's say not 0.5 seconds I
2159
01:31:16,440 --> 01:31:17,440
can try executing that once again
2160
01:31:20,100 --> 01:31:21,100
so if I go ahead and press play you see
2161
01:31:22,800 --> 01:31:23,800
it works as expected
2162
01:31:25,500 --> 01:31:26,500
[Music]
2163
01:31:29,760 --> 01:31:30,760
whatever we spoke until now were just
2164
01:31:32,219 --> 01:31:33,219
the basics in order to get you started
2165
01:31:34,139 --> 01:31:35,139
with Unreal Engine but in order to
2166
01:31:36,540 --> 01:31:37,540
actually practically create a game we
2167
01:31:39,360 --> 01:31:40,360
need to First go into some background so
2168
01:31:41,400 --> 01:31:42,400
that we can learn how to use classes and
2169
01:31:43,380 --> 01:31:44,380
objects now if you guys aren't aware
2170
01:31:46,159 --> 01:31:47,159
Unreal Engine or any game engine in
2171
01:31:48,840 --> 01:31:49,840
general is going to be working on the
2172
01:31:51,840 --> 01:31:52,840
principle of object oriented programming
2173
01:31:54,179 --> 01:31:55,179
a bit of a background here so there are
2174
01:31:56,880 --> 01:31:57,880
two main programming methods that we'll
2175
01:31:58,620 --> 01:31:59,620
talk about now the first one is
2176
01:32:00,900 --> 01:32:01,900
procedural programming so this is the
2177
01:32:03,300 --> 01:32:04,300
approach used in languages such as C
2178
01:32:05,340 --> 01:32:06,340
where basically your approach is mainly
2179
01:32:07,920 --> 01:32:08,920
using functions so procedures that's
2180
01:32:11,580 --> 01:32:12,580
what basically procedural programming
2181
01:32:14,159 --> 01:32:15,159
stands for so you have a main function
2182
01:32:16,440 --> 01:32:17,440
and you have several other functions
2183
01:32:19,500 --> 01:32:20,500
now this is the most simplest form of
2184
01:32:22,139 --> 01:32:23,139
what it could be however you could have
2185
01:32:24,960 --> 01:32:25,960
a function over here as well so let's
2186
01:32:26,639 --> 01:32:27,639
say you have function 4 for example and
2187
01:32:29,219 --> 01:32:30,219
maybe function 4 can call function 2 or
2188
01:32:32,219 --> 01:32:33,219
vice versa doesn't really matter but
2189
01:32:35,520 --> 01:32:36,520
basically your whole program is divided
2190
01:32:38,520 --> 01:32:39,520
into multiple functions and there is
2191
01:32:40,560 --> 01:32:41,560
some global data on which it operates on
2192
01:32:42,600 --> 01:32:43,600
so you have some data over here and
2193
01:32:44,880 --> 01:32:45,880
maybe function three accesses some data
2194
01:32:47,219 --> 01:32:48,219
here stuff like that could happen in
2195
01:32:49,800 --> 01:32:50,800
procedural programming
2196
01:32:51,840 --> 01:32:52,840
however the approach which is used in
2197
01:32:54,659 --> 01:32:55,659
unreal in object-oriented programming
2198
01:32:57,480 --> 01:32:58,480
languages such as C plus plus is going
2199
01:33:00,480 --> 01:33:01,480
to be object oriented programming of
2200
01:33:02,400 --> 01:33:03,400
course as the name suggests
2201
01:33:04,980 --> 01:33:05,980
and here we use a principle known as
2202
01:33:08,280 --> 01:33:09,280
classes
2203
01:33:09,780 --> 01:33:10,780
and an instance of this class is known
2204
01:33:12,960 --> 01:33:13,960
as an object so let me be a little more
2205
01:33:15,780 --> 01:33:16,780
specific here so all the data and
2206
01:33:18,900 --> 01:33:19,900
functions so for example or in this case
2207
01:33:22,100 --> 01:33:23,100
this was a method this was the main
2208
01:33:24,420 --> 01:33:25,420
function so we have one method here
2209
01:33:26,460 --> 01:33:27,460
another one and we also have some data
2210
01:33:29,880 --> 01:33:30,880
over here
2211
01:33:30,840 --> 01:33:31,840
so all of this is going to be
2212
01:33:33,239 --> 01:33:34,239
encapsulated into a unit known as a
2213
01:33:35,580 --> 01:33:36,580
class and I will get to some examples
2214
01:33:38,040 --> 01:33:39,040
later
2215
01:33:38,820 --> 01:33:39,820
so once we have this encapsulated we can
2216
01:33:41,760 --> 01:33:42,760
go ahead and create instances of these
2217
01:33:44,280 --> 01:33:45,280
called objects so basically your class
2218
01:33:47,280 --> 01:33:48,280
acts as a template for these objects
2219
01:33:50,580 --> 01:33:51,580
now
2220
01:33:51,719 --> 01:33:52,719
the first question that pops up in your
2221
01:33:53,820 --> 01:33:54,820
mind would be why do we use object
2222
01:33:57,060 --> 01:33:58,060
oriented programming over procedural
2223
01:34:00,060 --> 01:34:01,060
well it's pretty simple to explain that
2224
01:34:03,480 --> 01:34:04,480
so if we look at the wrong approach that
2225
01:34:06,480 --> 01:34:07,480
is procedural programming
2226
01:34:08,760 --> 01:34:09,760
you would know that you would have a
2227
01:34:11,159 --> 01:34:12,159
character let's say for example so let's
2228
01:34:13,440 --> 01:34:14,440
actually talk about a character which
2229
01:34:15,900 --> 01:34:16,900
you'll have in a game and how we would
2230
01:34:17,340 --> 01:34:18,340
approach it with both programming
2231
01:34:19,080 --> 01:34:20,080
methods
2232
01:34:20,040 --> 01:34:21,040
so in procedural programming you would
2233
01:34:22,800 --> 01:34:23,800
have a character of course you are not
2234
01:34:25,320 --> 01:34:26,320
defining any unit known as character but
2235
01:34:27,960 --> 01:34:28,960
let's say we have a character in a
2236
01:34:29,639 --> 01:34:30,639
program and you you're going to have
2237
01:34:31,620 --> 01:34:32,620
several functions so you have move turn
2238
01:34:34,920 --> 01:34:35,920
jump of course you'll have other
2239
01:34:36,480 --> 01:34:37,480
functions I just took the most Bare
2240
01:34:38,580 --> 01:34:39,580
Bones example and obviously you'll have
2241
01:34:41,580 --> 01:34:42,580
the characters transform and if you guys
2242
01:34:44,100 --> 01:34:45,100
forgot about what transform is transform
2243
01:34:46,860 --> 01:34:47,860
is basically location rotation and the
2244
01:34:49,320 --> 01:34:50,320
scale combined then you're also going to
2245
01:34:51,719 --> 01:34:52,719
have a velocity for the character health
2246
01:34:54,060 --> 01:34:55,060
and other variables pertaining to your
2247
01:34:56,219 --> 01:34:57,219
gameplay
2248
01:34:57,540 --> 01:34:58,540
however there is one problem which you
2249
01:35:00,179 --> 01:35:01,179
might notice we do not have a unit which
2250
01:35:03,420 --> 01:35:04,420
we can recognize as a character so we
2251
01:35:06,179 --> 01:35:07,179
have several functions let's say we call
2252
01:35:08,580 --> 01:35:09,580
the move function for example now when
2253
01:35:11,699 --> 01:35:12,699
we move when we call the move function
2254
01:35:14,520 --> 01:35:15,520
we actually have no idea which character
2255
01:35:17,699 --> 01:35:18,699
we are moving so character itself
2256
01:35:22,080 --> 01:35:23,080
is not actually an entity so we don't
2257
01:35:25,500 --> 01:35:26,500
have an actual entity known as a
2258
01:35:27,600 --> 01:35:28,600
character our program just has functions
2259
01:35:30,719 --> 01:35:31,719
same with the transform we cannot
2260
01:35:33,360 --> 01:35:34,360
instantiate another character so this
2261
01:35:36,600 --> 01:35:37,600
code this entire code isn't reusable so
2262
01:35:40,320 --> 01:35:41,320
that's the problem now what if we head
2263
01:35:43,020 --> 01:35:44,020
back into the object oriented type so if
2264
01:35:46,080 --> 01:35:47,080
we head back
2265
01:35:47,760 --> 01:35:48,760
and if you can see here we have a class
2266
01:35:50,699 --> 01:35:51,699
and we have instantiated several objects
2267
01:35:53,940 --> 01:35:54,940
now if you were to actually model a
2268
01:35:56,400 --> 01:35:57,400
character with this you would have your
2269
01:35:58,020 --> 01:35:59,020
character class obviously with the above
2270
01:36:00,179 --> 01:36:01,179
mentioned functions and data I didn't
2271
01:36:01,920 --> 01:36:02,920
want to rewrite that so you'd have a
2272
01:36:04,620 --> 01:36:05,620
character class
2273
01:36:06,000 --> 01:36:07,000
and now that we actually have a unit
2274
01:36:09,000 --> 01:36:10,000
which we can identify as a character we
2275
01:36:12,179 --> 01:36:13,179
can go ahead and instantiate a character
2276
01:36:14,520 --> 01:36:15,520
and let's say we call it character one
2277
01:36:16,320 --> 01:36:17,320
so we are going to instantiate it so we
2278
01:36:19,260 --> 01:36:20,260
are going to instantiate it and let's
2279
01:36:21,780 --> 01:36:22,780
say we have another player let's say an
2280
01:36:23,580 --> 01:36:24,580
enemy so we can go ahead and reuse that
2281
01:36:25,860 --> 01:36:26,860
once again and instantiate character too
2282
01:36:28,800 --> 01:36:29,800
so now we don't have to rewrite all the
2283
01:36:31,739 --> 01:36:32,739
functions and whenever we are actually
2284
01:36:34,260 --> 01:36:35,260
writing code we have an idea of which
2285
01:36:37,500 --> 01:36:38,500
exact character we are referring to so
2286
01:36:40,080 --> 01:36:41,080
character 2 is actually a real time
2287
01:36:42,360 --> 01:36:43,360
entity and this is known as an object so
2288
01:36:45,360 --> 01:36:46,360
character one is an object character two
2289
01:36:47,219 --> 01:36:48,219
and character 3 all these three are
2290
01:36:49,380 --> 01:36:50,380
objects now if you were to remember in
2291
01:36:52,020 --> 01:36:53,020
our blueprint notes we had a Target pin
2292
01:36:55,440 --> 01:36:56,440
so if I bring in for example set actor
2293
01:36:58,739 --> 01:36:59,739
location
2294
01:37:00,179 --> 01:37:01,179
so I'll just use the same node so set
2295
01:37:03,540 --> 01:37:04,540
actor location
2296
01:37:05,460 --> 01:37:06,460
now you would notice there is a
2297
01:37:07,320 --> 01:37:08,320
character pin now if you were to just
2298
01:37:09,840 --> 01:37:10,840
hover over it it says actor object
2299
01:37:12,239 --> 01:37:13,239
reference now
2300
01:37:14,580 --> 01:37:15,580
in our programming approach what this
2301
01:37:17,280 --> 01:37:18,280
basically means is we have set actor
2302
01:37:20,760 --> 01:37:21,760
location defined in our class so let's
2303
01:37:23,639 --> 01:37:24,639
say for example
2304
01:37:25,139 --> 01:37:26,139
we have something like this so we have
2305
01:37:27,960 --> 01:37:28,960
our actor class now anything that can be
2306
01:37:30,060 --> 01:37:31,060
placed in the level is called an actor
2307
01:37:31,860 --> 01:37:32,860
so let's actually
2308
01:37:33,300 --> 01:37:34,300
create that so actor
2309
01:37:35,580 --> 01:37:36,580
so inside this inside actor you actually
2310
01:37:39,300 --> 01:37:40,300
have a set actor location method so set
2311
01:37:41,639 --> 01:37:42,639
that to location and not write the whole
2312
01:37:43,260 --> 01:37:44,260
thing
2313
01:37:44,159 --> 01:37:45,159
and let's say you instantiate actor one
2314
01:37:47,340 --> 01:37:48,340
so let's call it A1 for example when you
2315
01:37:50,760 --> 01:37:51,760
instantiate actor 1 your program needs
2316
01:37:53,639 --> 01:37:54,639
to know on which actor set actor
2317
01:37:57,000 --> 01:37:58,000
location has to be called
2318
01:37:58,920 --> 01:37:59,920
so we have actor 1 so that is our Target
2319
01:38:02,820 --> 01:38:03,820
so when we call set actor location in
2320
01:38:05,639 --> 01:38:06,639
our case in a blueprint we call set at
2321
01:38:07,739 --> 01:38:08,739
the location now it needs to know on
2322
01:38:10,739 --> 01:38:11,739
which actor it has to perform it so when
2323
01:38:13,500 --> 01:38:14,500
you call this in the through the target
2324
01:38:16,020 --> 01:38:17,020
pin in Blueprint that's how we will do
2325
01:38:18,120 --> 01:38:19,120
it in the Target pin you specify that
2326
01:38:20,820 --> 01:38:21,820
and the program knows that it has to set
2327
01:38:24,420 --> 01:38:25,420
a one's location so that's how it
2328
01:38:27,540 --> 01:38:28,540
basically works foreign
2329
01:38:34,040 --> 01:38:35,040
so it's time we apply whatever we
2330
01:38:36,840 --> 01:38:37,840
learned just now so head into your
2331
01:38:38,760 --> 01:38:39,760
content folder and create a new folder
2332
01:38:40,679 --> 01:38:41,679
and we'll just call this one blueprints
2333
01:38:42,840 --> 01:38:43,840
and inside here we'll create all our
2334
01:38:44,760 --> 01:38:45,760
blueprint classes and we will compare
2335
01:38:46,500 --> 01:38:47,500
all of them so basically the most Bare
2336
01:38:49,199 --> 01:38:50,199
Bones one which you can create is an
2337
01:38:50,880 --> 01:38:51,880
object now please do not confuse this
2338
01:38:52,739 --> 01:38:53,739
with an actual object we are creating a
2339
01:38:54,900 --> 01:38:55,900
class and the class name is going to be
2340
01:38:56,940 --> 01:38:57,940
object we are basically deriving a class
2341
01:38:59,400 --> 01:39:00,400
from this object class this is how you
2342
01:39:02,639 --> 01:39:03,639
basically start in Blueprint however as
2343
01:39:05,100 --> 01:39:06,100
you proceed further you will understand
2344
01:39:06,679 --> 01:39:07,679
note that this is not an actor so I
2345
01:39:09,300 --> 01:39:10,300
cannot drag this into a level now if as
2346
01:39:12,719 --> 01:39:13,719
I mentioned before Unreal Engine already
2347
01:39:14,820 --> 01:39:15,820
has a 2d Vector structure but just to
2348
01:39:17,520 --> 01:39:18,520
Showcase what we can do with such
2349
01:39:19,739 --> 01:39:20,739
classes let me just actually create a 2d
2350
01:39:22,739 --> 01:39:23,739
Vector so let's just call this one
2351
01:39:24,900 --> 01:39:25,900
2D Vector for example
2352
01:39:27,179 --> 01:39:28,179
now please note you cannot name a type
2353
01:39:30,000 --> 01:39:31,000
with a number beginning in you know C
2354
01:39:34,739 --> 01:39:35,739
plus plus however you can do that in
2355
01:39:37,380 --> 01:39:38,380
Blueprint so let me just call this on
2356
01:39:39,960 --> 01:39:40,960
Vector 2 for example
2357
01:39:42,000 --> 01:39:43,000
so if I open this up
2358
01:39:44,219 --> 01:39:45,219
you you would see you have a standard
2359
01:39:46,980 --> 01:39:47,980
blueprint editor you have an event graph
2360
01:39:49,260 --> 01:39:50,260
but you don't have your viewport and
2361
01:39:51,000 --> 01:39:52,000
stuff like that which you would see in
2362
01:39:52,620 --> 01:39:53,620
an actor now one more thing you would
2363
01:39:54,840 --> 01:39:55,840
notice is you don't have an event pick
2364
01:39:56,699 --> 01:39:57,699
and play so you get an option to add a
2365
01:39:59,820 --> 01:40:00,820
custom event which is basically like
2366
01:40:02,400 --> 01:40:03,400
defining a function but it does not
2367
01:40:04,620 --> 01:40:05,620
return anything and you can call it just
2368
01:40:07,080 --> 01:40:08,080
like a function and we will be using a
2369
01:40:09,780 --> 01:40:10,780
lot of custom events so you would get an
2370
01:40:12,000 --> 01:40:13,000
idea of what I mean
2371
01:40:13,500 --> 01:40:14,500
now in Vector 2 we are going to have two
2372
01:40:16,260 --> 01:40:17,260
variables the first two are going to be
2373
01:40:19,139 --> 01:40:20,139
floats
2374
01:40:20,699 --> 01:40:21,699
so obviously we'll think about what we
2375
01:40:22,500 --> 01:40:23,500
can have later on so it's going to be an
2376
01:40:24,540 --> 01:40:25,540
X and A Y
2377
01:40:26,760 --> 01:40:27,760
so these are the variables which are
2378
01:40:29,159 --> 01:40:30,159
encapsulated inside this Vector 2 class
2379
01:40:31,980 --> 01:40:32,980
note that this is not an object this is
2380
01:40:34,500 --> 01:40:35,500
a class and when we actually create an
2381
01:40:37,260 --> 01:40:38,260
instance of this we create a vector too
2382
01:40:39,659 --> 01:40:40,659
so that's how it basically works now we
2383
01:40:43,080 --> 01:40:44,080
don't want this X and Y variable to be
2384
01:40:45,780 --> 01:40:46,780
directly accessible
2385
01:40:47,760 --> 01:40:48,760
now the reason I wanted this way is for
2386
01:40:50,520 --> 01:40:51,520
data security now I don't want to be
2387
01:40:53,699 --> 01:40:54,699
directly able to write any random value
2388
01:40:55,739 --> 01:40:56,739
to X and Y let's say this was exposed
2389
01:40:58,980 --> 01:40:59,980
and you could actually change this
2390
01:41:01,080 --> 01:41:02,080
directly in memory what would happen is
2391
01:41:04,440 --> 01:41:05,440
now for example let's say I have a
2392
01:41:07,080 --> 01:41:08,080
vector 2 object so let me just create
2393
01:41:09,420 --> 01:41:10,420
that so use the construct object
2394
01:41:11,219 --> 01:41:12,219
function so construct object from class
2395
01:41:17,639 --> 01:41:18,639
so I think I misspelled that so
2396
01:41:19,800 --> 01:41:20,800
construct
2397
01:41:21,719 --> 01:41:22,719
object from class yep there we have it
2398
01:41:24,540 --> 01:41:25,540
so I'll just delete this and if you go
2399
01:41:27,239 --> 01:41:28,239
ahead we will get access to our vector
2400
01:41:29,159 --> 01:41:30,159
2.
2401
01:41:30,360 --> 01:41:31,360
so Vector 2 for example
2402
01:41:33,719 --> 01:41:34,719
now we have a vector 2 object over here
2403
01:41:36,060 --> 01:41:37,060
so this is actually a vector 2 object we
2404
01:41:39,840 --> 01:41:40,840
could go ahead and promote that to a
2405
01:41:41,639 --> 01:41:42,639
variable so it's going to create a
2406
01:41:43,020 --> 01:41:44,020
variable of that type and let's just
2407
01:41:45,119 --> 01:41:46,119
call this one R vector
2408
01:41:48,239 --> 01:41:49,239
now we don't want any other
2409
01:41:52,040 --> 01:41:53,040
external entity to actually be able to
2410
01:41:55,219 --> 01:41:56,219
directly set X
2411
01:41:57,900 --> 01:41:58,900
so this would be prone to lots of
2412
01:42:02,880 --> 01:42:03,880
exploits basically
2413
01:42:04,980 --> 01:42:05,980
so that's the reason what you generally
2414
01:42:07,560 --> 01:42:08,560
do in object oriented is you make this
2415
01:42:09,900 --> 01:42:10,900
private you see the option over here
2416
01:42:11,699 --> 01:42:12,699
called private now basically you will
2417
01:42:14,699 --> 01:42:15,699
not be able to access X and Y from here
2418
01:42:16,739 --> 01:42:17,739
so now if I type in get X you see I
2419
01:42:19,440 --> 01:42:20,440
can't get it if I type in set X
2420
01:42:22,020 --> 01:42:23,020
I cannot set X so that's one way of
2421
01:42:25,080 --> 01:42:26,080
providing security to the data now what
2422
01:42:27,960 --> 01:42:28,960
if you just wanted to access the value
2423
01:42:29,580 --> 01:42:30,580
that's pretty simple you would just go
2424
01:42:31,860 --> 01:42:32,860
ahead and create a function so you type
2425
01:42:33,480 --> 01:42:34,480
in get x value for example so get X
2426
01:42:36,659 --> 01:42:37,659
and get y
2427
01:42:38,400 --> 01:42:39,400
and we are going to make this PR
2428
01:42:39,719 --> 01:42:40,719
functions because we are just returning
2429
01:42:41,940 --> 01:42:42,940
the immediate value
2430
01:42:43,739 --> 01:42:44,739
and we could add a compact node title
2431
01:42:46,679 --> 01:42:47,679
and call This One X
2432
01:42:48,420 --> 01:42:49,420
and we'll call this one y
2433
01:42:50,460 --> 01:42:51,460
now in the return node we could just go
2434
01:42:52,619 --> 01:42:53,619
ahead and return the value so return
2435
01:42:54,420 --> 01:42:55,420
node
2436
01:42:55,800 --> 01:42:56,800
and we can go ahead and grab our y here
2437
01:43:00,179 --> 01:43:01,179
and return that
2438
01:43:01,860 --> 01:43:02,860
and over here as well we can go ahead
2439
01:43:04,199 --> 01:43:05,199
and return X
2440
01:43:05,880 --> 01:43:06,880
so grabbing the return node and return X
2441
01:43:09,840 --> 01:43:10,840
so now if you wanted to access X or Y
2442
01:43:12,420 --> 01:43:13,420
you can go ahead and type in get X
2443
01:43:15,360 --> 01:43:16,360
so you will get access to the x value
2444
01:43:17,580 --> 01:43:18,580
however you will not be able to edit X
2445
01:43:20,880 --> 01:43:21,880
directly
2446
01:43:22,080 --> 01:43:23,080
so again for that we can go ahead and
2447
01:43:25,380 --> 01:43:26,380
create setters
2448
01:43:26,820 --> 01:43:27,820
so Setters are basically just functions
2449
01:43:29,340 --> 01:43:30,340
which are going to set the value so
2450
01:43:31,020 --> 01:43:32,020
let's say I type in set X
2451
01:43:34,080 --> 01:43:35,080
and I type in set set y I accidentally
2452
01:43:37,980 --> 01:43:38,980
type text again
2453
01:43:39,360 --> 01:43:40,360
so set White
2454
01:43:43,800 --> 01:43:44,800
all right so once that's set we can go
2455
01:43:46,560 --> 01:43:47,560
ahead and take in the value
2456
01:43:48,719 --> 01:43:49,719
and this is going to be
2457
01:43:51,179 --> 01:43:52,179
of type float
2458
01:43:53,760 --> 01:43:54,760
and we can go ahead and set our y to be
2459
01:43:57,119 --> 01:43:58,119
equal to that
2460
01:43:58,800 --> 01:43:59,800
and we can go ahead and type in let it
2461
01:44:01,380 --> 01:44:02,380
the return node we don't really need it
2462
01:44:03,540 --> 01:44:04,540
in this case but anyways we'll have it
2463
01:44:06,300 --> 01:44:07,300
and in our set X function we could do
2464
01:44:08,760 --> 01:44:09,760
the exact same thing we could add in an
2465
01:44:11,280 --> 01:44:12,280
input pin and call this one value once
2466
01:44:13,440 --> 01:44:14,440
again
2467
01:44:16,800 --> 01:44:17,800
value
2468
01:44:18,060 --> 01:44:19,060
and we can go ahead and add in a return
2469
01:44:20,340 --> 01:44:21,340
node
2470
01:44:22,500 --> 01:44:23,500
whoops we didn't need that
2471
01:44:25,619 --> 01:44:26,619
now what if you just wanted to set this
2472
01:44:28,800 --> 01:44:29,800
entire vector
2473
01:44:31,679 --> 01:44:32,679
now when we set R Vector we are actually
2474
01:44:35,940 --> 01:44:36,940
just getting a reference to it we are
2475
01:44:38,940 --> 01:44:39,940
not actually setting our members
2476
01:44:41,219 --> 01:44:42,219
so we can go ahead and write a function
2477
01:44:43,260 --> 01:44:44,260
for that again we could get add a get
2478
01:44:45,900 --> 01:44:46,900
Vector to
2479
01:44:48,420 --> 01:44:49,420
and we could also have a set Vector too
2480
01:44:54,360 --> 01:44:55,360
so something like this this was just to
2481
01:44:56,699 --> 01:44:57,699
show you guys how we would work with
2482
01:44:58,020 --> 01:44:59,020
classes and objects so
2483
01:45:00,960 --> 01:45:01,960
for get Vector 2
2484
01:45:02,940 --> 01:45:03,940
we can go ahead and
2485
01:45:07,500 --> 01:45:08,500
actually return the value
2486
01:45:10,260 --> 01:45:11,260
so we can go ahead and add in the return
2487
01:45:12,659 --> 01:45:13,659
node
2488
01:45:14,100 --> 01:45:15,100
and we can get our X and our y
2489
01:45:19,860 --> 01:45:20,860
so things like that
2490
01:45:21,840 --> 01:45:22,840
so for a set Vector 2 we can go ahead
2491
01:45:24,840 --> 01:45:25,840
and all track this
2492
01:45:27,780 --> 01:45:28,780
or track this once again
2493
01:45:30,179 --> 01:45:31,179
now obviously please do understand that
2494
01:45:32,460 --> 01:45:33,460
this is kind of impractical
2495
01:45:34,560 --> 01:45:35,560
unreal already has a struct built in
2496
01:45:37,199 --> 01:45:38,199
which handles all this for us I'm just
2497
01:45:40,199 --> 01:45:41,199
trying to show you an example of how you
2498
01:45:43,139 --> 01:45:44,139
would actually use it
2499
01:45:45,060 --> 01:45:46,060
so this is how you do it so now if I
2500
01:45:47,400 --> 01:45:48,400
type in set Vector 2 you see I can
2501
01:45:49,980 --> 01:45:50,980
actually set its value and the target is
2502
01:45:52,920 --> 01:45:53,920
R Vector so we are adjusting this value
2503
01:45:57,119 --> 01:45:58,119
and we could go ahead and write in a few
2504
01:45:59,520 --> 01:46:00,520
more functions so for example we could
2505
01:46:02,639 --> 01:46:03,639
write a function to print the vector to
2506
01:46:05,699 --> 01:46:06,699
so print vector 2.
2507
01:46:08,400 --> 01:46:09,400
so we can go ahead and type in print
2508
01:46:11,400 --> 01:46:12,400
string
2509
01:46:13,560 --> 01:46:14,560
and we need a word context object
2510
01:46:16,440 --> 01:46:17,440
however it is going to take the outer
2511
01:46:18,900 --> 01:46:19,900
object by default I believe but anyways
2512
01:46:21,900 --> 01:46:22,900
in these contexts what you would want to
2513
01:46:24,119 --> 01:46:25,119
do with something which I haven't seen
2514
01:46:26,100 --> 01:46:27,100
much is you would just get the outer
2515
01:46:27,960 --> 01:46:28,960
object there is a function for this
2516
01:46:29,880 --> 01:46:30,880
basically the outer object is the object
2517
01:46:32,040 --> 01:46:33,040
from which the subject was created so in
2518
01:46:34,560 --> 01:46:35,560
our case it's our level blueprint and we
2519
01:46:36,420 --> 01:46:37,420
can call the print function from there
2520
01:46:38,400 --> 01:46:39,400
the reason is it actually needs to know
2521
01:46:41,400 --> 01:46:42,400
uh where to actually print the string so
2522
01:46:44,280 --> 01:46:45,280
that's the reason actually
2523
01:46:46,020 --> 01:46:47,020
so now I can just type in self self
2524
01:46:48,600 --> 01:46:49,600
refers to this object itself so we can
2525
01:46:51,060 --> 01:46:52,060
just pass that in
2526
01:46:52,739 --> 01:46:53,739
now we can go ahead and actually print
2527
01:46:57,420 --> 01:46:58,420
something so in our case we can get our
2528
01:47:00,000 --> 01:47:01,000
X
2529
01:47:01,260 --> 01:47:02,260
and one handy function which you'll use
2530
01:47:03,659 --> 01:47:04,659
a lot is going to be append so we can go
2531
01:47:06,300 --> 01:47:07,300
ahead and type in X for the x value give
2532
01:47:10,199 --> 01:47:11,199
a space and then print out RX
2533
01:47:13,500 --> 01:47:14,500
move that over there to keep things
2534
01:47:15,540 --> 01:47:16,540
clean
2535
01:47:16,800 --> 01:47:17,800
and we can go ahead and do the same for
2536
01:47:19,020 --> 01:47:20,020
the Y as well so we can go ahead and
2537
01:47:21,960 --> 01:47:22,960
give a space
2538
01:47:24,360 --> 01:47:25,360
and we can type in y with a colon
2539
01:47:29,100 --> 01:47:30,100
and we can go ahead and print that
2540
01:47:32,820 --> 01:47:33,820
so we have our y
2541
01:47:35,639 --> 01:47:36,639
we can go ahead and convert that once
2542
01:47:37,560 --> 01:47:38,560
again
2543
01:47:38,639 --> 01:47:39,639
and we can go ahead and print that if
2544
01:47:40,260 --> 01:47:41,260
you right click you can actually remove
2545
01:47:41,520 --> 01:47:42,520
the extra pin so that's an option
2546
01:47:43,560 --> 01:47:44,560
available as well
2547
01:47:45,360 --> 01:47:46,360
so now this is how you do it now if I go
2548
01:47:48,239 --> 01:47:49,239
ahead and press play
2549
01:47:49,679 --> 01:47:50,679
obviously we are not calling it anywhere
2550
01:47:51,719 --> 01:47:52,719
so now now that we have R Vector we can
2551
01:47:54,540 --> 01:47:55,540
go ahead and call Print vector2
2552
01:47:56,880 --> 01:47:57,880
so this is going to print our vector
2553
01:48:00,780 --> 01:48:01,780
so this is how it works
2554
01:48:03,060 --> 01:48:04,060
and obviously we can also test out our
2555
01:48:05,639 --> 01:48:06,639
set functions so we can type in set
2556
01:48:08,880 --> 01:48:09,880
vector2
2557
01:48:14,340 --> 01:48:15,340
and we can just give some random values
2558
01:48:17,219 --> 01:48:18,219
to this and if we go ahead and print
2559
01:48:19,440 --> 01:48:20,440
Vector 2 we should get that value
2560
01:48:22,320 --> 01:48:23,320
so this is basically how we would work
2561
01:48:24,600 --> 01:48:25,600
with the most basic type of object now
2562
01:48:27,360 --> 01:48:28,360
this is mostly useful in cases where you
2563
01:48:30,239 --> 01:48:31,239
only need some data and methods and you
2564
01:48:33,780 --> 01:48:34,780
want methods basically because in
2565
01:48:37,380 --> 01:48:38,380
Blueprint you cannot have struct methods
2566
01:48:40,380 --> 01:48:41,380
so in those cases you would use an
2567
01:48:43,560 --> 01:48:44,560
object type
2568
01:48:44,760 --> 01:48:45,760
so we are not going to be messing with
2569
01:48:46,860 --> 01:48:47,860
this any further
2570
01:48:49,000 --> 01:48:50,000
[Music]
2571
01:48:53,400 --> 01:48:54,400
now the the next type which you will use
2572
01:48:56,280 --> 01:48:57,280
is going to be an actor now this is
2573
01:48:59,159 --> 01:49:00,159
probably the most commonly used type and
2574
01:49:02,159 --> 01:49:03,159
most of the other types of class
2575
01:49:04,139 --> 01:49:05,139
official create will also be derived
2576
01:49:06,360 --> 01:49:07,360
from actor so let me just create that
2577
01:49:08,460 --> 01:49:09,460
right click go to blueprint class and
2578
01:49:10,139 --> 01:49:11,139
create an actor it's directly available
2579
01:49:11,639 --> 01:49:12,639
here or you could search down there
2580
01:49:14,280 --> 01:49:15,280
so if I create an actor we'll call this
2581
01:49:16,500 --> 01:49:17,500
one my actor for example
2582
01:49:18,420 --> 01:49:19,420
now if you were to notice if I drag this
2583
01:49:21,239 --> 01:49:22,239
I cannot do that because you cannot
2584
01:49:23,639 --> 01:49:24,639
place a vector 2 in your scene right
2585
01:49:26,340 --> 01:49:27,340
however I can drag my actor and I can
2586
01:49:29,100 --> 01:49:30,100
place it in the scene and if I hit F on
2587
01:49:30,960 --> 01:49:31,960
my keyboard I can actually see it now
2588
01:49:32,880 --> 01:49:33,880
this is just a visual representation in
2589
01:49:35,040 --> 01:49:36,040
the editor so that you can actually see
2590
01:49:37,199 --> 01:49:38,199
it however if you hit G on your keyboard
2591
01:49:39,060 --> 01:49:40,060
to go to game view it actually won't be
2592
01:49:41,340 --> 01:49:42,340
seen
2593
01:49:42,659 --> 01:49:43,659
now if you were to open your actor you
2594
01:49:45,119 --> 01:49:46,119
would see the editor is a little more
2595
01:49:47,040 --> 01:49:48,040
complicated than your basic object you
2596
01:49:49,739 --> 01:49:50,739
have three tabs the viewport the
2597
01:49:52,320 --> 01:49:53,320
construction script and the event graph
2598
01:49:54,480 --> 01:49:55,480
where you will be working with most of
2599
01:49:56,520 --> 01:49:57,520
the time we will separately talk about
2600
01:49:58,500 --> 01:49:59,500
construction scripts and we'll also get
2601
01:50:00,540 --> 01:50:01,540
to the viewport but of our relevance is
2602
01:50:03,420 --> 01:50:04,420
the event graph right now and we will
2603
01:50:05,340 --> 01:50:06,340
talk a little bit more about actors
2604
01:50:08,219 --> 01:50:09,219
you would also notice that we have our
2605
01:50:10,980 --> 01:50:11,980
begin play and tick which we missed in
2606
01:50:13,260 --> 01:50:14,260
our basic object type class
2607
01:50:16,139 --> 01:50:17,139
now if we wanted to have multiple of
2608
01:50:18,420 --> 01:50:19,420
these actors so let's actually do
2609
01:50:21,300 --> 01:50:22,300
something practical let's say we had a
2610
01:50:23,040 --> 01:50:24,040
pickup actor in our game so we have pick
2611
01:50:25,860 --> 01:50:26,860
up actor
2612
01:50:28,199 --> 01:50:29,199
and it's generally a convention you do
2613
01:50:31,380 --> 01:50:32,380
something like this
2614
01:50:33,179 --> 01:50:34,179
BP underscore pickup
2615
01:50:35,520 --> 01:50:36,520
because more often than not or here if
2616
01:50:39,360 --> 01:50:40,360
you see the parent class it says actor
2617
01:50:41,400 --> 01:50:42,400
right so more often than not you will
2618
01:50:43,860 --> 01:50:44,860
actually create another class of your
2619
01:50:45,719 --> 01:50:46,719
own in C plus plus so any code that
2620
01:50:48,119 --> 01:50:49,119
needs to run fast or something you would
2621
01:50:49,800 --> 01:50:50,800
put that in C plus plus and then you
2622
01:50:52,020 --> 01:50:53,020
would derive BP pickup from the C plus
2623
01:50:55,080 --> 01:50:56,080
plus pickup actor so that's why it's a
2624
01:50:57,420 --> 01:50:58,420
convention I usually name it like this
2625
01:50:59,280 --> 01:51:00,280
so I can go ahead and grab this so I
2626
01:51:02,219 --> 01:51:03,219
have BP pickup whoops deleted the wrong
2627
01:51:04,860 --> 01:51:05,860
thing so I can delete my actor here BP
2628
01:51:07,980 --> 01:51:08,980
pickup 2 will be created so these two
2629
01:51:10,739 --> 01:51:11,739
are pickups and both of these contain
2630
01:51:13,440 --> 01:51:14,440
all the variables and functions which
2631
01:51:15,239 --> 01:51:16,239
this creates
2632
01:51:16,500 --> 01:51:17,500
so you can go ahead and edit our
2633
01:51:18,600 --> 01:51:19,600
blueprint just like how we would usually
2634
01:51:21,060 --> 01:51:22,060
all right so it's time to dive a little
2635
01:51:23,580 --> 01:51:24,580
bit more deeper into some of these
2636
01:51:25,679 --> 01:51:26,679
events and let's actually start writing
2637
01:51:28,020 --> 01:51:29,020
some practical code
2638
01:51:29,580 --> 01:51:30,580
so event begin play is called not when
2639
01:51:33,420 --> 01:51:34,420
the game begins actually that's the
2640
01:51:35,820 --> 01:51:36,820
wrong way to interpret it however event
2641
01:51:38,400 --> 01:51:39,400
begin play is called when this actor is
2642
01:51:41,880 --> 01:51:42,880
instantiated so for example we have our
2643
01:51:43,980 --> 01:51:44,980
BP pickup here and since this is placed
2644
01:51:46,500 --> 01:51:47,500
in our level this will get created as
2645
01:51:48,360 --> 01:51:49,360
soon as our level starts so it is
2646
01:51:50,400 --> 01:51:51,400
technically called when the game starts
2647
01:51:53,040 --> 01:51:54,040
however if I just go ahead and print
2648
01:51:55,440 --> 01:51:56,440
this
2649
01:51:56,639 --> 01:51:57,639
and
2650
01:51:58,320 --> 01:51:59,320
let's just call this begin play
2651
01:52:02,100 --> 01:52:03,100
you would see two begin place because we
2652
01:52:04,739 --> 01:52:05,739
have two instances of our BP pickup
2653
01:52:07,619 --> 01:52:08,619
however
2654
01:52:09,600 --> 01:52:10,600
it need not be called when the game
2655
01:52:12,060 --> 01:52:13,060
begins it is called when the pickup
2656
01:52:15,300 --> 01:52:16,300
actor is actually created so when BP
2657
01:52:17,580 --> 01:52:18,580
pickup is created that is when it is
2658
01:52:19,500 --> 01:52:20,500
called so let's delete a vector 2 stuff
2659
01:52:21,300 --> 01:52:22,300
we don't really need it now in order to
2660
01:52:24,000 --> 01:52:25,000
actually create an actor remember that
2661
01:52:26,820 --> 01:52:27,820
every actor is going to have a location
2662
01:52:28,860 --> 01:52:29,860
rotation and scale so that's the reason
2663
01:52:31,380 --> 01:52:32,380
you cannot just create an object because
2664
01:52:33,300 --> 01:52:34,300
you do need a certain number of
2665
01:52:37,040 --> 01:52:38,040
default parameters in order to actually
2666
01:52:39,480 --> 01:52:40,480
be able to place something in the scene
2667
01:52:41,159 --> 01:52:42,159
so without a location the engine has no
2668
01:52:43,980 --> 01:52:44,980
idea of where to place it that's the
2669
01:52:45,900 --> 01:52:46,900
reason actor exists now if you head back
2670
01:52:48,719 --> 01:52:49,719
into your level blueprint let's actually
2671
01:52:50,219 --> 01:52:51,219
give a delay of a few seconds just to
2672
01:52:52,380 --> 01:52:53,380
show you guys
2673
01:52:53,460 --> 01:52:54,460
so let's say we give a delay of two
2674
01:52:55,320 --> 01:52:56,320
seconds and in order to create an actor
2675
01:52:57,719 --> 01:52:58,719
you call a function known as Pawn actor
2676
01:53:01,800 --> 01:53:02,800
so spawn actor from class and over here
2677
01:53:05,100 --> 01:53:06,100
under spawn transform we could just set
2678
01:53:07,139 --> 01:53:08,139
that to zero for now it's since we don't
2679
01:53:09,300 --> 01:53:10,300
have any visual representation it
2680
01:53:11,040 --> 01:53:12,040
doesn't matter honestly
2681
01:53:12,840 --> 01:53:13,840
so once that's done we can go ahead and
2682
01:53:15,239 --> 01:53:16,239
select our BP pickup
2683
01:53:18,780 --> 01:53:19,780
and we can go ahead and compile it now
2684
01:53:21,179 --> 01:53:22,179
if I press play you see begin play is
2685
01:53:23,520 --> 01:53:24,520
called but two seconds later another
2686
01:53:25,800 --> 01:53:26,800
begin place called if you guys couldn't
2687
01:53:28,020 --> 01:53:29,020
catch that I'll leave a longer delay
2688
01:53:31,260 --> 01:53:32,260
begin play
2689
01:53:33,060 --> 01:53:34,060
and another begin play was called and if
2690
01:53:35,460 --> 01:53:36,460
you would notice in the outliner
2691
01:53:37,619 --> 01:53:38,619
you would actually notice another
2692
01:53:39,300 --> 01:53:40,300
instance being created here
2693
01:53:42,300 --> 01:53:43,300
so if you were to notice there is
2694
01:53:44,219 --> 01:53:45,219
another BP pickup that is created so
2695
01:53:47,040 --> 01:53:48,040
that's basically how it works
2696
01:53:49,619 --> 01:53:50,619
and tick is called every frame however
2697
01:53:52,199 --> 01:53:53,199
it need not be once again
2698
01:53:54,420 --> 01:53:55,420
so if I just go ahead or I can just go
2699
01:53:56,639 --> 01:53:57,639
and reuse it actually
2700
01:53:58,800 --> 01:53:59,800
so instead of this I'm going to type in
2701
01:54:01,800 --> 01:54:02,800
tick
2702
01:54:03,320 --> 01:54:04,320
and now this should be called every
2703
01:54:06,179 --> 01:54:07,179
frame let's have let's only have one
2704
01:54:07,860 --> 01:54:08,860
pickup actor and let's go ahead and not
2705
01:54:10,500 --> 01:54:11,500
spawn this
2706
01:54:12,060 --> 01:54:13,060
so if you want to disconnect pins like
2707
01:54:14,040 --> 01:54:15,040
that by the way you can go ahead and
2708
01:54:15,780 --> 01:54:16,780
press alt over here and it's going to
2709
01:54:18,060 --> 01:54:19,060
disconnect the pin so we don't need that
2710
01:54:20,820 --> 01:54:21,820
now
2711
01:54:24,000 --> 01:54:25,000
if you were to notice it's going to
2712
01:54:26,340 --> 01:54:27,340
constantly print tick
2713
01:54:28,320 --> 01:54:29,320
so this should be about 200 to 300 times
2714
01:54:31,800 --> 01:54:32,800
a second on my computer so if I just
2715
01:54:34,080 --> 01:54:35,080
type in stat FPS
2716
01:54:37,639 --> 01:54:38,639
whoops missed that start FPS
2717
01:54:41,400 --> 01:54:42,400
it's locked at 120 so it's 120 times a
2718
01:54:44,760 --> 01:54:45,760
second
2719
01:54:45,600 --> 01:54:46,600
so if you want to increase it actually
2720
01:54:47,520 --> 01:54:48,520
you can remove the cap by typing in t
2721
01:54:49,500 --> 01:54:50,500
dot Max FPS space Max FPS give something
2722
01:54:53,580 --> 01:54:54,580
like 999 or 1000
2723
01:54:56,460 --> 01:54:57,460
all right so I don't know I did that
2724
01:54:59,580 --> 01:55:00,580
now head back into your blueprints
2725
01:55:02,219 --> 01:55:03,219
under your pickup and under your class
2726
01:55:04,920 --> 01:55:05,920
defaults you can actually disable your
2727
01:55:07,139 --> 01:55:08,139
tick
2728
01:55:08,159 --> 01:55:09,159
so you can go ahead and disable and as
2729
01:55:11,100 --> 01:55:12,100
you can see nothing's being printed
2730
01:55:13,440 --> 01:55:14,440
now there's another thing
2731
01:55:15,480 --> 01:55:16,480
you can actually change this parameter
2732
01:55:18,119 --> 01:55:19,119
at runtime as well people don't know
2733
01:55:20,159 --> 01:55:21,159
this but any and all details which are
2734
01:55:24,659 --> 01:55:25,659
there in this panel over here so let's
2735
01:55:26,820 --> 01:55:27,820
say for example I go to my class
2736
01:55:29,159 --> 01:55:30,159
defaults
2737
01:55:30,480 --> 01:55:31,480
I will definitely be able to change most
2738
01:55:34,020 --> 01:55:35,020
of these at runtime so for example we
2739
01:55:36,780 --> 01:55:37,780
have start with tick enabled so we
2740
01:55:39,659 --> 01:55:40,659
should be able to enable or disable tick
2741
01:55:41,760 --> 01:55:42,760
at runtime so let's actually just type
2742
01:55:43,739 --> 01:55:44,739
in tick enabled
2743
01:55:45,420 --> 01:55:46,420
and as you can see there is actually a
2744
01:55:47,520 --> 01:55:48,520
function which lets us do it so if I go
2745
01:55:50,100 --> 01:55:51,100
ahead and actually enable tick first of
2746
01:55:52,380 --> 01:55:53,380
all
2747
01:55:53,580 --> 01:55:54,580
and if I go ahead and disable it after
2748
01:55:55,679 --> 01:55:56,679
one second you would notice that Tech is
2749
01:55:58,440 --> 01:55:59,440
being printed and a second letter it
2750
01:56:01,139 --> 01:56:02,139
stops printing tick so that's basically
2751
01:56:03,960 --> 01:56:04,960
how it works and not only that any and
2752
01:56:06,960 --> 01:56:07,960
all parameters and you can actually
2753
01:56:08,760 --> 01:56:09,760
change the tick interval as well let's
2754
01:56:10,500 --> 01:56:11,500
say it's printing too often you could
2755
01:56:12,600 --> 01:56:13,600
just set it to 0.5 so it will be roughly
2756
01:56:15,300 --> 01:56:16,300
0.5 seconds now as you can see it is not
2757
01:56:18,300 --> 01:56:19,300
printing as frequently so that's
2758
01:56:20,820 --> 01:56:21,820
basically one aspect in blueprints that
2759
01:56:24,119 --> 01:56:25,119
that is Handy to know because any and
2760
01:56:26,639 --> 01:56:27,639
all settings that will be there will be
2761
01:56:28,619 --> 01:56:29,619
usually uh exposed as functions to be
2762
01:56:32,760 --> 01:56:33,760
adjusted at runtime otherwise again you
2763
01:56:36,179 --> 01:56:37,179
have your class defaults where you can
2764
01:56:37,980 --> 01:56:38,980
actually set them I think whatever we
2765
01:56:40,980 --> 01:56:41,980
did till now is clear now so we can go
2766
01:56:43,380 --> 01:56:44,380
ahead and delete this code we won't be
2767
01:56:45,060 --> 01:56:46,060
using it as of now so now let's go ahead
2768
01:56:47,760 --> 01:56:48,760
and actually write some code for the
2769
01:56:50,400 --> 01:56:51,400
pickup itself so let's say we had an
2770
01:56:52,739 --> 01:56:53,739
object and we had to pick it up first
2771
01:56:54,719 --> 01:56:55,719
things first there is no visual
2772
01:56:56,100 --> 01:56:57,100
representation for the object so let's
2773
01:56:58,619 --> 01:56:59,619
say we actually just go ahead and oops
2774
01:57:01,920 --> 01:57:02,920
okay go ahead and press play you would
2775
01:57:04,260 --> 01:57:05,260
see that you can't actually see anything
2776
01:57:06,780 --> 01:57:07,780
no
2777
01:57:08,639 --> 01:57:09,639
if I zoom into this so as you can see
2778
01:57:11,699 --> 01:57:12,699
you can't actually see this pickup so
2779
01:57:14,580 --> 01:57:15,580
first of all let's actually add in a
2780
01:57:16,440 --> 01:57:17,440
model and stuff like that now there is
2781
01:57:18,719 --> 01:57:19,719
one thing
2782
01:57:19,679 --> 01:57:20,679
uh the default scene root is not
2783
01:57:22,739 --> 01:57:23,739
actually required if I delete it I won't
2784
01:57:25,440 --> 01:57:26,440
be able to however I can actually add in
2785
01:57:28,500 --> 01:57:29,500
a static mesh now a skeletal mesh is a
2786
01:57:31,080 --> 01:57:32,080
mesh which contains Burns and stuff like
2787
01:57:33,000 --> 01:57:34,000
that so basically your characters and
2788
01:57:36,540 --> 01:57:37,540
anything with animations is going to be
2789
01:57:39,480 --> 01:57:40,480
a skeletal mesh basically however your
2790
01:57:42,360 --> 01:57:43,360
models like your pickups and stuff
2791
01:57:45,599 --> 01:57:46,599
usually are going to be static meshes
2792
01:57:48,179 --> 01:57:49,179
so that's basically how it works as you
2793
01:57:50,219 --> 01:57:51,219
use them you will understand so now if I
2794
01:57:53,219 --> 01:57:54,219
drag this into the default scene root
2795
01:57:55,920 --> 01:57:56,920
I'll go ahead and delete the visual
2796
01:57:58,020 --> 01:57:59,020
representation and the static mesh will
2797
01:58:00,900 --> 01:58:01,900
be replaced now one thing to note when
2798
01:58:03,239 --> 01:58:04,239
you do this the most high component the
2799
01:58:07,139 --> 01:58:08,139
component which is the uppermost in the
2800
01:58:09,719 --> 01:58:10,719
hierarchy over here is called the root
2801
01:58:12,360 --> 01:58:13,360
component so for example this default
2802
01:58:14,400 --> 01:58:15,400
scene root is the root component now
2803
01:58:16,260 --> 01:58:17,260
when I drag the static mesh this is the
2804
01:58:19,440 --> 01:58:20,440
root component and if physics has to be
2805
01:58:22,020 --> 01:58:23,020
simulated in our case let's actually try
2806
01:58:25,020 --> 01:58:26,020
that let's make the pickup fall down and
2807
01:58:26,940 --> 01:58:27,940
follow the laws of physics so in that
2808
01:58:29,040 --> 01:58:30,040
case we will need it to be the root
2809
01:58:30,659 --> 01:58:31,659
component so that's one thing to note
2810
01:58:32,760 --> 01:58:33,760
now if I go ahead and select a mesh so
2811
01:58:36,360 --> 01:58:37,360
for example I can just select this
2812
01:58:39,000 --> 01:58:40,000
random sphere that we have I think it's
2813
01:58:41,280 --> 01:58:42,280
way too big so
2814
01:58:44,099 --> 01:58:45,099
yeah we got to adjust that
2815
01:58:46,560 --> 01:58:47,560
now I can go ahead and enable simulate
2816
01:58:49,980 --> 01:58:50,980
physics
2817
01:58:52,440 --> 01:58:53,440
so now if I go ahead and press play
2818
01:58:57,599 --> 01:58:58,599
you see that it falls like you would
2819
01:58:59,880 --> 01:59:00,880
expect
2820
01:59:02,460 --> 01:59:03,460
so we basically simulated physics now we
2821
01:59:05,460 --> 01:59:06,460
have a visual representation now how are
2822
01:59:08,219 --> 01:59:09,219
we actually going to pick this up now
2823
01:59:10,679 --> 01:59:11,679
actually let's select something a little
2824
01:59:12,300 --> 01:59:13,300
more smaller because
2825
01:59:14,460 --> 01:59:15,460
I don't think this is convenient
2826
01:59:17,040 --> 01:59:18,040
okay this seems like a reasonable size
2827
01:59:19,920 --> 01:59:20,920
so if we go ahead and press play
2828
01:59:22,139 --> 01:59:23,139
we are simulating physics so absolutely
2829
01:59:24,360 --> 01:59:25,360
no problem with that and one thing to
2830
01:59:26,580 --> 01:59:27,580
remember in case you are not simulating
2831
01:59:28,739 --> 01:59:29,739
physics make sure you do have collision
2832
01:59:30,719 --> 01:59:31,719
and stuff like that if you if we
2833
01:59:34,139 --> 01:59:35,139
actually encounter such an issue I will
2834
01:59:36,179 --> 01:59:37,179
go ahead and show you guys how to deal
2835
01:59:37,980 --> 01:59:38,980
with that
2836
01:59:38,940 --> 01:59:39,940
so we have physics now now we can go
2837
01:59:41,400 --> 01:59:42,400
ahead and set up some logic now
2838
01:59:43,920 --> 01:59:44,920
we want to be able to pick this up when
2839
01:59:46,679 --> 01:59:47,679
we overlap it let's say for example so
2840
01:59:49,739 --> 01:59:50,739
we can do on actor begin overlap
2841
01:59:53,159 --> 01:59:54,159
so what this says is when another actor
2842
01:59:56,840 --> 01:59:57,840
overlaps this actor so in our case it's
2843
02:00:00,360 --> 02:00:01,360
going to be this when it overlaps this
2844
02:00:03,000 --> 02:00:04,000
actor we can go ahead and perform some
2845
02:00:05,940 --> 02:00:06,940
logic and Unreal Engine has set this up
2846
02:00:08,639 --> 02:00:09,639
for us now there is one problem though
2847
02:00:11,099 --> 02:00:12,099
this is just R Cube which is our model
2848
02:00:14,060 --> 02:00:15,060
however we don't have an actual bound so
2849
02:00:17,840 --> 02:00:18,840
our code won't really be able to know
2850
02:00:22,500 --> 02:00:23,500
when to actually call on actor begin
2851
02:00:24,780 --> 02:00:25,780
overlap so even if I disable Collision
2852
02:00:27,360 --> 02:00:28,360
so the way you do that is you can head
2853
02:00:30,239 --> 02:00:31,239
over here
2854
02:00:31,260 --> 02:00:32,260
and from physics actor you could go
2855
02:00:34,260 --> 02:00:35,260
ahead and change it but we do need
2856
02:00:35,699 --> 02:00:36,699
physics so we can't do that even if we
2857
02:00:37,920 --> 02:00:38,920
actually bump into this you won't really
2858
02:00:40,139 --> 02:00:41,139
notice anything happen so if I go ahead
2859
02:00:42,540 --> 02:00:43,540
and bump it to this nothing is really
2860
02:00:44,520 --> 02:00:45,520
going to happen
2861
02:00:46,080 --> 02:00:47,080
now if I actually go ahead and creates a
2862
02:00:49,500 --> 02:00:50,500
bound so the way you do that is right
2863
02:00:51,900 --> 02:00:52,900
click or rather go to add and you can
2864
02:00:54,780 --> 02:00:55,780
type in a sphere I believe
2865
02:00:58,020 --> 02:00:59,020
sphere Collision yes
2866
02:01:00,119 --> 02:01:01,119
so when you create a sphere Collision we
2867
02:01:02,099 --> 02:01:03,099
could call this one bounds
2868
02:01:03,780 --> 02:01:04,780
you would have created a sphere and you
2869
02:01:06,239 --> 02:01:07,239
can't see that because the size is too
2870
02:01:07,739 --> 02:01:08,739
small can go ahead and increase the
2871
02:01:09,119 --> 02:01:10,119
sphere radius
2872
02:01:10,440 --> 02:01:11,440
now these are our bounds so as soon as
2873
02:01:13,619 --> 02:01:14,619
we enter this our on active begin
2874
02:01:15,900 --> 02:01:16,900
overlap will be triggered so we can go
2875
02:01:18,000 --> 02:01:19,000
ahead and print it
2876
02:01:19,380 --> 02:01:20,380
and if you were to notice the Collision
2877
02:01:21,360 --> 02:01:22,360
preset over here under the details panel
2878
02:01:23,699 --> 02:01:24,699
select this and head into your Collision
2879
02:01:26,340 --> 02:01:27,340
preset you see it says overlap all
2880
02:01:29,099 --> 02:01:30,099
Dynamic and obviously if you select
2881
02:01:31,440 --> 02:01:32,440
custom you can go ahead and edit each
2882
02:01:33,480 --> 02:01:34,480
Channel and we will talk about this
2883
02:01:35,340 --> 02:01:36,340
later
2884
02:01:36,119 --> 02:01:37,119
so if I go ahead and press play
2885
02:01:38,340 --> 02:01:39,340
you see we get hello every time we
2886
02:01:40,380 --> 02:01:41,380
overlap it
2887
02:01:41,720 --> 02:01:42,720
[Music]
2888
02:01:46,199 --> 02:01:47,199
now hello is going to be printed every
2889
02:01:48,780 --> 02:01:49,780
time any other actor overlaps this
2890
02:01:51,179 --> 02:01:52,179
however we want to print hello only if a
2891
02:01:55,260 --> 02:01:56,260
character overlaps it and it need not be
2892
02:01:58,560 --> 02:01:59,560
a character as well now in unreal
2893
02:02:01,260 --> 02:02:02,260
character is actually a derived class of
2894
02:02:04,500 --> 02:02:05,500
another class known as pawn and I will
2895
02:02:07,020 --> 02:02:08,020
talk a little more in depth about this
2896
02:02:08,880 --> 02:02:09,880
right now so basically this is how it's
2897
02:02:11,639 --> 02:02:12,639
laid out in unreal basically we are
2898
02:02:13,500 --> 02:02:14,500
looking for a pawn and I will get to
2899
02:02:16,500 --> 02:02:17,500
that in just about a minute so we can
2900
02:02:19,080 --> 02:02:20,080
type in pawn and if you were to scroll
2901
02:02:21,840 --> 02:02:22,840
down you would see cast to pawn so cast
2902
02:02:25,020 --> 02:02:26,020
is another programming feature now if
2903
02:02:28,560 --> 02:02:29,560
you were to feed in an object to this
2904
02:02:31,380 --> 02:02:32,380
you can check whether it is upon object
2905
02:02:35,179 --> 02:02:36,179
so now if I go ahead and print this out
2906
02:02:39,659 --> 02:02:40,659
now uh you would go ahead and actually
2907
02:02:43,320 --> 02:02:44,320
get hello just normally
2908
02:02:46,260 --> 02:02:47,260
the reason is when you are actually
2909
02:02:48,900 --> 02:02:49,900
controlling your camera over here
2910
02:02:51,599 --> 02:02:52,599
you are actually controlling a pawn
2911
02:02:54,119 --> 02:02:55,119
actor
2912
02:02:55,440 --> 02:02:56,440
anything that can be possessed by a
2913
02:02:59,280 --> 02:03:00,280
player controller is known as a pawn and
2914
02:03:01,980 --> 02:03:02,980
we will talk a little more in depth
2915
02:03:03,599 --> 02:03:04,599
right now and just to clear your doubts
2916
02:03:06,780 --> 02:03:07,780
on whether this logic actually work
2917
02:03:09,239 --> 02:03:10,239
let's say it wasn't a pawn so which
2918
02:03:11,760 --> 02:03:12,760
means it's not a player basically so if
2919
02:03:14,219 --> 02:03:15,219
I copy this over and instead of hello
2920
02:03:16,080 --> 02:03:17,080
let's just print not player
2921
02:03:19,619 --> 02:03:20,619
and now if I go ahead and press play
2922
02:03:23,400 --> 02:03:24,400
you'd see you won't get anything
2923
02:03:25,560 --> 02:03:26,560
and if I overlap it it says hello but if
2924
02:03:29,460 --> 02:03:30,460
I go ahead and copy this over and let's
2925
02:03:32,159 --> 02:03:33,159
say I keep it above this and if I press
2926
02:03:34,560 --> 02:03:35,560
play you see you get not player printed
2927
02:03:37,380 --> 02:03:38,380
that is because
2928
02:03:39,239 --> 02:03:40,239
the Box overlapped another box
2929
02:03:42,480 --> 02:03:43,480
or rather RBP pickup overlapped another
2930
02:03:45,119 --> 02:03:46,119
BP pickup however those are not
2931
02:03:48,300 --> 02:03:49,300
characters so this cast right here
2932
02:03:50,460 --> 02:03:51,460
failed because the object which came
2933
02:03:53,820 --> 02:03:54,820
from this actor begin overlap was not a
2934
02:03:56,760 --> 02:03:57,760
pawn hence we got not player printed
2935
02:04:00,119 --> 02:04:01,119
foreign
2936
02:04:07,219 --> 02:04:08,219
part of the course I'll just tell you
2937
02:04:09,840 --> 02:04:10,840
guys the most basic form of inheritance
2938
02:04:13,139 --> 02:04:14,139
hierarchy which is there and unreal
2939
02:04:14,820 --> 02:04:15,820
however once we get to the more advanced
2940
02:04:17,159 --> 02:04:18,159
part I will tell you guys more in depth
2941
02:04:19,020 --> 02:04:20,020
but as far as what you guys need to know
2942
02:04:21,179 --> 02:04:22,179
so at the base level the most simplest
2943
02:04:23,580 --> 02:04:24,580
type of class from which you can
2944
02:04:25,139 --> 02:04:26,139
instantiate objects is known as object
2945
02:04:27,480 --> 02:04:28,480
in Blueprint so object is the simplest
2946
02:04:30,300 --> 02:04:31,300
type and from that the most basic one
2947
02:04:33,540 --> 02:04:34,540
which you can create is going to be an
2948
02:04:35,400 --> 02:04:36,400
actor now an actor is basically an
2949
02:04:37,920 --> 02:04:38,920
object which has a transform and can be
2950
02:04:40,020 --> 02:04:41,020
placed in the level as you would have
2951
02:04:41,880 --> 02:04:42,880
figured by now now under this you have
2952
02:04:44,580 --> 02:04:45,580
various other classes however for the
2953
02:04:48,599 --> 02:04:49,599
most basic level we are going to be
2954
02:04:50,940 --> 02:04:51,940
considering only two
2955
02:04:52,739 --> 02:04:53,739
so there are many more and we will talk
2956
02:04:55,380 --> 02:04:56,380
about many others where once we actually
2957
02:04:58,139 --> 02:04:59,139
come to the advanced part but these are
2958
02:05:00,420 --> 02:05:01,420
the two which you do require to get up
2959
02:05:02,460 --> 02:05:03,460
and running so the first one under this
2960
02:05:05,340 --> 02:05:06,340
is going to be your controller
2961
02:05:08,580 --> 02:05:09,580
so a controller as the name suggests is
2962
02:05:11,760 --> 02:05:12,760
a class which has functionality for your
2963
02:05:15,420 --> 02:05:16,420
built-in to take player input and stuff
2964
02:05:17,820 --> 02:05:18,820
like that
2965
02:05:18,780 --> 02:05:19,780
and under controller you also have a
2966
02:05:21,719 --> 02:05:22,719
special type known as a player
2967
02:05:23,520 --> 02:05:24,520
controller and there are others such as
2968
02:05:25,260 --> 02:05:26,260
AI controller so you have a player
2969
02:05:28,139 --> 02:05:29,139
controller so player
2970
02:05:30,659 --> 02:05:31,659
and I'm just going to put this so play a
2971
02:05:33,960 --> 02:05:34,960
controller
2972
02:05:35,219 --> 02:05:36,219
now a player controller is basically a
2973
02:05:37,679 --> 02:05:38,679
controller which belongs to an actual
2974
02:05:40,860 --> 02:05:41,860
player you also have other things such
2975
02:05:43,199 --> 02:05:44,199
as AI controllers which is assigned to
2976
02:05:46,500 --> 02:05:47,500
CPU players basically so if you have
2977
02:05:50,340 --> 02:05:51,340
enemies in game for an offline game or
2978
02:05:52,739 --> 02:05:53,739
something you design an AI controller
2979
02:05:55,080 --> 02:05:56,080
now another class that you'll need is
2980
02:05:57,780 --> 02:05:58,780
pun and that's what we talked about so
2981
02:06:00,599 --> 02:06:01,599
this is called Pawn now a pawn is
2982
02:06:03,900 --> 02:06:04,900
basically
2983
02:06:04,920 --> 02:06:05,920
a class
2984
02:06:06,540 --> 02:06:07,540
which is an actor obviously and can be
2985
02:06:09,540 --> 02:06:10,540
placed in the level and note that you
2986
02:06:11,159 --> 02:06:12,159
cannot place a controller in a level
2987
02:06:13,080 --> 02:06:14,080
although it is derived from actor it is
2988
02:06:15,000 --> 02:06:16,000
actually an exception controllers player
2989
02:06:17,520 --> 02:06:18,520
States game states there are a few other
2990
02:06:19,199 --> 02:06:20,199
classes which are exceptions and you
2991
02:06:20,940 --> 02:06:21,940
can't place them in the level however
2992
02:06:22,860 --> 02:06:23,860
pawns can be placed in the level and a
2993
02:06:25,619 --> 02:06:26,619
pawn is always possessed by a player
2994
02:06:28,139 --> 02:06:29,139
controller so a player controller is
2995
02:06:30,659 --> 02:06:31,659
going to be possessing a pawn so when
2996
02:06:33,239 --> 02:06:34,239
you call the possess function and you
2997
02:06:36,480 --> 02:06:37,480
give the target as a pawn you are going
2998
02:06:38,940 --> 02:06:39,940
to be possessing the pawn and one
2999
02:06:41,159 --> 02:06:42,159
special type of Pawn which has a lot of
3000
02:06:43,440 --> 02:06:44,440
functionality built in for us already
3001
02:06:46,020 --> 02:06:47,020
is called a character most of the times
3002
02:06:49,020 --> 02:06:50,020
you will be working with characters and
3003
02:06:51,060 --> 02:06:52,060
not puns however you can use puns so by
3004
02:06:55,020 --> 02:06:56,020
character I mean a character such as a
3005
02:06:58,679 --> 02:06:59,679
living being basically so generally if
3006
02:07:01,440 --> 02:07:02,440
you have like a human or if you have
3007
02:07:03,719 --> 02:07:04,719
like an animal or something like that
3008
02:07:05,219 --> 02:07:06,219
you would generally use characters
3009
02:07:06,800 --> 02:07:07,800
however if you have something like a
3010
02:07:08,820 --> 02:07:09,820
vehicle you would usually stay away from
3011
02:07:11,099 --> 02:07:12,099
characters because it has some
3012
02:07:12,540 --> 02:07:13,540
properties which are not realistic for
3013
02:07:15,060 --> 02:07:16,060
those however it is completely possible
3014
02:07:17,760 --> 02:07:18,760
to use a character class for something
3015
02:07:19,980 --> 02:07:20,980
like a vehicle as well so you can
3016
02:07:22,080 --> 02:07:23,080
possess a character as well there is no
3017
02:07:24,599 --> 02:07:25,599
harm in that pawn or any derived class
3018
02:07:27,179 --> 02:07:28,179
of Pawn can be possessed by a player
3019
02:07:29,940 --> 02:07:30,940
controller
3020
02:07:31,020 --> 02:07:32,020
foreign
3021
02:07:39,619 --> 02:07:40,619
we can go ahead and actually create our
3022
02:07:42,360 --> 02:07:43,360
own character class or I should rather
3023
02:07:44,580 --> 02:07:45,580
say Pawn class which is also a character
3024
02:07:46,739 --> 02:07:47,739
class in our case so we can create that
3025
02:07:49,440 --> 02:07:50,440
as well as a player controller and I'll
3026
02:07:51,960 --> 02:07:52,960
show you guys how to set those and how
3027
02:07:54,420 --> 02:07:55,420
we can go about interacting with this
3028
02:07:57,060 --> 02:07:58,060
pickup using those so right click go
3029
02:07:59,580 --> 02:08:00,580
ahead and create blueprint class and as
3030
02:08:01,320 --> 02:08:02,320
you would see you have character and
3031
02:08:02,580 --> 02:08:03,580
clear controller right here because they
3032
02:08:04,440 --> 02:08:05,440
are really really common
3033
02:08:06,060 --> 02:08:07,060
so type in character and let's just type
3034
02:08:08,880 --> 02:08:09,880
in BP underscore character
3035
02:08:13,739 --> 02:08:14,739
again you can you can name it
3036
02:08:15,599 --> 02:08:16,599
appropriately or as per your wish
3037
02:08:18,119 --> 02:08:19,119
now if I go ahead and open it up you see
3038
02:08:21,540 --> 02:08:22,540
this looks a little more different and
3039
02:08:23,159 --> 02:08:24,159
it already has something set up for us
3040
02:08:25,699 --> 02:08:26,699
and some of these are quite handy
3041
02:08:28,199 --> 02:08:29,199
especially the character movement
3042
02:08:29,880 --> 02:08:30,880
component which is there and if I
3043
02:08:32,580 --> 02:08:33,580
haven't mentioned yet whatever we did
3044
02:08:34,860 --> 02:08:35,860
here
3045
02:08:35,760 --> 02:08:36,760
under the component step these are
3046
02:08:37,860 --> 02:08:38,860
called components basically basically
3047
02:08:40,139 --> 02:08:41,139
every actor is made up of several
3048
02:08:42,900 --> 02:08:43,900
components and you can actually create
3049
02:08:45,360 --> 02:08:46,360
your own components as well and make
3050
02:08:47,400 --> 02:08:48,400
them behave as you wish but as of now
3051
02:08:50,280 --> 02:08:51,280
just know that these are just
3052
02:08:52,340 --> 02:08:53,340
constituents of these this actor and
3053
02:08:56,159 --> 02:08:57,159
these are the constituents of BP pickup
3054
02:08:59,340 --> 02:09:00,340
and this is these are the constituents
3055
02:09:01,320 --> 02:09:02,320
of BP character basically now we haven't
3056
02:09:03,540 --> 02:09:04,540
set a mesh and we don't really have one
3057
02:09:06,540 --> 02:09:07,540
so let's just take okay we have
3058
02:09:09,540 --> 02:09:10,540
a character tutorial PPP and one thing
3059
02:09:13,080 --> 02:09:14,080
to note this Arrow actually represents
3060
02:09:15,300 --> 02:09:16,300
the forward direction of the character
3061
02:09:16,920 --> 02:09:17,920
so you can go ahead and move it down
3062
02:09:19,920 --> 02:09:20,920
and you can go ahead and rotate it 90
3063
02:09:22,199 --> 02:09:23,199
degrees so let let me have snapping
3064
02:09:23,880 --> 02:09:24,880
enabled
3065
02:09:25,679 --> 02:09:26,679
so rotate it by negative 90 and you can
3066
02:09:29,340 --> 02:09:30,340
go ahead and bring him all the way down
3067
02:09:31,739 --> 02:09:32,739
until I feel it's correct
3068
02:09:35,040 --> 02:09:36,040
now we don't have any animations but I'm
3069
02:09:37,560 --> 02:09:38,560
not really sure if we do have an
3070
02:09:39,480 --> 02:09:40,480
animation blueprint for him
3071
02:09:41,340 --> 02:09:42,340
so let's just check
3072
02:09:43,679 --> 02:09:44,679
tutorial animation blueprint I guess
3073
02:09:46,739 --> 02:09:47,739
tutorial animation blueprint so yeah we
3074
02:09:50,280 --> 02:09:51,280
do have an animation blueprint for him
3075
02:09:53,099 --> 02:09:54,099
now if you want to change the default
3076
02:09:56,280 --> 02:09:57,280
character that you will be using the way
3077
02:09:58,560 --> 02:09:59,560
you'll do that is by first of all
3078
02:10:00,840 --> 02:10:01,840
heading into Window World settings make
3079
02:10:03,179 --> 02:10:04,179
sure that is enabled and then over here
3080
02:10:05,219 --> 02:10:06,219
on the right hand side head into World
3081
02:10:07,500 --> 02:10:08,500
settings and under game mode override
3082
02:10:09,719 --> 02:10:10,719
you can go ahead and set your own game
3083
02:10:12,060 --> 02:10:13,060
mode now if I were to just select game
3084
02:10:14,099 --> 02:10:15,099
mode I still cannot edit it so I will
3085
02:10:17,580 --> 02:10:18,580
get to Game Mode classes later on
3086
02:10:19,500 --> 02:10:20,500
because they are not that important but
3087
02:10:21,599 --> 02:10:22,599
for now you can just go ahead and create
3088
02:10:23,520 --> 02:10:24,520
a new game mode and it could be of type
3089
02:10:25,920 --> 02:10:26,920
game mode base or it could be of type
3090
02:10:27,840 --> 02:10:28,840
game mode it doesn't really matter but I
3091
02:10:30,540 --> 02:10:31,540
would suggest sticking with game mode
3092
02:10:32,040 --> 02:10:33,040
base
3093
02:10:33,239 --> 02:10:34,239
and let's just call this one uh BP
3094
02:10:36,599 --> 02:10:37,599
underscore game mode
3095
02:10:38,639 --> 02:10:39,639
uh I just did something there
3096
02:10:41,699 --> 02:10:42,699
so yeah BP underscore game mode
3097
02:10:46,440 --> 02:10:47,440
that's what we'll call it and now under
3098
02:10:48,659 --> 02:10:49,659
this we will get our option to select
3099
02:10:50,639 --> 02:10:51,639
the game mode now since this is our
3100
02:10:52,800 --> 02:10:53,800
custom or custom made game mode we get
3101
02:10:55,440 --> 02:10:56,440
the option to select the default Pawn
3102
02:10:57,300 --> 02:10:58,300
class and over here we can select our BP
3103
02:11:00,300 --> 02:11:01,300
character and if I save everything and
3104
02:11:03,119 --> 02:11:04,119
if I go ahead and press play you would
3105
02:11:05,040 --> 02:11:06,040
see that we have indeed possessed our
3106
02:11:08,099 --> 02:11:09,099
character and you were to notice that
3107
02:11:11,699 --> 02:11:12,699
the camera is a bit off
3108
02:11:14,280 --> 02:11:15,280
so what you can do is you can actually
3109
02:11:16,619 --> 02:11:17,619
create a camera
3110
02:11:18,719 --> 02:11:19,719
if I go ahead and type in camera under
3111
02:11:21,060 --> 02:11:22,060
the component section
3112
02:11:22,739 --> 02:11:23,739
you can create a camera and you can
3113
02:11:25,560 --> 02:11:26,560
align it as per your requirement so this
3114
02:11:28,860 --> 02:11:29,860
should be about correct
3115
02:11:31,500 --> 02:11:32,500
so I feel rotating this a bit maybe a
3116
02:11:35,219 --> 02:11:36,219
bit back maybe a bit to the side would
3117
02:11:37,020 --> 02:11:38,020
be nice
3118
02:11:38,520 --> 02:11:39,520
so there you have it so this is our
3119
02:11:40,980 --> 02:11:41,980
character
3120
02:11:42,119 --> 02:11:43,119
however we are not actually able to move
3121
02:11:45,300 --> 02:11:46,300
the reason is we haven't actually
3122
02:11:47,639 --> 02:11:48,639
written the code for it to take our
3123
02:11:50,280 --> 02:11:51,280
input
3124
02:11:51,360 --> 02:11:52,360
Now setting up input in unreal is really
3125
02:11:55,080 --> 02:11:56,080
really easy and I will show you guys the
3126
02:11:57,780 --> 02:11:58,780
brute force method as well as the proper
3127
02:12:00,000 --> 02:12:01,000
way to do it so The Brood force method
3128
02:12:02,159 --> 02:12:03,159
is for example we want W to be able to
3129
02:12:04,980 --> 02:12:05,980
make us move forward so I can press W
3130
02:12:07,380 --> 02:12:08,380
and if you just give a space and type in
3131
02:12:09,599 --> 02:12:10,599
keyboard
3132
02:12:10,920 --> 02:12:11,920
you would be able to get W and we can
3133
02:12:13,260 --> 02:12:14,260
make the character move forward
3134
02:12:15,239 --> 02:12:16,239
so in order to make your character move
3135
02:12:18,599 --> 02:12:19,599
basically there's a function for us
3136
02:12:20,699 --> 02:12:21,699
built in already under the character
3137
02:12:22,619 --> 02:12:23,619
movement and not character movement I
3138
02:12:25,440 --> 02:12:26,440
believe it's there in our Pawn class I
3139
02:12:27,540 --> 02:12:28,540
believe or a character class so if you
3140
02:12:29,219 --> 02:12:30,219
right click and type in add movement
3141
02:12:31,920 --> 02:12:32,920
input
3142
02:12:33,119 --> 02:12:34,119
so it's written in our Pawn class we can
3143
02:12:35,340 --> 02:12:36,340
go ahead and make him move
3144
02:12:37,860 --> 02:12:38,860
and if you were to notice we have to
3145
02:12:40,440 --> 02:12:41,440
provide a direction and a scale value
3146
02:12:42,320 --> 02:12:43,320
scale value is useful if you are on a
3147
02:12:45,300 --> 02:12:46,300
joystick or something where you can
3148
02:12:47,340 --> 02:12:48,340
partially press down so let's say you're
3149
02:12:49,440 --> 02:12:50,440
halfway pushing the joystick uh
3150
02:12:52,980 --> 02:12:53,980
knob so in that case it would be 0.5 so
3151
02:12:57,179 --> 02:12:58,179
the scale value can be given through an
3152
02:12:59,460 --> 02:13:00,460
axis value
3153
02:13:00,719 --> 02:13:01,719
now if you were to notice ah there is
3154
02:13:03,840 --> 02:13:04,840
another problem here when I actually
3155
02:13:06,480 --> 02:13:07,480
plug this in
3156
02:13:07,800 --> 02:13:08,800
it's not really going to work as you
3157
02:13:09,900 --> 02:13:10,900
would expect so for our direction we
3158
02:13:12,179 --> 02:13:13,179
need the forward direction of the
3159
02:13:14,099 --> 02:13:15,099
character so a very simple way to do
3160
02:13:16,380 --> 02:13:17,380
that is typing in get forward Vector so
3161
02:13:19,139 --> 02:13:20,139
get actor forward vector
3162
02:13:21,360 --> 02:13:22,360
so get actor forward Vector so that's
3163
02:13:24,119 --> 02:13:25,119
the way you would actually get the word
3164
02:13:25,560 --> 02:13:26,560
Direction that's how you do it
3165
02:13:28,260 --> 02:13:29,260
and if you were to notice
3166
02:13:30,480 --> 02:13:31,480
it's not going to work as expected at
3167
02:13:33,119 --> 02:13:34,119
all the reason is this has to be called
3168
02:13:36,239 --> 02:13:37,239
every frame in order to actually work
3169
02:13:39,000 --> 02:13:40,000
so the way you do it is Type in uh or
3170
02:13:43,800 --> 02:13:44,800
rather we can do it on event tick for
3171
02:13:45,900 --> 02:13:46,900
example
3172
02:13:46,860 --> 02:13:47,860
so if we go ahead and do it on event
3173
02:13:49,199 --> 02:13:50,199
tick I'm just doing this to show you
3174
02:13:50,880 --> 02:13:51,880
guys how to do it if I do this now we
3175
02:13:53,639 --> 02:13:54,639
would see that our character is moving
3176
02:13:55,920 --> 02:13:56,920
forward
3177
02:13:57,300 --> 02:13:58,300
now the most obvious question is how am
3178
02:14:00,360 --> 02:14:01,360
I actually going to set this up so there
3179
02:14:04,079 --> 02:14:05,079
is something known as an axis mapping
3180
02:14:06,239 --> 02:14:07,239
which runs every frame basically what
3181
02:14:08,280 --> 02:14:09,280
add movement input does is it moves you
3182
02:14:11,219 --> 02:14:12,219
a very very slight amount and by calling
3183
02:14:14,159 --> 02:14:15,159
this multiple times in a single second
3184
02:14:16,699 --> 02:14:17,699
you are going to be adding considerable
3185
02:14:19,619 --> 02:14:20,619
amount of movement now if I head into my
3186
02:14:22,619 --> 02:14:23,619
project settings
3187
02:14:24,060 --> 02:14:25,060
and under input this is the right way to
3188
02:14:26,579 --> 02:14:27,579
do it the Brute Force wave would have
3189
02:14:28,320 --> 02:14:29,320
been like doing this on tick and I'll
3190
02:14:30,900 --> 02:14:31,900
just show you this really shouldn't be
3191
02:14:32,940 --> 02:14:33,940
your option but I'll just show you just
3192
02:14:35,219 --> 02:14:36,219
in case so for example you could just
3193
02:14:37,440 --> 02:14:38,440
have a Boolean here and we could just
3194
02:14:40,139 --> 02:14:41,139
set this to true for example and when
3195
02:14:42,719 --> 02:14:43,719
you release it we could set this to
3196
02:14:44,280 --> 02:14:45,280
false
3197
02:14:45,239 --> 02:14:46,239
now this is wrong so don't really worry
3198
02:14:47,219 --> 02:14:48,219
about the logic this is just gonna work
3199
02:14:49,079 --> 02:14:50,079
but you shouldn't really do this so we
3200
02:14:52,380 --> 02:14:53,380
could do if new variable is true we want
3201
02:14:55,800 --> 02:14:56,800
to move otherwise we don't want to do
3202
02:14:57,780 --> 02:14:58,780
anything
3203
02:14:58,739 --> 02:14:59,739
so if I go ahead and press play I can
3204
02:15:00,659 --> 02:15:01,659
press W and move but as soon as I
3205
02:15:02,940 --> 02:15:03,940
release it I'm going to stop this is the
3206
02:15:04,860 --> 02:15:05,860
Brute Force way to do it but unreal has
3207
02:15:07,139 --> 02:15:08,139
a much more elegant system to do it so
3208
02:15:09,119 --> 02:15:10,119
we can go ahead and delete all of this
3209
02:15:12,179 --> 02:15:13,179
head into our project settings once
3210
02:15:14,159 --> 02:15:15,159
again
3211
02:15:15,420 --> 02:15:16,420
and under input you would see action and
3212
02:15:17,820 --> 02:15:18,820
access mappings
3213
02:15:19,260 --> 02:15:20,260
now we want an axis mapping because we
3214
02:15:22,260 --> 02:15:23,260
do want to be able to control the scale
3215
02:15:24,239 --> 02:15:25,239
and since add movement input is actually
3216
02:15:27,119 --> 02:15:28,119
a function which depends on the scale
3217
02:15:30,119 --> 02:15:31,119
value so remember what I told you about
3218
02:15:32,280 --> 02:15:33,280
the joystick so we can create an access
3219
02:15:34,980 --> 02:15:35,980
mapping so for things such as jump where
3220
02:15:37,619 --> 02:15:38,619
there is no scale value so it's either
3221
02:15:39,619 --> 02:15:40,619
jumping or not jumping so wherever you
3222
02:15:42,179 --> 02:15:43,179
have a toggle you would have an action
3223
02:15:43,739 --> 02:15:44,739
mapping wherever you you have some value
3224
02:15:47,219 --> 02:15:48,219
which goes linearly you would have an
3225
02:15:49,079 --> 02:15:50,079
access mapping so we can call this one
3226
02:15:51,540 --> 02:15:52,540
move forward
3227
02:15:54,500 --> 02:15:55,500
and
3228
02:15:56,400 --> 02:15:57,400
make that Pascal case and we could have
3229
02:15:58,560 --> 02:15:59,560
W on the keyboard for that and again
3230
02:16:02,460 --> 02:16:03,460
for move backward we could reuse this
3231
02:16:04,800 --> 02:16:05,800
actually so s is going to be moved
3232
02:16:07,199 --> 02:16:08,199
backward
3233
02:16:08,520 --> 02:16:09,520
and for the scale value you can make
3234
02:16:10,500 --> 02:16:11,500
this negative one
3235
02:16:12,480 --> 02:16:13,480
now if I right click over here and if I
3236
02:16:16,020 --> 02:16:17,020
type in move forward
3237
02:16:18,599 --> 02:16:19,599
you would notice that we have an axis
3238
02:16:21,780 --> 02:16:22,780
mapping
3239
02:16:23,760 --> 02:16:24,760
so if I grab this into this input event
3240
02:16:27,659 --> 02:16:28,659
or rather if I bring this into this axis
3241
02:16:30,420 --> 02:16:31,420
move forward event and for the scale
3242
02:16:32,580 --> 02:16:33,580
value if I put this under access value
3243
02:16:34,500 --> 02:16:35,500
now this will work exactly as I would
3244
02:16:37,260 --> 02:16:38,260
want it to so if I go ahead and press W
3245
02:16:39,300 --> 02:16:40,300
it's going to work and even s is going
3246
02:16:41,460 --> 02:16:42,460
to work now for us
3247
02:16:43,139 --> 02:16:44,139
so this is basically how you do access
3248
02:16:45,719 --> 02:16:46,719
mappings similarly you could do it for
3249
02:16:48,420 --> 02:16:49,420
move right
3250
02:16:49,559 --> 02:16:50,559
so we could have move right or we could
3251
02:16:51,899 --> 02:16:52,899
call it move sideways
3252
02:16:54,840 --> 02:16:55,840
and we'd have our A and D keys so we
3253
02:16:58,200 --> 02:16:59,200
have our a key and we have our D key so
3254
02:17:02,280 --> 02:17:03,280
D is going to be
3255
02:17:04,679 --> 02:17:05,679
this one and it's going to be negative
3256
02:17:07,080 --> 02:17:08,080
1.
3257
02:17:08,099 --> 02:17:09,099
so let's actually just test it out
3258
02:17:11,399 --> 02:17:12,399
so
3259
02:17:12,840 --> 02:17:13,840
it's not really doing anything because
3260
02:17:14,160 --> 02:17:15,160
we didn't set up the logic obviously so
3261
02:17:16,620 --> 02:17:17,620
move
3262
02:17:17,880 --> 02:17:18,880
sideways
3263
02:17:19,740 --> 02:17:20,740
whoops
3264
02:17:21,359 --> 02:17:22,359
axis
3265
02:17:22,800 --> 02:17:23,800
move sideways
3266
02:17:27,599 --> 02:17:28,599
so once you have the event set up you
3267
02:17:30,300 --> 02:17:31,300
can go ahead and add the movement input
3268
02:17:32,040 --> 02:17:33,040
and again you can get the right Vector
3269
02:17:34,500 --> 02:17:35,500
of the actor so basically the right
3270
02:17:36,240 --> 02:17:37,240
direction of the actor is going to be
3271
02:17:38,580 --> 02:17:39,580
your right Vector so your forward Vector
3272
02:17:42,059 --> 02:17:43,059
is always in this arrows Direction and
3273
02:17:44,399 --> 02:17:45,399
your right Vector is going to be a
3274
02:17:45,719 --> 02:17:46,719
vector in this direction basically
3275
02:17:47,939 --> 02:17:48,939
so right vector and if I go ahead and
3276
02:17:50,760 --> 02:17:51,760
press play
3277
02:17:52,200 --> 02:17:53,200
so it's always one so that's the reason
3278
02:17:54,540 --> 02:17:55,540
it's happening so
3279
02:17:56,280 --> 02:17:57,280
if I plug that into the axis value
3280
02:17:59,160 --> 02:18:00,160
I am moving reverse actually right now
3281
02:18:01,200 --> 02:18:02,200
so that's just a simple mistake I did
3282
02:18:03,899 --> 02:18:04,899
here so I can type in minus one for this
3283
02:18:06,660 --> 02:18:07,660
and I can type in plus one for this now
3284
02:18:09,000 --> 02:18:10,000
everything should work as expected so if
3285
02:18:10,979 --> 02:18:11,979
any of your directions are reversed just
3286
02:18:13,320 --> 02:18:14,320
multiply the access value by -1 now as
3287
02:18:16,260 --> 02:18:17,260
you can see we are able to move forward
3288
02:18:18,660 --> 02:18:19,660
left right and all of that good stuff
3289
02:18:22,679 --> 02:18:23,679
now that is about it for the keyboard
3290
02:18:25,200 --> 02:18:26,200
input however if you were to notice I
3291
02:18:27,660 --> 02:18:28,660
really can't rotate the character so
3292
02:18:29,820 --> 02:18:30,820
let's actually set that up first so
3293
02:18:32,340 --> 02:18:33,340
first things first head back into your
3294
02:18:34,139 --> 02:18:35,139
BP character and the functions which we
3295
02:18:37,320 --> 02:18:38,320
require to set up keyboard input I mean
3296
02:18:40,439 --> 02:18:41,439
Mouse input for a character is going to
3297
02:18:43,080 --> 02:18:44,080
be your controller pitch input and your
3298
02:18:46,200 --> 02:18:47,200
controller your input so controller
3299
02:18:48,120 --> 02:18:49,120
pitch input
3300
02:18:49,979 --> 02:18:50,979
and controller your input
3301
02:18:53,399 --> 02:18:54,399
so these are the functions that we need
3302
02:18:55,740 --> 02:18:56,740
now again since our Mouse needs to be
3303
02:18:59,280 --> 02:19:00,280
captured as much as possible because it
3304
02:19:02,820 --> 02:19:03,820
it has to detect every tiny movement so
3305
02:19:05,340 --> 02:19:06,340
we again need to create an axis mapping
3306
02:19:08,160 --> 02:19:09,160
so go ahead into inputs
3307
02:19:10,859 --> 02:19:11,859
and create two new access mappings and
3308
02:19:14,639 --> 02:19:15,639
call one
3309
02:19:15,899 --> 02:19:16,899
look around
3310
02:19:18,559 --> 02:19:19,559
and the next one call it look up
3311
02:19:24,120 --> 02:19:25,120
and for this look around is going to be
3312
02:19:26,280 --> 02:19:27,280
the x-axis of the mouse so type in Mouse
3313
02:19:28,260 --> 02:19:29,260
X
3314
02:19:29,580 --> 02:19:30,580
and for this one type in Mouse y
3315
02:19:33,479 --> 02:19:34,479
so that should be good
3316
02:19:35,519 --> 02:19:36,519
and over here
3317
02:19:38,099 --> 02:19:39,099
if I go back and if I type in Access
3318
02:19:44,399 --> 02:19:45,399
look around
3319
02:19:46,800 --> 02:19:47,800
and we can go ahead and add your input
3320
02:19:49,200 --> 02:19:50,200
over here
3321
02:19:50,700 --> 02:19:51,700
and over here access
3322
02:19:54,060 --> 02:19:55,060
lookup
3323
02:19:57,720 --> 02:19:58,720
oops I misspelled that
3324
02:20:02,760 --> 02:20:03,760
so head back into input so look up
3325
02:20:12,420 --> 02:20:13,420
now if I go ahead and compile this and
3326
02:20:15,840 --> 02:20:16,840
press play
3327
02:20:17,580 --> 02:20:18,580
you would see that I am able to look
3328
02:20:20,100 --> 02:20:21,100
around
3329
02:20:21,660 --> 02:20:22,660
however I really am not able to you know
3330
02:20:24,479 --> 02:20:25,479
look up and down
3331
02:20:26,100 --> 02:20:27,100
that's mostly because your character
3332
02:20:29,220 --> 02:20:30,220
isn't really meant to rotate along with
3333
02:20:32,100 --> 02:20:33,100
it so that's the reason it's happening
3334
02:20:34,859 --> 02:20:35,859
so if I head into my camera and enable
3335
02:20:38,160 --> 02:20:39,160
use spawn control rotation and if I
3336
02:20:40,680 --> 02:20:41,680
press play you see I am able to rotate
3337
02:20:43,560 --> 02:20:44,560
my camera
3338
02:20:44,760 --> 02:20:45,760
however there's one small problem here
3339
02:20:47,160 --> 02:20:48,160
we are again uh doing it reverse
3340
02:20:50,880 --> 02:20:51,880
so again in that case as I told you guys
3341
02:20:53,760 --> 02:20:54,760
before just change the scale value to
3342
02:20:56,280 --> 02:20:57,280
negative 1.
3343
02:20:58,500 --> 02:20:59,500
now if I go ahead and press play you
3344
02:21:01,560 --> 02:21:02,560
would be able to see that our camera is
3345
02:21:04,439 --> 02:21:05,439
working as expected now there is one
3346
02:21:07,439 --> 02:21:08,439
slight issue though
3347
02:21:08,880 --> 02:21:09,880
that is
3348
02:21:10,620 --> 02:21:11,620
uh our view is kind of off which you can
3349
02:21:13,319 --> 02:21:14,319
fix
3350
02:21:14,640 --> 02:21:15,640
but when we actually look up our
3351
02:21:17,640 --> 02:21:18,640
character doesn't seem to be looking up
3352
02:21:20,040 --> 02:21:21,040
but the reason that's not happening is
3353
02:21:22,560 --> 02:21:23,560
because you can't just rotate the whole
3354
02:21:24,479 --> 02:21:25,479
character now if I were to actually go
3355
02:21:27,000 --> 02:21:28,000
to this uh main tab over here under BP
3356
02:21:30,060 --> 02:21:31,060
character
3357
02:21:31,260 --> 02:21:32,260
and if I search for control rotation so
3358
02:21:34,500 --> 02:21:35,500
if I type in control rotation
3359
02:21:36,660 --> 02:21:37,660
and if I enable it to use pitch
3360
02:21:40,080 --> 02:21:41,080
you would actually see
3361
02:21:42,060 --> 02:21:43,060
that I am in fact able to do that but
3362
02:21:45,060 --> 02:21:46,060
there is a small problem now if I hit f8
3363
02:21:47,700 --> 02:21:48,700
to unpossess my character you see he
3364
02:21:50,460 --> 02:21:51,460
just rotates like that however we want
3365
02:21:52,200 --> 02:21:53,200
only his spine to rotate and that is
3366
02:21:54,780 --> 02:21:55,780
something which we have to set up using
3367
02:21:56,280 --> 02:21:57,280
an animation blueprint which we will do
3368
02:21:58,140 --> 02:21:59,140
later so for now we'll just disable this
3369
02:22:00,780 --> 02:22:01,780
and even for the yaw part you could you
3370
02:22:04,020 --> 02:22:05,020
could disable this and
3371
02:22:07,200 --> 02:22:08,200
you could technically do something like
3372
02:22:09,240 --> 02:22:10,240
this and maybe set up some other logic
3373
02:22:12,240 --> 02:22:13,240
in order to actually rotate your
3374
02:22:13,800 --> 02:22:14,800
character but for our purposes we'll
3375
02:22:15,359 --> 02:22:16,359
only do it for the pitch
3376
02:22:18,300 --> 02:22:19,300
another tiny thing that I would love to
3377
02:22:20,880 --> 02:22:21,880
cover here is how do you actually set up
3378
02:22:23,220 --> 02:22:24,220
different sensitivities because
3379
02:22:25,740 --> 02:22:26,740
obviously right now
3380
02:22:27,899 --> 02:22:28,899
the current sensitivity may be a little
3381
02:22:30,240 --> 02:22:31,240
too much for some for some maybe it's a
3382
02:22:32,880 --> 02:22:33,880
little too less
3383
02:22:34,020 --> 02:22:35,020
so the way you do that
3384
02:22:35,880 --> 02:22:36,880
is just multiply this axis value by your
3385
02:22:39,359 --> 02:22:40,359
sensitivity value that's basically how
3386
02:22:41,399 --> 02:22:42,399
you do it
3387
02:22:42,479 --> 02:22:43,479
so multiply this
3388
02:22:44,640 --> 02:22:45,640
and multiply this as well press Ctrl D
3389
02:22:47,340 --> 02:22:48,340
to duplicate that
3390
02:22:49,380 --> 02:22:50,380
now we could just promote this to a
3391
02:22:51,720 --> 02:22:52,720
variable however remember that this BP
3392
02:22:55,260 --> 02:22:56,260
character refers to only the character
3393
02:22:57,600 --> 02:22:58,600
which we are playing so let's say we are
3394
02:22:59,580 --> 02:23:00,580
playing a death match or something where
3395
02:23:01,859 --> 02:23:02,859
your character dies and you respawn with
3396
02:23:03,780 --> 02:23:04,780
a new character you would have to pass
3397
02:23:05,700 --> 02:23:06,700
in the variable every time so instead of
3398
02:23:09,060 --> 02:23:10,060
doing this we are going to set this up
3399
02:23:11,280 --> 02:23:12,280
in a class which will be common
3400
02:23:14,939 --> 02:23:15,939
even when your character is destroyed so
3401
02:23:18,840 --> 02:23:19,840
the class which we'll use and as you
3402
02:23:21,780 --> 02:23:22,780
would expect is called player controller
3403
02:23:24,960 --> 02:23:25,960
so go ahead and create BP player
3404
02:23:27,180 --> 02:23:28,180
controller
3405
02:23:30,120 --> 02:23:31,120
so make sure everything is in Pascal
3406
02:23:32,340 --> 02:23:33,340
case
3407
02:23:33,720 --> 02:23:34,720
now if you open this up now over here we
3408
02:23:36,359 --> 02:23:37,359
can go ahead and create a variable and
3409
02:23:38,100 --> 02:23:39,100
call this one sensitivity
3410
02:23:41,819 --> 02:23:42,819
and now uh this is going to be of type
3411
02:23:44,100 --> 02:23:45,100
float obviously
3412
02:23:45,720 --> 02:23:46,720
and let's make this one private and
3413
02:23:48,660 --> 02:23:49,660
let's create a method to get the
3414
02:23:50,460 --> 02:23:51,460
sensitivity
3415
02:23:54,060 --> 02:23:55,060
now this player controller is going to
3416
02:23:56,280 --> 02:23:57,280
be persistent even after your character
3417
02:23:59,100 --> 02:24:00,100
dies so that's the reason we're using it
3418
02:24:01,319 --> 02:24:02,319
and since we need the immediate value
3419
02:24:03,240 --> 02:24:04,240
this will be pure and for the return
3420
02:24:05,700 --> 02:24:06,700
value we are just going to return the
3421
02:24:07,800 --> 02:24:08,800
sensitivity
3422
02:24:09,720 --> 02:24:10,720
now obviously the reason we're doing it
3423
02:24:12,240 --> 02:24:13,240
this way is you don't want an external
3424
02:24:15,000 --> 02:24:16,000
entity to actually modify sensitivity
3425
02:24:17,640 --> 02:24:18,640
that would be crazy
3426
02:24:19,380 --> 02:24:20,380
and one more thing make sure you set
3427
02:24:21,120 --> 02:24:22,120
this value to anything other than zero
3428
02:24:23,160 --> 02:24:24,160
because if it's zero your mouse
3429
02:24:24,540 --> 02:24:25,540
obviously will not move so maybe
3430
02:24:26,520 --> 02:24:27,520
something like 0.5
3431
02:24:29,700 --> 02:24:30,700
so once that's done I should be able to
3432
02:24:32,520 --> 02:24:33,520
set my player controller first of all
3433
02:24:35,100 --> 02:24:36,100
over here in your game mode override for
3434
02:24:37,200 --> 02:24:38,200
your BP game mode go ahead and change
3435
02:24:39,060 --> 02:24:40,060
your black controller to the one you
3436
02:24:40,560 --> 02:24:41,560
created
3437
02:24:42,540 --> 02:24:43,540
save that and open up your BP character
3438
02:24:45,560 --> 02:24:46,560
and now
3439
02:24:47,399 --> 02:24:48,399
on begin play what we can do is we can
3440
02:24:50,340 --> 02:24:51,340
actually get our player controller so we
3441
02:24:52,560 --> 02:24:53,560
can type in get player controller
3442
02:24:56,340 --> 02:24:57,340
and we can cast this to our as you would
3443
02:25:00,120 --> 02:25:01,120
guess BP player controller so we are
3444
02:25:02,460 --> 02:25:03,460
getting our play controller and we are
3445
02:25:04,140 --> 02:25:05,140
checking if it is a BP player control
3446
02:25:06,300 --> 02:25:07,300
obviously we set it over there in the
3447
02:25:08,280 --> 02:25:09,280
game mode so it will be there is no
3448
02:25:10,319 --> 02:25:11,319
there's no way it's going to head into
3449
02:25:12,120 --> 02:25:13,120
cast field so we can just right click
3450
02:25:14,580 --> 02:25:15,580
and make this appear cast so this just
3451
02:25:16,859 --> 02:25:17,859
helps us save some space in the graph
3452
02:25:18,479 --> 02:25:19,479
this will be a success for sure and we
3453
02:25:21,240 --> 02:25:22,240
can go ahead and type in promote to
3454
02:25:22,859 --> 02:25:23,859
variable and we'll call this one pcrf
3455
02:25:26,340 --> 02:25:27,340
for player controller ref
3456
02:25:29,220 --> 02:25:30,220
now go ahead and compile that again you
3457
02:25:31,800 --> 02:25:32,800
can go ahead and make this one private
3458
02:25:33,479 --> 02:25:34,479
but honestly it doesn't matter in this
3459
02:25:35,460 --> 02:25:36,460
case
3460
02:25:36,540 --> 02:25:37,540
so on begin play we have gone ahead and
3461
02:25:39,000 --> 02:25:40,000
stored our player controller
3462
02:25:41,340 --> 02:25:42,340
and from our player controller object we
3463
02:25:43,680 --> 02:25:44,680
can go ahead and get the sensitivity
3464
02:25:46,979 --> 02:25:47,979
go ahead and get the sensitivity
3465
02:25:49,800 --> 02:25:50,800
go ahead and do the same thing over here
3466
02:25:52,800 --> 02:25:53,800
compile that
3467
02:25:54,180 --> 02:25:55,180
and if I go ahead and press play
3468
02:25:57,060 --> 02:25:58,060
you would see our sensitivity works and
3469
02:26:00,240 --> 02:26:01,240
not only that actually if I go ahead and
3470
02:26:02,760 --> 02:26:03,760
change the value so let's say I make
3471
02:26:04,620 --> 02:26:05,620
this point O one or rather point of 5
3472
02:26:08,100 --> 02:26:09,100
for example
3473
02:26:09,780 --> 02:26:10,780
0.01 would have been too less now as you
3474
02:26:12,359 --> 02:26:13,359
can see I can make very precise
3475
02:26:14,100 --> 02:26:15,100
movements
3476
02:26:15,479 --> 02:26:16,479
so now this sensitivity option
3477
02:26:17,640 --> 02:26:18,640
definitely works
3478
02:26:19,200 --> 02:26:20,200
so this is how we would actually go
3479
02:26:20,939 --> 02:26:21,939
about setting up sensitivity obviously
3480
02:26:23,580 --> 02:26:24,580
if you really didn't care you could just
3481
02:26:25,319 --> 02:26:26,319
have a variable here and stuff like that
3482
02:26:27,600 --> 02:26:28,600
doesn't really matter honestly
3483
02:26:30,420 --> 02:26:31,420
and there's another thing which you
3484
02:26:32,280 --> 02:26:33,280
could do is first on begin play itself
3485
02:26:36,120 --> 02:26:37,120
you could go ahead and pass your
3486
02:26:38,040 --> 02:26:39,040
sensitivity over here
3487
02:26:40,380 --> 02:26:41,380
and you could promote this to a variable
3488
02:26:42,540 --> 02:26:43,540
over here
3489
02:26:43,920 --> 02:26:44,920
and instead of calling the function
3490
02:26:46,620 --> 02:26:47,620
every time
3491
02:26:48,300 --> 02:26:49,300
and make this one private once again
3492
02:26:50,880 --> 02:26:51,880
instead of calling the function every
3493
02:26:52,740 --> 02:26:53,740
time you can go ahead and use the
3494
02:26:54,359 --> 02:26:55,359
sensitivity variable
3495
02:26:55,979 --> 02:26:56,979
so that's a little more better in terms
3496
02:26:58,140 --> 02:26:59,140
of performance this is something which
3497
02:26:59,760 --> 02:27:00,760
you could do as well
3498
02:27:01,859 --> 02:27:02,859
now remember we are only able to do this
3499
02:27:05,040 --> 02:27:06,040
because the player controller is always
3500
02:27:08,160 --> 02:27:09,160
created before your character spawns
3501
02:27:10,319 --> 02:27:11,319
let's say a player controller is not yet
3502
02:27:12,960 --> 02:27:13,960
created by the engine you can't actually
3503
02:27:15,240 --> 02:27:16,240
do this so let's say I go to my player
3504
02:27:18,300 --> 02:27:19,300
controller and I'm not sure if I can do
3505
02:27:21,720 --> 02:27:22,720
it on begin play maybe it would work on
3506
02:27:23,580 --> 02:27:24,580
begin play but technically if I type in
3507
02:27:26,280 --> 02:27:27,280
get player character
3508
02:27:29,160 --> 02:27:30,160
and if I type in cost to my BP character
3509
02:27:34,560 --> 02:27:35,560
and if I go ahead and print the string
3510
02:27:40,200 --> 02:27:41,200
copy that over
3511
02:27:42,180 --> 02:27:43,180
and I'll just type
3512
02:27:44,280 --> 02:27:45,280
failed for this
3513
02:27:46,740 --> 02:27:47,740
and doesn't matter to be honest and I'll
3514
02:27:49,620 --> 02:27:50,620
type in success now if I go ahead and
3515
02:27:52,080 --> 02:27:53,080
press play you see we get success
3516
02:27:54,800 --> 02:27:55,800
however this happens only because our
3517
02:27:58,920 --> 02:27:59,920
player controller is probably created or
3518
02:28:02,880 --> 02:28:03,880
rather the begin play is actually called
3519
02:28:05,040 --> 02:28:06,040
after the character is created as well
3520
02:28:07,620 --> 02:28:08,620
however now I'll just show you guys
3521
02:28:10,500 --> 02:28:11,500
another class now we'll discuss more in
3522
02:28:12,600 --> 02:28:13,600
depth about this but if I just type in
3523
02:28:14,580 --> 02:28:15,580
game instance I can go ahead and create
3524
02:28:16,620 --> 02:28:17,620
a game instance class and this is
3525
02:28:19,020 --> 02:28:20,020
actually referring to your whole game
3526
02:28:21,060 --> 02:28:22,060
application so if I type in event init
3527
02:28:24,060 --> 02:28:25,060
this is when your game starts this is
3528
02:28:26,939 --> 02:28:27,939
It's not like the begin play where you
3529
02:28:29,880 --> 02:28:30,880
are actually you know talking about when
3530
02:28:32,280 --> 02:28:33,280
this entity is created
3531
02:28:34,200 --> 02:28:35,200
the event in it is actually called uh
3532
02:28:38,100 --> 02:28:39,100
act when the game starts so that's one
3533
02:28:41,040 --> 02:28:42,040
difference so over here if I go ahead
3534
02:28:43,200 --> 02:28:44,200
and put this logic over here
3535
02:28:45,600 --> 02:28:46,600
and if I go ahead and go to my project
3536
02:28:49,200 --> 02:28:50,200
settings
3537
02:28:50,280 --> 02:28:51,280
and change the game instance
3538
02:28:53,939 --> 02:28:54,939
game instance to new blueprint we'll
3539
02:28:56,520 --> 02:28:57,520
delete that soon
3540
02:28:57,960 --> 02:28:58,960
and if I go ahead and press play you see
3541
02:29:00,300 --> 02:29:01,300
it says failed because our character is
3542
02:29:03,840 --> 02:29:04,840
not yet created so that's one thing to
3543
02:29:06,300 --> 02:29:07,300
note the the begin play logic only work
3544
02:29:09,359 --> 02:29:10,359
because our character is already created
3545
02:29:11,220 --> 02:29:12,220
now let's say we added a two second
3546
02:29:12,780 --> 02:29:13,780
delay now this is gonna work
3547
02:29:14,880 --> 02:29:15,880
so now if I do this it's gonna work
3548
02:29:17,700 --> 02:29:18,700
because our character is now
3549
02:29:19,020 --> 02:29:20,020
successfully created so that's basically
3550
02:29:21,540 --> 02:29:22,540
one thing that you guys need to
3551
02:29:22,979 --> 02:29:23,979
understand just make sure all your
3552
02:29:25,680 --> 02:29:26,680
entities are valid before you actually
3553
02:29:27,240 --> 02:29:28,240
set them and we can go ahead and revert
3554
02:29:29,100 --> 02:29:30,100
our game instance so
3555
02:29:31,020 --> 02:29:32,020
again we'll talk about all of this more
3556
02:29:33,359 --> 02:29:34,359
in depth this is not something which you
3557
02:29:35,640 --> 02:29:36,640
would really worry about at a beginner
3558
02:29:37,200 --> 02:29:38,200
level
3559
02:29:38,819 --> 02:29:39,819
now save everything and that should be
3560
02:29:41,280 --> 02:29:42,280
good to go
3561
02:29:42,359 --> 02:29:43,359
to go a little more in depth on the part
3562
02:29:45,479 --> 02:29:46,479
where you know you'd actually check if
3563
02:29:47,640 --> 02:29:48,640
this object is created so in our case I
3564
02:29:51,180 --> 02:29:52,180
mean everything just worked out smoothly
3565
02:29:52,920 --> 02:29:53,920
but what if it didn't what if this
3566
02:29:55,859 --> 02:29:56,859
wasn't valid yet because as I told you
3567
02:29:58,680 --> 02:29:59,680
guys the default value is none what if
3568
02:30:00,899 --> 02:30:01,899
this wasn't valid well there is a fix
3569
02:30:03,300 --> 02:30:04,300
for that as well there is actually a
3570
02:30:05,520 --> 02:30:06,520
function called is valid so if I go
3571
02:30:08,700 --> 02:30:09,700
ahead and type in is valid there's
3572
02:30:10,380 --> 02:30:11,380
actually a macro which is created for us
3573
02:30:13,080 --> 02:30:14,080
so what we can do is we can go ahead and
3574
02:30:17,100 --> 02:30:18,100
actually do this
3575
02:30:19,439 --> 02:30:20,439
so if we we can convert this to a normal
3576
02:30:22,620 --> 02:30:23,620
MPR cast
3577
02:30:24,780 --> 02:30:25,780
so on begin play we can go ahead and do
3578
02:30:27,780 --> 02:30:28,780
this
3579
02:30:28,620 --> 02:30:29,620
we can check if it is valid and if it is
3580
02:30:32,280 --> 02:30:33,280
not valid we would not want to do
3581
02:30:34,560 --> 02:30:35,560
anything but I mean if it is valid we
3582
02:30:37,680 --> 02:30:38,680
want to set the reference obviously but
3583
02:30:40,500 --> 02:30:41,500
if it is not valid we want to again
3584
02:30:42,479 --> 02:30:43,479
check after a while and if it is valid
3585
02:30:45,359 --> 02:30:46,359
obviously uh after setting the reference
3586
02:30:48,000 --> 02:30:49,000
you would want to go ahead and set the
3587
02:30:49,620 --> 02:30:50,620
sensitivity and do the regular stuff
3588
02:30:53,819 --> 02:30:54,819
foreign
3589
02:30:57,180 --> 02:30:58,180
now
3590
02:30:58,640 --> 02:30:59,640
how do we actually check once again so
3591
02:31:02,220 --> 02:31:03,220
for this you would use a technique known
3592
02:31:04,200 --> 02:31:05,200
as polling so polling is where you
3593
02:31:06,960 --> 02:31:07,960
repeatedly call a certain function until
3594
02:31:10,439 --> 02:31:11,439
a certain condition is met and you
3595
02:31:13,740 --> 02:31:14,740
actually get your desired result
3596
02:31:15,960 --> 02:31:16,960
so the way you can do this is by using a
3597
02:31:18,300 --> 02:31:19,300
timer and that takes us to the next
3598
02:31:20,280 --> 02:31:21,280
important concept
3599
02:31:22,020 --> 02:31:23,020
now if I right click and type in set
3600
02:31:24,420 --> 02:31:25,420
timer you would see you you'd get a few
3601
02:31:28,140 --> 02:31:29,140
nodes over here
3602
02:31:30,240 --> 02:31:31,240
however the only one which you'll use is
3603
02:31:32,580 --> 02:31:33,580
set timer by function name
3604
02:31:34,680 --> 02:31:35,680
set timer by event is kinda pointless in
3605
02:31:37,740 --> 02:31:38,740
my opinion because even if you do use
3606
02:31:40,920 --> 02:31:41,920
this you can actually refer to an event
3607
02:31:43,140 --> 02:31:44,140
by the function name itself so most of
3608
02:31:45,359 --> 02:31:46,359
the times you would be using set timer
3609
02:31:46,920 --> 02:31:47,920
by function name
3610
02:31:48,420 --> 02:31:49,420
so you set timer by function name now it
3611
02:31:51,540 --> 02:31:52,540
returns as a timer handle which allows
3612
02:31:53,819 --> 02:31:54,819
us to control this timer
3613
02:31:55,500 --> 02:31:56,500
and what this basically means is it is
3614
02:31:58,979 --> 02:31:59,979
going to call the function with a given
3615
02:32:00,960 --> 02:32:01,960
name so we can right click on this and
3616
02:32:03,479 --> 02:32:04,479
type in collapse to function and let's
3617
02:32:06,780 --> 02:32:07,780
call this one for example get references
3618
02:32:11,160 --> 02:32:12,160
or let's call this one initialize
3619
02:32:13,859 --> 02:32:14,859
and we don't really need this in the
3620
02:32:15,960 --> 02:32:16,960
event graph
3621
02:32:17,640 --> 02:32:18,640
and over here we can copy over this name
3622
02:32:20,520 --> 02:32:21,520
so what we are basically saying is after
3623
02:32:22,560 --> 02:32:23,560
certain time call this function once
3624
02:32:24,960 --> 02:32:25,960
again so we can have a very small time
3625
02:32:27,060 --> 02:32:28,060
such as 0.01 seconds and make this one
3626
02:32:30,060 --> 02:32:31,060
looping because if you just uh set this
3627
02:32:32,939 --> 02:32:33,939
to point on without the looping it's
3628
02:32:34,800 --> 02:32:35,800
just going to execute it once
3629
02:32:36,840 --> 02:32:37,840
and we can go ahead and store the handle
3630
02:32:39,300 --> 02:32:40,300
of the timer so we can call this one
3631
02:32:41,660 --> 02:32:42,660
initialization timer
3632
02:32:47,280 --> 02:32:48,280
and once we have that
3633
02:32:50,040 --> 02:32:51,040
this timer is now set and we could just
3634
02:32:52,920 --> 02:32:53,920
comment it out and call this one polling
3635
02:32:55,979 --> 02:32:56,979
for references
3636
02:32:58,140 --> 02:32:59,140
again you could name it a little more
3637
02:32:59,880 --> 02:33:00,880
descriptively you could give it a color
3638
02:33:01,620 --> 02:33:02,620
as well that's one cool feature in
3639
02:33:03,240 --> 02:33:04,240
unreal honestly you'd never use it but
3640
02:33:05,939 --> 02:33:06,939
yeah I just showed it and under
3641
02:33:08,340 --> 02:33:09,340
initialize
3642
02:33:11,819 --> 02:33:12,819
we need to stop the timer once we
3643
02:33:14,040 --> 02:33:15,040
actually finish everything so once we
3644
02:33:16,140 --> 02:33:17,140
finish setting the sensitivity there's
3645
02:33:17,640 --> 02:33:18,640
no reason for this function to run again
3646
02:33:20,040 --> 02:33:21,040
so we can go ahead and get our timer
3647
02:33:22,260 --> 02:33:23,260
handle first of all
3648
02:33:23,880 --> 02:33:24,880
and if you just type in clear you'd get
3649
02:33:27,300 --> 02:33:28,300
an option called clear and invalidate
3650
02:33:29,160 --> 02:33:30,160
timer by handle go ahead and call that
3651
02:33:31,200 --> 02:33:32,200
this is how you stop the timer
3652
02:33:33,540 --> 02:33:34,540
copy this and if it is not valid we
3653
02:33:36,300 --> 02:33:37,300
don't really want to do anything and if
3654
02:33:38,100 --> 02:33:39,100
the cast failed again we don't really
3655
02:33:39,899 --> 02:33:40,899
want to do anything
3656
02:33:41,880 --> 02:33:42,880
so again yeah this cast is bound to fail
3657
02:33:45,359 --> 02:33:46,359
actually this check is kind of useless
3658
02:33:49,680 --> 02:33:50,680
in this case
3659
02:33:51,240 --> 02:33:52,240
so we can just go ahead and do this
3660
02:33:53,280 --> 02:33:54,280
because if we don't have a player
3661
02:33:56,340 --> 02:33:57,340
controller this cast will obviously fail
3662
02:33:58,319 --> 02:33:59,319
but anyways I'll just keep it like this
3663
02:34:01,560 --> 02:34:02,560
and now if I go ahead and run this what
3664
02:34:05,880 --> 02:34:06,880
will actually happen is every 0.01
3665
02:34:08,100 --> 02:34:09,100
seconds it is going to repeatedly call
3666
02:34:10,380 --> 02:34:11,380
the function until we have cleared it so
3667
02:34:12,720 --> 02:34:13,720
once we get all the references we go
3668
02:34:14,939 --> 02:34:15,939
ahead and clear the function I mean
3669
02:34:16,620 --> 02:34:17,620
clear the timer there are some key
3670
02:34:18,960 --> 02:34:19,960
differences though between doing this
3671
02:34:21,240 --> 02:34:22,240
and using a delay obviously you could
3672
02:34:23,939 --> 02:34:24,939
have done this as well so you could have
3673
02:34:25,560 --> 02:34:26,560
done delay
3674
02:34:27,300 --> 02:34:28,300
and let's say we give 0.01 once again
3675
02:34:30,720 --> 02:34:31,720
and over here we can go ahead and call
3676
02:34:33,000 --> 02:34:34,000
initialize and we can go ahead and loop
3677
02:34:36,000 --> 02:34:37,000
this obviously we can call this first so
3678
02:34:38,460 --> 02:34:39,460
initialize then after 0.01 seconds we
3679
02:34:41,520 --> 02:34:42,520
could do this and maybe we could check
3680
02:34:43,620 --> 02:34:44,620
if we have all the references we could
3681
02:34:45,479 --> 02:34:46,479
maybe return a Boolean over here or
3682
02:34:47,220 --> 02:34:48,220
something and do something like that the
3683
02:34:49,620 --> 02:34:50,620
difference between a delay and a timer
3684
02:34:51,479 --> 02:34:52,479
is that a timer is going to be very very
3685
02:34:53,700 --> 02:34:54,700
precise it is going to be precise
3686
02:34:55,979 --> 02:34:56,979
usually up to micro or even nanoseconds
3687
02:34:59,040 --> 02:35:00,040
if you have a precise timer this one I
3688
02:35:01,680 --> 02:35:02,680
believe is precise up to a couple
3689
02:35:03,479 --> 02:35:04,479
hundred microseconds so as far as my
3690
02:35:06,720 --> 02:35:07,720
testing is concerned you could use
3691
02:35:08,220 --> 02:35:09,220
Chrono in C plus plus and actually test
3692
02:35:10,439 --> 02:35:11,439
it so this is going to be accurate
3693
02:35:13,020 --> 02:35:14,020
however a delay is going to be very very
3694
02:35:15,060 --> 02:35:16,060
inaccurate so that's one thing to note
3695
02:35:17,580 --> 02:35:18,580
if you want something to time accurately
3696
02:35:20,340 --> 02:35:21,340
you would use a timer or in our case we
3697
02:35:23,580 --> 02:35:24,580
needed the looping functionality so
3698
02:35:25,380 --> 02:35:26,380
that's the reason we use the timer
3699
02:35:28,590 --> 02:35:29,590
[Music]
3700
02:35:33,300 --> 02:35:34,300
since we have built a fundamental idea
3701
02:35:36,060 --> 02:35:37,060
on how inputs work now we can go ahead
3702
02:35:39,060 --> 02:35:40,060
and check the other type of input that
3703
02:35:41,340 --> 02:35:42,340
is input action mapping now before that
3704
02:35:44,520 --> 02:35:45,520
let's actually just clean this up a
3705
02:35:47,220 --> 02:35:48,220
little bit so just comment it out and
3706
02:35:50,160 --> 02:35:51,160
type in movement
3707
02:35:52,319 --> 02:35:53,319
movement and maybe you could type in
3708
02:35:54,300 --> 02:35:55,300
movement and Camera maybe so movement
3709
02:35:56,340 --> 02:35:57,340
and Camera
3710
02:35:58,680 --> 02:35:59,680
so now we can just group this
3711
02:36:01,560 --> 02:36:02,560
now head back into your project settings
3712
02:36:04,859 --> 02:36:05,859
and under input again
3713
02:36:07,200 --> 02:36:08,200
if you look at action mappings you can
3714
02:36:09,359 --> 02:36:10,359
go ahead and add one and we can call
3715
02:36:11,880 --> 02:36:12,880
this one interact
3716
02:36:13,979 --> 02:36:14,979
and we could set that to the F key
3717
02:36:17,040 --> 02:36:18,040
now the advantage of using it through
3718
02:36:19,380 --> 02:36:20,380
the project settings like this rather
3719
02:36:21,180 --> 02:36:22,180
than brute forcing so you could do F
3720
02:36:23,880 --> 02:36:24,880
over here as well so if I just type in F
3721
02:36:26,700 --> 02:36:27,700
and give a space and type in keyboard I
3722
02:36:29,939 --> 02:36:30,939
can actually do this but this is not the
3723
02:36:32,220 --> 02:36:33,220
proper way to do it because this uh
3724
02:36:35,399 --> 02:36:36,399
these action mappings can be actually
3725
02:36:38,220 --> 02:36:39,220
changed through your in-game settings
3726
02:36:40,979 --> 02:36:41,979
menus so you can actually create a menu
3727
02:36:43,319 --> 02:36:44,319
inside the game and allow the user to
3728
02:36:45,780 --> 02:36:46,780
change or allow the player to change
3729
02:36:48,240 --> 02:36:49,240
these key bindings
3730
02:36:50,520 --> 02:36:51,520
so we'll call the call this one interact
3731
02:36:52,859 --> 02:36:53,859
now so action event interact and this
3732
02:36:55,680 --> 02:36:56,680
gives us a pretty basic pressed and
3733
02:36:57,840 --> 02:36:58,840
released option so when we actually
3734
02:37:00,120 --> 02:37:01,120
press it
3735
02:37:01,800 --> 02:37:02,800
so we want to be able to pick up an
3736
02:37:05,100 --> 02:37:06,100
actor now how are we going to actually
3737
02:37:08,160 --> 02:37:09,160
set this up
3738
02:37:09,600 --> 02:37:10,600
so first things first
3739
02:37:11,460 --> 02:37:12,460
remember we had our actor begin overlap
3740
02:37:14,640 --> 02:37:15,640
instead of doing it here it's always
3741
02:37:16,920 --> 02:37:17,920
advisable we do it from the character
3742
02:37:19,800 --> 02:37:20,800
so do your actor begin overlap here
3743
02:37:22,800 --> 02:37:23,800
actor begin overlap
3744
02:37:25,500 --> 02:37:26,500
once you call the actor uh begin overlap
3745
02:37:29,580 --> 02:37:30,580
or here for the other actor instead of
3746
02:37:32,040 --> 02:37:33,040
casting to a character since we are the
3747
02:37:34,380 --> 02:37:35,380
character ourselves here because we are
3748
02:37:36,720 --> 02:37:37,720
inside the character class right now we
3749
02:37:39,240 --> 02:37:40,240
can cast to the pickup instead
3750
02:37:43,380 --> 02:37:44,380
now that we have casted to BP pickup we
3751
02:37:46,080 --> 02:37:47,080
are checking if this is actually a
3752
02:37:48,420 --> 02:37:49,420
pickup now there is a better way to do
3753
02:37:51,000 --> 02:37:52,000
it using interfaces but that is a much
3754
02:37:53,700 --> 02:37:54,700
higher level concept than casting but I
3755
02:37:56,520 --> 02:37:57,520
will definitely get to that a little
3756
02:37:58,319 --> 02:37:59,319
later in this course so we'll probably
3757
02:38:00,660 --> 02:38:01,660
change this to use an interface even
3758
02:38:03,180 --> 02:38:04,180
that is casting at the very fundamental
3759
02:38:06,240 --> 02:38:07,240
level but that's a more elegant solution
3760
02:38:08,520 --> 02:38:09,520
to do things
3761
02:38:10,380 --> 02:38:11,380
now if this is actually a pickup we can
3762
02:38:13,080 --> 02:38:14,080
go ahead and actually store it so
3763
02:38:15,359 --> 02:38:16,359
promote to variable
3764
02:38:17,640 --> 02:38:18,640
and let's just say let's just call this
3765
02:38:21,300 --> 02:38:22,300
one nearby pickup
3766
02:38:23,580 --> 02:38:24,580
nearby pickup
3767
02:38:26,040 --> 02:38:27,040
and what we can do is on our actor end
3768
02:38:29,520 --> 02:38:30,520
all app so end overlap
3769
02:38:34,740 --> 02:38:35,740
over here we can go ahead and again cast
3770
02:38:37,859 --> 02:38:38,859
it first things first and if it is we
3771
02:38:41,220 --> 02:38:42,220
can check if it is equal to the nearby
3772
02:38:43,979 --> 02:38:44,979
pickup
3773
02:38:45,840 --> 02:38:46,840
and if it is equal to the nearby pickup
3774
02:38:48,479 --> 02:38:49,479
and we have left its bounds we can go
3775
02:38:51,479 --> 02:38:52,479
ahead and remove it
3776
02:38:53,520 --> 02:38:54,520
and invalidate the reference so we can
3777
02:38:56,700 --> 02:38:57,700
all drag it and we can set it to be
3778
02:38:58,680 --> 02:38:59,680
equal to none that is going to
3779
02:38:59,939 --> 02:39:00,939
invalidate a reference
3780
02:39:02,160 --> 02:39:03,160
so that's about it
3781
02:39:03,960 --> 02:39:04,960
now once we have our reference what we
3782
02:39:07,020 --> 02:39:08,020
can do is we can head in our interact
3783
02:39:09,180 --> 02:39:10,180
function check if this is valid one more
3784
02:39:11,640 --> 02:39:12,640
way you can do it is by right clicking
3785
02:39:13,200 --> 02:39:14,200
and converting this to a validated git
3786
02:39:15,660 --> 02:39:16,660
so if our pickup is valid which means we
3787
02:39:18,359 --> 02:39:19,359
are near a pickup so what we can do is
3788
02:39:20,880 --> 02:39:21,880
we can actually call a function for now
3789
02:39:23,040 --> 02:39:24,040
let's just print out a string let's say
3790
02:39:25,460 --> 02:39:26,460
so or rather we can just destroy it so
3791
02:39:28,680 --> 02:39:29,680
type in Destroy and you will get destroy
3792
02:39:31,319 --> 02:39:32,319
actor
3793
02:39:32,340 --> 02:39:33,340
if I go ahead and press play
3794
02:39:34,560 --> 02:39:35,560
and if I go close to it and if I hit
3795
02:39:36,359 --> 02:39:37,359
interact you see I destroy the pickup
3796
02:39:38,399 --> 02:39:39,399
and if I do that once again that is not
3797
02:39:40,920 --> 02:39:41,920
gonna work
3798
02:39:42,600 --> 02:39:43,600
the reason is once our pickup is
3799
02:39:45,120 --> 02:39:46,120
destroyed it's no longer valid so what
3800
02:39:47,939 --> 02:39:48,939
we have to do basically is check once
3801
02:39:51,240 --> 02:39:52,240
again if we have any pickups nearby
3802
02:39:54,120 --> 02:39:55,120
so that's actually really easy to do so
3803
02:39:56,399 --> 02:39:57,399
once we destroy it we know that our
3804
02:39:58,319 --> 02:39:59,319
nearby pickup isn't actually valid
3805
02:40:00,899 --> 02:40:01,899
so we can go ahead and set our nearby
3806
02:40:03,000 --> 02:40:04,000
pickup to the nearest one now how do you
3807
02:40:05,760 --> 02:40:06,760
check that again using a function so we
3808
02:40:08,220 --> 02:40:09,220
want to see if we are overlapping so
3809
02:40:10,439 --> 02:40:11,439
type in overlapping
3810
02:40:12,720 --> 02:40:13,720
and you already see
3811
02:40:15,180 --> 02:40:16,180
you actually get
3812
02:40:17,280 --> 02:40:18,280
options for get overlapping actors which
3813
02:40:21,359 --> 02:40:22,359
is exactly what we need and for the
3814
02:40:23,520 --> 02:40:24,520
class filter it's obviously going to be
3815
02:40:25,439 --> 02:40:26,439
BP pickup
3816
02:40:27,540 --> 02:40:28,540
and over here we get an array of actor
3817
02:40:30,420 --> 02:40:31,420
references
3818
02:40:31,800 --> 02:40:32,800
instead of getting all of them we can
3819
02:40:33,479 --> 02:40:34,479
just get the first one this is an array
3820
02:40:35,399 --> 02:40:36,399
so obviously we have to get the first
3821
02:40:38,280 --> 02:40:39,280
index of the array
3822
02:40:40,920 --> 02:40:41,920
so once we get that we can go ahead and
3823
02:40:43,680 --> 02:40:44,680
cast this to BP pickup once again
3824
02:40:47,700 --> 02:40:48,700
and it is going to be successful all the
3825
02:40:50,460 --> 02:40:51,460
time so we can just make this a pure
3826
02:40:52,080 --> 02:40:53,080
cast
3827
02:40:53,100 --> 02:40:54,100
because we are actually using the class
3828
02:40:54,960 --> 02:40:55,960
filter here
3829
02:40:56,340 --> 02:40:57,340
and then we can go ahead and set the
3830
02:40:58,260 --> 02:40:59,260
nearby pickup
3831
02:41:00,780 --> 02:41:01,780
so now our logic should work
3832
02:41:04,560 --> 02:41:05,560
for both the pickup so if I hit f one of
3833
02:41:07,080 --> 02:41:08,080
the pickups got destroyed
3834
02:41:10,740 --> 02:41:11,740
so I shouldn't have moved back actually
3835
02:41:13,140 --> 02:41:14,140
so if I press f one got destroyed if I
3836
02:41:15,960 --> 02:41:16,960
press F again the other one got
3837
02:41:17,399 --> 02:41:18,399
destroyed as well and there are no
3838
02:41:19,439 --> 02:41:20,439
errors
3839
02:41:20,520 --> 02:41:21,520
so this is basically how you do
3840
02:41:22,319 --> 02:41:23,319
something like a pickup now obviously
3841
02:41:24,660 --> 02:41:25,660
before you destroy it let's say you had
3842
02:41:27,240 --> 02:41:28,240
some properties let's say for example
3843
02:41:29,280 --> 02:41:30,280
let's say this was a health portion or
3844
02:41:32,220 --> 02:41:33,220
something which gave your player a
3845
02:41:34,140 --> 02:41:35,140
couple of Health points
3846
02:41:35,640 --> 02:41:36,640
so we can add in
3847
02:41:38,460 --> 02:41:39,460
I don't know let's say health points
3848
02:41:41,660 --> 02:41:42,660
obviously you will have a better
3849
02:41:43,979 --> 02:41:44,979
inheritance hierarchy and we will get
3850
02:41:47,040 --> 02:41:48,040
into that
3851
02:41:48,120 --> 02:41:49,120
so Health points make this a float let's
3852
02:41:50,640 --> 02:41:51,640
say we have 10
3853
02:41:52,380 --> 02:41:53,380
so what we can do is for now we can just
3854
02:41:55,439 --> 02:41:56,439
go ahead and print it so we can grab
3855
02:41:57,960 --> 02:41:58,960
this
3856
02:41:58,740 --> 02:41:59,740
Health points and we can just print it
3857
02:42:01,560 --> 02:42:02,560
out
3858
02:42:03,960 --> 02:42:04,960
so move all of this logic a bit over
3859
02:42:06,180 --> 02:42:07,180
there to make space
3860
02:42:07,920 --> 02:42:08,920
we can just print that before destroying
3861
02:42:10,020 --> 02:42:11,020
it make sure you call Print before
3862
02:42:12,000 --> 02:42:13,000
destroy otherwise you're going to get a
3863
02:42:14,040 --> 02:42:15,040
log error
3864
02:42:17,580 --> 02:42:18,580
now if I go nearby if I press f we are
3865
02:42:21,120 --> 02:42:22,120
going to get 10 printed every time
3866
02:42:23,819 --> 02:42:24,819
so that's basically how you do it
3867
02:42:26,720 --> 02:42:27,720
[Music]
3868
02:42:31,859 --> 02:42:32,859
however
3869
02:42:33,060 --> 02:42:34,060
let's say you wanted to change some of
3870
02:42:36,540 --> 02:42:37,540
these properties
3871
02:42:38,700 --> 02:42:39,700
depending on which pickup it is
3872
02:42:41,460 --> 02:42:42,460
now apart from having these as a
3873
02:42:43,500 --> 02:42:44,500
variable
3874
02:42:44,399 --> 02:42:45,399
you can go ahead and check these two
3875
02:42:46,859 --> 02:42:47,859
options called instance editable and
3876
02:42:49,620 --> 02:42:50,620
expose on spawn
3877
02:42:52,020 --> 02:42:53,020
what these will do is allow us to edit
3878
02:42:55,200 --> 02:42:56,200
these properties when we actually spawn
3879
02:42:57,180 --> 02:42:58,180
it so let's say we spawn a pickup for
3880
02:42:59,760 --> 02:43:00,760
example
3881
02:43:01,080 --> 02:43:02,080
so over here
3882
02:43:02,760 --> 02:43:03,760
let's say I do spawn actor
3883
02:43:05,460 --> 02:43:06,460
let's have a spawn a pickup
3884
02:43:08,700 --> 02:43:09,700
you see we actually get an option to
3885
02:43:10,859 --> 02:43:11,859
change our health points so we could do
3886
02:43:12,840 --> 02:43:13,840
something like 90 for example and for
3887
02:43:15,240 --> 02:43:16,240
the spawn transform we can just uh get a
3888
02:43:17,880 --> 02:43:18,880
random location let's say uh let me just
3889
02:43:20,640 --> 02:43:21,640
add in
3890
02:43:21,840 --> 02:43:22,840
something for us to recognize so
3891
02:43:24,120 --> 02:43:25,120
something which you would use for such a
3892
02:43:25,979 --> 02:43:26,979
case is called a Target point
3893
02:43:28,260 --> 02:43:29,260
so I can use a Target point so this will
3894
02:43:30,359 --> 02:43:31,359
represent a target a point in space you
3895
02:43:33,359 --> 02:43:34,359
can copy this over and we can go ahead
3896
02:43:35,819 --> 02:43:36,819
and paste it in or okay maybe we can't
3897
02:43:38,880 --> 02:43:39,880
do that here you can do it in the
3898
02:43:41,100 --> 02:43:42,100
details panel so one one five zero
3899
02:43:44,640 --> 02:43:45,640
uh negative whatever this value is
3900
02:43:47,939 --> 02:43:48,939
and 650.
3901
02:43:50,340 --> 02:43:51,340
so 650.
3902
02:43:52,439 --> 02:43:53,439
and we have health points set to 90 over
3903
02:43:55,979 --> 02:43:56,979
there now as you would see we actually
3904
02:43:58,140 --> 02:43:59,140
spawn another pickup now if I go ahead
3905
02:44:00,060 --> 02:44:01,060
and pick these up you get 10 but when I
3906
02:44:03,240 --> 02:44:04,240
go near this I get 90.
3907
02:44:06,660 --> 02:44:07,660
however it need not be restricted to
3908
02:44:09,479 --> 02:44:10,479
spawning it through the blueprint you
3909
02:44:12,120 --> 02:44:13,120
can actually edit Expos on spawn
3910
02:44:13,979 --> 02:44:14,979
variables right here as well so even
3911
02:44:16,620 --> 02:44:17,620
when you're placing them in the level
3912
02:44:18,180 --> 02:44:19,180
you could have this to be 20 for example
3913
02:44:21,420 --> 02:44:22,420
so if I go nearby
3914
02:44:24,240 --> 02:44:25,240
you would see 10
3915
02:44:25,979 --> 02:44:26,979
20 and this one is obviously going to be
3916
02:44:28,920 --> 02:44:29,920
90. so stuff like that which you can do
3917
02:44:32,220 --> 02:44:33,220
using expose on spawn you can expose any
3918
02:44:34,620 --> 02:44:35,620
variable on spawn and they will be
3919
02:44:36,420 --> 02:44:37,420
passed right into the actor and the
3920
02:44:38,640 --> 02:44:39,640
value which you pass in would be set to
3921
02:44:40,620 --> 02:44:41,620
that variable
3922
02:44:42,180 --> 02:44:43,180
and now we can go ahead and remove this
3923
02:44:44,100 --> 02:44:45,100
logic that was just for showcasing
3924
02:44:46,439 --> 02:44:47,439
purposes
3925
02:44:47,760 --> 02:44:48,760
and we can go ahead and collapse system
3926
02:44:50,880 --> 02:44:51,880
function and call this one whoops call
3927
02:44:54,540 --> 02:44:55,540
this one pickup
3928
02:44:57,319 --> 02:44:58,319
and along with this maybe we could also
3929
02:45:00,960 --> 02:45:01,960
have something like door open or
3930
02:45:03,240 --> 02:45:04,240
something let's say this is not valid we
3931
02:45:05,760 --> 02:45:06,760
could go ahead and perform door open or
3932
02:45:07,920 --> 02:45:08,920
something like that we could go to the
3933
02:45:09,720 --> 02:45:10,720
return node and we could have a sequence
3934
02:45:12,000 --> 02:45:13,000
node here
3935
02:45:13,859 --> 02:45:14,859
so first we would check for a pickup
3936
02:45:16,260 --> 02:45:17,260
and we could also do something like a
3937
02:45:18,540 --> 02:45:19,540
door open or maybe anything else
3938
02:45:21,359 --> 02:45:22,359
probably maybe if you had some sort of
3939
02:45:24,780 --> 02:45:25,780
an interaction system with a player or
3940
02:45:26,640 --> 02:45:27,640
something so you could interact with the
3941
02:45:28,920 --> 02:45:29,920
other player stuff like that which you
3942
02:45:31,140 --> 02:45:32,140
can do using these input bindings and
3943
02:45:33,920 --> 02:45:34,920
using the overlap events
3944
02:45:37,800 --> 02:45:38,800
foreign
3945
02:45:47,180 --> 02:45:48,180
events now I will show you guys how to
3946
02:45:49,439 --> 02:45:50,439
do it the better way with interfaces
3947
02:45:51,120 --> 02:45:52,120
later but this is the Brute Force way
3948
02:45:53,040 --> 02:45:54,040
and if you have maybe one two or maybe
3949
02:45:56,220 --> 02:45:57,220
three or not more than four interactions
3950
02:45:59,280 --> 02:46:00,280
you could use this method itself the one
3951
02:46:01,979 --> 02:46:02,979
which we did with casting so this is
3952
02:46:04,620 --> 02:46:05,620
totally okay for small things
3953
02:46:06,960 --> 02:46:07,960
now let's actually do it so right click
3954
02:46:09,359 --> 02:46:10,359
create a new actor and let's call this
3955
02:46:11,580 --> 02:46:12,580
one interaction actor
3956
02:46:15,899 --> 02:46:16,899
maybe we could just uh nudge it or
3957
02:46:18,600 --> 02:46:19,600
something so
3958
02:46:20,280 --> 02:46:21,280
let's say we have we have another static
3959
02:46:22,620 --> 02:46:23,620
mesh make that the root component and we
3960
02:46:26,040 --> 02:46:27,040
need some sort of bound so sphere
3961
02:46:28,260 --> 02:46:29,260
Collision Maybe
3962
02:46:29,819 --> 02:46:30,819
and for the mesh let's just take a cone
3963
02:46:33,120 --> 02:46:34,120
for example and also I've gone ahead and
3964
02:46:35,780 --> 02:46:36,780
deleted the code which we had inside BP
3965
02:46:39,000 --> 02:46:40,000
pickup since we are not using it
3966
02:46:41,399 --> 02:46:42,399
and over here go ahead and simulate
3967
02:46:44,220 --> 02:46:45,220
physics make sure you don't forget that
3968
02:46:46,939 --> 02:46:47,939
and we can go ahead and okay maybe we
3969
02:46:50,040 --> 02:46:51,040
can have a smaller one for example
3970
02:46:53,040 --> 02:46:54,040
so I'm not really sure I'm just looking
3971
02:46:55,859 --> 02:46:56,859
for
3972
02:46:57,120 --> 02:46:58,120
any mesh that's available to us because
3973
02:46:59,819 --> 02:47:00,819
we haven't imported ours
3974
02:47:02,160 --> 02:47:03,160
okay this is way too big
3975
02:47:05,700 --> 02:47:06,700
okay this sphere seems like a reasonable
3976
02:47:07,859 --> 02:47:08,859
size we can go ahead and increase our
3977
02:47:09,960 --> 02:47:10,960
bounds
3978
02:47:11,580 --> 02:47:12,580
that's about it
3979
02:47:13,380 --> 02:47:14,380
and once again over here we can head
3980
02:47:16,560 --> 02:47:17,560
into our BP character
3981
02:47:18,479 --> 02:47:19,479
and what we can do is we can copy our
3982
02:47:21,060 --> 02:47:22,060
the same logic
3983
02:47:23,399 --> 02:47:24,399
so instead of nearby pickup we are going
3984
02:47:26,700 --> 02:47:27,700
to have something else so if this cast
3985
02:47:28,680 --> 02:47:29,680
fails so if
3986
02:47:30,359 --> 02:47:31,359
whatever we are nearby is not a pickup
3987
02:47:33,300 --> 02:47:34,300
we can check if this is actually an
3988
02:47:35,760 --> 02:47:36,760
interaction actor so we can do cast to
3989
02:47:37,920 --> 02:47:38,920
interaction actor
3990
02:47:40,200 --> 02:47:41,200
and again other actor is what we are
3991
02:47:43,380 --> 02:47:44,380
checking if it is the interaction actor
3992
02:47:45,540 --> 02:47:46,540
we can go ahead and promote this to
3993
02:47:47,580 --> 02:47:48,580
variable and call this one interaction
3994
02:47:49,920 --> 02:47:50,920
actor again I prefer going with Pascal
3995
02:47:53,160 --> 02:47:54,160
case
3996
02:47:54,780 --> 02:47:55,780
all right now when we actually
3997
02:47:59,100 --> 02:48:00,100
go away from it we can again do the same
3998
02:48:02,640 --> 02:48:03,640
cast so we can copy this over
3999
02:48:05,760 --> 02:48:06,760
we can paste it
4000
02:48:07,859 --> 02:48:08,859
and for this actor if it is equal to the
4001
02:48:11,880 --> 02:48:12,880
interaction actor which we were nearby
4002
02:48:13,620 --> 02:48:14,620
so copy this over
4003
02:48:17,280 --> 02:48:18,280
grab in the interaction actor if it was
4004
02:48:19,920 --> 02:48:20,920
in fact the interaction actor then we
4005
02:48:22,500 --> 02:48:23,500
can go ahead and invalidate it
4006
02:48:26,580 --> 02:48:27,580
and set that to be equal to none
4007
02:48:31,560 --> 02:48:32,560
so that should be about it now over here
4008
02:48:34,859 --> 02:48:35,859
in the interaction logic we can go ahead
4009
02:48:37,020 --> 02:48:38,020
and check if this is valid right click
4010
02:48:39,840 --> 02:48:40,840
convert to validated get so if we are
4011
02:48:43,260 --> 02:48:44,260
near an interaction actor uh what we can
4012
02:48:46,380 --> 02:48:47,380
do is we can instead of destroying let's
4013
02:48:49,500 --> 02:48:50,500
actually add impulse so add impulse
4014
02:48:52,859 --> 02:48:53,859
so add impulse
4015
02:48:57,660 --> 02:48:58,660
so ins so we want to add impulse to the
4016
02:49:01,319 --> 02:49:02,319
root component here which is simulating
4017
02:49:03,840 --> 02:49:04,840
physics
4018
02:49:04,859 --> 02:49:05,859
basically these are the physics
4019
02:49:06,479 --> 02:49:07,479
functions you have impulse Force dark
4020
02:49:08,760 --> 02:49:09,760
and all sorts of stuff obviously you
4021
02:49:11,399 --> 02:49:12,399
could spend some time and study those
4022
02:49:13,920 --> 02:49:14,920
but we'll not get into that so we have a
4023
02:49:16,800 --> 02:49:17,800
sphere here so
4024
02:49:18,840 --> 02:49:19,840
static mesh is the root component so we
4025
02:49:21,240 --> 02:49:22,240
need to get the static mesh
4026
02:49:25,319 --> 02:49:26,319
if I go ahead and scroll all the way
4027
02:49:28,080 --> 02:49:29,080
down I should see get static mesh now
4028
02:49:30,899 --> 02:49:31,899
this variable refers to the component
4029
02:49:33,479 --> 02:49:34,479
even components are objects so you can
4030
02:49:37,020 --> 02:49:38,020
just get them as variables
4031
02:49:39,740 --> 02:49:40,740
and for the impulse what we can do is we
4032
02:49:43,560 --> 02:49:44,560
can go ahead and get the forward
4033
02:49:44,939 --> 02:49:45,939
direction of a character get forward
4034
02:49:46,979 --> 02:49:47,979
vector
4035
02:49:48,600 --> 02:49:49,600
now you could change it according to
4036
02:49:50,640 --> 02:49:51,640
y'all this is logic based so it's
4037
02:49:53,100 --> 02:49:54,100
nothing much really and you can multiply
4038
02:49:55,260 --> 02:49:56,260
this by a certain value so you can make
4039
02:49:57,840 --> 02:49:58,840
this one a float
4040
02:50:00,439 --> 02:50:01,439
and change this to a float
4041
02:50:03,540 --> 02:50:04,540
make this let's say something like 10
4042
02:50:06,540 --> 02:50:07,540
000 something big Maybe
4043
02:50:08,280 --> 02:50:09,280
get active forward Vector multiply that
4044
02:50:11,399 --> 02:50:12,399
by ten thousand
4045
02:50:13,280 --> 02:50:14,280
and that should be good to go
4046
02:50:17,340 --> 02:50:18,340
now we can collapse this to a function
4047
02:50:20,460 --> 02:50:21,460
and we can call this one nudge ball or
4048
02:50:24,120 --> 02:50:25,120
something because the sphere looks like
4049
02:50:26,399 --> 02:50:27,399
a ball so
4050
02:50:27,840 --> 02:50:28,840
nudge ball Maybe
4051
02:50:30,000 --> 02:50:31,000
and if I go ahead and press play okay we
4052
02:50:32,880 --> 02:50:33,880
have a compilation error so we can check
4053
02:50:35,340 --> 02:50:36,340
what's that
4054
02:50:36,540 --> 02:50:37,540
so it says
4055
02:50:38,819 --> 02:50:39,819
let's read the arrow first of all okay
4056
02:50:41,700 --> 02:50:42,700
it was just uh it just compiled it in
4057
02:50:44,220 --> 02:50:45,220
the wrong order it compiled character
4058
02:50:45,960 --> 02:50:46,960
before this so it didn't know what
4059
02:50:48,540 --> 02:50:49,540
static mesh was now we should be able to
4060
02:50:50,340 --> 02:50:51,340
go ahead and play this and first of all
4061
02:50:52,979 --> 02:50:53,979
we don't have an interaction actor let's
4062
02:50:54,660 --> 02:50:55,660
actually create one go ahead and press
4063
02:50:56,819 --> 02:50:57,819
play
4064
02:50:58,500 --> 02:50:59,500
now if I go ahead and bump into this
4065
02:51:04,380 --> 02:51:05,380
oops I shouldn't have bumped into that
4066
02:51:06,180 --> 02:51:07,180
if I press F on my keyboard when I'm
4067
02:51:08,160 --> 02:51:09,160
overlapping it
4068
02:51:09,540 --> 02:51:10,540
uh the bounce is a little too small let
4069
02:51:11,700 --> 02:51:12,700
me just increase that
4070
02:51:16,439 --> 02:51:17,439
so increase the radius don't scale it up
4071
02:51:21,840 --> 02:51:22,840
and one more thing if you want to see
4072
02:51:23,819 --> 02:51:24,819
the bounds just for testing purposes you
4073
02:51:26,520 --> 02:51:27,520
can set this flag called hidden in game
4074
02:51:28,800 --> 02:51:29,800
to false so now it is going to be
4075
02:51:31,380 --> 02:51:32,380
visible in the game as well
4076
02:51:33,359 --> 02:51:34,359
so if I look around yeah there we have
4077
02:51:36,840 --> 02:51:37,840
it so we can enter our bounds and now if
4078
02:51:39,660 --> 02:51:40,660
I press F on the keyboard you see we
4079
02:51:41,640 --> 02:51:42,640
actually not jit
4080
02:51:43,920 --> 02:51:44,920
so the force is way too small so I can
4081
02:51:46,620 --> 02:51:47,620
go ahead and make this something like 50
4082
02:51:48,660 --> 02:51:49,660
000 let's say
4083
02:51:52,920 --> 02:51:53,920
so if I go ahead and press F over here
4084
02:51:54,660 --> 02:51:55,660
you see we are actually not doing it
4085
02:51:57,540 --> 02:51:58,540
so this is the way you would set up
4086
02:51:59,939 --> 02:52:00,939
interaction using casting obviously you
4087
02:52:03,000 --> 02:52:04,000
can use interfaces to simplify things a
4088
02:52:05,580 --> 02:52:06,580
little bit
4089
02:52:06,479 --> 02:52:07,479
but yeah this is the basic idea
4090
02:52:09,640 --> 02:52:10,640
[Music]
4091
02:52:14,220 --> 02:52:15,220
all right so in order to understand
4092
02:52:16,380 --> 02:52:17,380
whatever I just told now in case it went
4093
02:52:19,080 --> 02:52:20,080
above your head please do Tinker around
4094
02:52:21,540 --> 02:52:22,540
and try some of the functions yourself
4095
02:52:23,960 --> 02:52:24,960
using the context sensitive and the and
4096
02:52:27,840 --> 02:52:28,840
the search bar basically so when you
4097
02:52:29,640 --> 02:52:30,640
right click and let's say you drag
4098
02:52:32,819 --> 02:52:33,819
something off of this you can go ahead
4099
02:52:35,580 --> 02:52:36,580
and type any random function so for
4100
02:52:37,979 --> 02:52:38,979
example if I just press a you get a
4101
02:52:40,500 --> 02:52:41,500
bunch of functions maybe you could have
4102
02:52:42,060 --> 02:52:43,060
a look at all of these maybe have a look
4103
02:52:44,700 --> 02:52:45,700
at documentation and maybe try out some
4104
02:52:47,340 --> 02:52:48,340
of your own logic
4105
02:52:49,200 --> 02:52:50,200
and try out something else maybe add in
4106
02:52:52,260 --> 02:52:53,260
another actor to do something else with
4107
02:52:54,660 --> 02:52:55,660
maybe add in a door and make it open or
4108
02:52:57,240 --> 02:52:58,240
something so you guys should be able to
4109
02:52:59,640 --> 02:53:00,640
try it out yourself and once you are
4110
02:53:02,399 --> 02:53:03,399
actually done with that now we can go
4111
02:53:04,560 --> 02:53:05,560
ahead and talk about the next part now
4112
02:53:07,979 --> 02:53:08,979
until now we talked about the basics and
4113
02:53:11,279 --> 02:53:12,279
I'm pretty sure you can write some basic
4114
02:53:13,080 --> 02:53:14,080
game logic with whatever we have done
4115
02:53:14,939 --> 02:53:15,939
already but there are a couple of
4116
02:53:17,399 --> 02:53:18,399
functions which the engine provides us
4117
02:53:19,500 --> 02:53:20,500
which is going to make our job a lot
4118
02:53:21,300 --> 02:53:22,300
easier
4119
02:53:22,800 --> 02:53:23,800
the first one and one of the most
4120
02:53:25,439 --> 02:53:26,439
commonly used ones which I would like to
4121
02:53:27,300 --> 02:53:28,300
talk about is Ray casting now if you
4122
02:53:30,120 --> 02:53:31,120
guys are familiar with other engines you
4123
02:53:32,160 --> 02:53:33,160
guys would know what a raycast is
4124
02:53:34,319 --> 02:53:35,319
but in Unreal Engine you call it a line
4125
02:53:36,420 --> 02:53:37,420
dress so if I right click and call line
4126
02:53:38,160 --> 02:53:39,160
Trace so you see you get a bunch of
4127
02:53:40,620 --> 02:53:41,620
options the one you'll use most of the
4128
02:53:43,080 --> 02:53:44,080
time is line Trace by Channel multi is
4129
02:53:45,899 --> 02:53:46,899
basically used when you have penetration
4130
02:53:47,760 --> 02:53:48,760
and stuff when you are detecting
4131
02:53:49,380 --> 02:53:50,380
multiple hits in the same line I'll I'll
4132
02:53:51,479 --> 02:53:52,479
tell you guys what's line Trace first
4133
02:53:53,700 --> 02:53:54,700
so line Trace is basically a function
4134
02:53:56,819 --> 02:53:57,819
which lets us draw a line from a given
4135
02:54:00,180 --> 02:54:01,180
starting point to a given ending point
4136
02:54:02,359 --> 02:54:03,359
and in between these two points if you
4137
02:54:05,399 --> 02:54:06,399
are actually hitting anything you are
4138
02:54:07,080 --> 02:54:08,080
going to get it as a hit result
4139
02:54:09,240 --> 02:54:10,240
so I can get access to the hit location
4140
02:54:11,840 --> 02:54:12,840
and in case you want to see the line
4141
02:54:14,279 --> 02:54:15,279
itself you can change this draw debug
4142
02:54:17,700 --> 02:54:18,700
type enum and make this for duration and
4143
02:54:21,120 --> 02:54:22,120
if you guys wondered this is an
4144
02:54:22,859 --> 02:54:23,859
enumeration that's the reason we are
4145
02:54:24,600 --> 02:54:25,600
getting these options so none for one
4146
02:54:27,120 --> 02:54:28,120
frame for duration and persistent are
4147
02:54:29,100 --> 02:54:30,100
the enumerators so if we select for
4148
02:54:32,160 --> 02:54:33,160
duration we are going to get the line
4149
02:54:35,520 --> 02:54:36,520
for some time persistent means the line
4150
02:54:38,279 --> 02:54:39,279
is going to be shown to us forever until
4151
02:54:40,620 --> 02:54:41,620
you close the game of course
4152
02:54:42,660 --> 02:54:43,660
so let's actually do something with this
4153
02:54:45,960 --> 02:54:46,960
so let's actually set up an input event
4154
02:54:48,180 --> 02:54:49,180
let's say when we click our left Mouse
4155
02:54:50,640 --> 02:54:51,640
button so we can type in left Mouse
4156
02:54:52,979 --> 02:54:53,979
now I'm just setting this up brood Force
4157
02:54:55,020 --> 02:54:56,020
because I don't really know what exactly
4158
02:54:58,319 --> 02:54:59,319
we are going to set up once we actually
4159
02:55:00,120 --> 02:55:01,120
get to the examples we'll do that
4160
02:55:02,819 --> 02:55:03,819
now for the start location
4161
02:55:05,939 --> 02:55:06,939
you can choose the camera's location of
4162
02:55:08,640 --> 02:55:09,640
the player because this is where you
4163
02:55:11,399 --> 02:55:12,399
would be seeing stuff so you can select
4164
02:55:13,680 --> 02:55:14,680
the camera's location for example
4165
02:55:16,560 --> 02:55:17,560
so if I go ahead and get the start
4166
02:55:20,160 --> 02:55:21,160
location the way you do that is there
4167
02:55:22,920 --> 02:55:23,920
are a couple of ways
4168
02:55:24,479 --> 02:55:25,479
you could do this and you could do get
4169
02:55:27,120 --> 02:55:28,120
location
4170
02:55:28,380 --> 02:55:29,380
so you can get get World location and
4171
02:55:31,140 --> 02:55:32,140
you could use this as a starting point
4172
02:55:33,600 --> 02:55:34,600
and the way you would go forward towards
4173
02:55:36,960 --> 02:55:37,960
the center of your screen is going to be
4174
02:55:39,420 --> 02:55:40,420
first of all by getting the forward
4175
02:55:40,800 --> 02:55:41,800
vector
4176
02:55:42,060 --> 02:55:43,060
so you can get the forward Vector of
4177
02:55:43,920 --> 02:55:44,920
this camera
4178
02:55:45,439 --> 02:55:46,439
and multiply this by a certain value
4179
02:55:48,720 --> 02:55:49,720
Again by a float
4180
02:55:51,359 --> 02:55:52,359
uh we'll do that add that to the
4181
02:55:54,600 --> 02:55:55,600
starting location so starting location
4182
02:55:58,140 --> 02:55:59,140
plus forward Vector into a certain
4183
02:56:01,439 --> 02:56:02,439
number of a certain number that is going
4184
02:56:04,800 --> 02:56:05,800
to be your end and we can go ahead and
4185
02:56:07,260 --> 02:56:08,260
change this to a float
4186
02:56:10,020 --> 02:56:11,020
and we can do let's say 50 000. I mean
4187
02:56:15,060 --> 02:56:16,060
the number is arbitrary obviously unreal
4188
02:56:17,939 --> 02:56:18,939
uses centimeters remember that
4189
02:56:20,220 --> 02:56:21,220
so anything that you type in will be in
4190
02:56:22,319 --> 02:56:23,319
centimeters so 50 000 centimeters is
4191
02:56:25,439 --> 02:56:26,439
going to be divided by 100 so it's going
4192
02:56:29,220 --> 02:56:30,220
to be like 500 meters
4193
02:56:31,260 --> 02:56:32,260
now if I go ahead and Press Play If I
4194
02:56:33,120 --> 02:56:34,120
press my left Mouse button you see you
4195
02:56:35,580 --> 02:56:36,580
get a line drawn over there so if I
4196
02:56:37,260 --> 02:56:38,260
press f8
4197
02:56:38,460 --> 02:56:39,460
you see I can actually see the line
4198
02:56:40,260 --> 02:56:41,260
which was drawn so the red thing which
4199
02:56:42,720 --> 02:56:43,720
you see that is the line which was drawn
4200
02:56:45,000 --> 02:56:46,000
and as you can see
4201
02:56:47,100 --> 02:56:48,100
uh where where it hit the surface it
4202
02:56:49,680 --> 02:56:50,680
actually registered a hit
4203
02:56:52,140 --> 02:56:53,140
and in order to show that there is one
4204
02:56:55,020 --> 02:56:56,020
more thing which you can do actually Oh
4205
02:56:57,000 --> 02:56:58,000
and about the other options Trace
4206
02:56:59,100 --> 02:57:00,100
channel is something we'll talk about
4207
02:57:00,420 --> 02:57:01,420
later but basically you can do stuff
4208
02:57:03,479 --> 02:57:04,479
like ignoring several uh types of
4209
02:57:06,420 --> 02:57:07,420
objects so let's say you had a shooter
4210
02:57:09,000 --> 02:57:10,000
game and let's say you wanted to like
4211
02:57:11,040 --> 02:57:12,040
ignore teammates you could use it for
4212
02:57:13,020 --> 02:57:14,020
that but you'd use tags for that as well
4213
02:57:15,840 --> 02:57:16,840
but there are several other use cases
4214
02:57:18,240 --> 02:57:19,240
camera is another thing depending on
4215
02:57:21,240 --> 02:57:22,240
what type of objects you want to you
4216
02:57:23,880 --> 02:57:24,880
want the hit to detect you would do that
4217
02:57:25,800 --> 02:57:26,800
and actually if you were to notice if I
4218
02:57:28,920 --> 02:57:29,920
select my mesh and if I scroll down to
4219
02:57:31,319 --> 02:57:32,319
the Collision part
4220
02:57:34,580 --> 02:57:35,580
so I'll just type in Collision instead
4221
02:57:37,560 --> 02:57:38,560
of searching for it like this so
4222
02:57:39,120 --> 02:57:40,120
Collision
4223
02:57:40,800 --> 02:57:41,800
you have to notice it says character
4224
02:57:43,080 --> 02:57:44,080
mesh for the preset and over here if you
4225
02:57:45,779 --> 02:57:46,779
see there is actually visibility and
4226
02:57:47,760 --> 02:57:48,760
camera so what you can do is you can
4227
02:57:51,240 --> 02:57:52,240
actually make it block certain things so
4228
02:57:54,180 --> 02:57:55,180
now let's say I wanted this line Trace
4229
02:57:57,180 --> 02:57:58,180
which is using visibility right now to
4230
02:57:59,160 --> 02:58:00,160
block it I would have to change this to
4231
02:58:01,680 --> 02:58:02,680
custom and make this one block
4232
02:58:04,500 --> 02:58:05,500
visibility so then I would be able to
4233
02:58:07,760 --> 02:58:08,760
I would be able to make this line block
4234
02:58:10,380 --> 02:58:11,380
it
4235
02:58:11,819 --> 02:58:12,819
stuff like that which you could do now
4236
02:58:14,399 --> 02:58:15,399
obviously I'll change it back to
4237
02:58:15,720 --> 02:58:16,720
character mesh we didn't do anything but
4238
02:58:17,580 --> 02:58:18,580
still
4239
02:58:18,359 --> 02:58:19,359
so over here change it back to character
4240
02:58:22,140 --> 02:58:23,140
mesh
4241
02:58:23,160 --> 02:58:24,160
and let's say you wanted to ignore the
4242
02:58:25,740 --> 02:58:26,740
camera Channel you could do that as well
4243
02:58:28,380 --> 02:58:29,380
now let's say you wanted to just Mark
4244
02:58:32,279 --> 02:58:33,279
the place where you actually hit so now
4245
02:58:34,319 --> 02:58:35,319
we have access to the hit location so
4246
02:58:36,540 --> 02:58:37,540
there is a function called Draw debug
4247
02:58:38,700 --> 02:58:39,700
sphere
4248
02:58:39,660 --> 02:58:40,660
you can actually draw many other shapes
4249
02:58:41,760 --> 02:58:42,760
but sphere is the one which you'll use
4250
02:58:43,560 --> 02:58:44,560
most often
4251
02:58:45,600 --> 02:58:46,600
and the center is obviously the place
4252
02:58:48,060 --> 02:58:49,060
where you hit it so out hit location
4253
02:58:50,939 --> 02:58:51,939
and radius 100 maybe we can have 10
4254
02:58:54,180 --> 02:58:55,180
seconds for the duration and thickness
4255
02:58:56,580 --> 02:58:57,580
let's just say two units line color
4256
02:58:59,640 --> 02:59:00,640
let's set that to maybe something like a
4257
02:59:02,040 --> 02:59:03,040
greenish yellow or something
4258
02:59:03,899 --> 02:59:04,899
now if I go ahead and Press Play If I
4259
02:59:06,300 --> 02:59:07,300
left click you see it's drawing a sphere
4260
02:59:08,520 --> 02:59:09,520
where it actually hit it
4261
02:59:10,560 --> 02:59:11,560
and you could change some of the
4262
02:59:12,240 --> 02:59:13,240
properties let's say you wanted a more
4263
02:59:15,200 --> 02:59:16,200
details here I don't know why you would
4264
02:59:17,460 --> 02:59:18,460
want that though and maybe reduce the
4265
02:59:19,740 --> 02:59:20,740
radius of the sphere you could do that
4266
02:59:21,359 --> 02:59:22,359
as well
4267
02:59:23,460 --> 02:59:24,460
so as you can see we are registering a
4268
02:59:26,220 --> 02:59:27,220
hit over there so that's what it's
4269
02:59:28,140 --> 02:59:29,140
basically showing us
4270
02:59:29,580 --> 02:59:30,580
so this is how you do a line Trace
4271
02:59:31,680 --> 02:59:32,680
basically you draw a line from one end
4272
02:59:33,240 --> 02:59:34,240
to the other and you can detect hits
4273
02:59:34,640 --> 02:59:35,640
obviously for shooting a weapon and
4274
02:59:37,500 --> 02:59:38,500
stuff like that you use it now there is
4275
02:59:39,840 --> 02:59:40,840
another way you can actually determine
4276
02:59:41,700 --> 02:59:42,700
the start and end location now whatever
4277
02:59:44,880 --> 02:59:45,880
logic you have here is fine if you only
4278
02:59:47,760 --> 02:59:48,760
have one camera but what if you had a
4279
02:59:50,760 --> 02:59:51,760
first person view and a third person
4280
02:59:52,319 --> 02:59:53,319
view for example let's say you had two
4281
02:59:54,120 --> 02:59:55,120
cameras
4282
02:59:55,140 --> 02:59:56,140
you cannot check which camera you are
4283
02:59:58,020 --> 02:59:59,020
using and stuff that would make the
4284
02:59:59,700 --> 03:00:00,700
logic complicated so the way you do it
4285
03:00:02,220 --> 03:00:03,220
is you would use a function called get
4286
03:00:04,500 --> 03:00:05,500
player camera manager
4287
03:00:06,840 --> 03:00:07,840
now this is going to get the current
4288
03:00:09,000 --> 03:00:10,000
camera which you're using and it's going
4289
03:00:11,819 --> 03:00:12,819
to be an actor so we can just type in
4290
03:00:14,880 --> 03:00:15,880
get actor location
4291
03:00:17,819 --> 03:00:18,819
and this is going to be your camera's
4292
03:00:20,340 --> 03:00:21,340
location so let's say you switch between
4293
03:00:21,840 --> 03:00:22,840
cameras this is going to work
4294
03:00:24,620 --> 03:00:25,620
universally regardless of which camera
4295
03:00:26,880 --> 03:00:27,880
you're using however since in this logic
4296
03:00:29,760 --> 03:00:30,760
we are using this camera's reference
4297
03:00:31,740 --> 03:00:32,740
let's say we had another camera this
4298
03:00:34,140 --> 03:00:35,140
logic is not going to work it is going
4299
03:00:35,939 --> 03:00:36,939
to work with respect to this camera
4300
03:00:38,880 --> 03:00:39,880
so instead of this I can go ahead and
4301
03:00:41,399 --> 03:00:42,399
replace it
4302
03:00:43,340 --> 03:00:44,340
and we can get the actor for Vector
4303
03:00:46,380 --> 03:00:47,380
again
4304
03:00:47,880 --> 03:00:48,880
get actor forward vector
4305
03:00:50,460 --> 03:00:51,460
and we can replace this by this
4306
03:00:54,960 --> 03:00:55,960
and we can go ahead and delete it and
4307
03:00:57,120 --> 03:00:58,120
the rest of the logic Remains the Same
4308
03:00:58,859 --> 03:00:59,859
obviously and now if I were to press
4309
03:01:01,380 --> 03:01:02,380
play you would see that the logic does
4310
03:01:04,260 --> 03:01:05,260
not work okay we didn't plug it in so
4311
03:01:07,080 --> 03:01:08,080
the actor location is going to be the
4312
03:01:08,700 --> 03:01:09,700
start of course not zero
4313
03:01:11,160 --> 03:01:12,160
press play and the logic works exactly
4314
03:01:13,859 --> 03:01:14,859
the same one more thing you'll notice is
4315
03:01:15,960 --> 03:01:16,960
that the line Trace is going exactly to
4316
03:01:18,240 --> 03:01:19,240
the center of our screen if you were to
4317
03:01:19,859 --> 03:01:20,859
notice
4318
03:01:21,180 --> 03:01:22,180
that's one more thing the reason it's
4319
03:01:23,520 --> 03:01:24,520
happening like that is because we are
4320
03:01:26,460 --> 03:01:27,460
going from the center of our Viewpoint
4321
03:01:28,800 --> 03:01:29,800
and going exactly forward to the view so
4322
03:01:32,460 --> 03:01:33,460
that's the reason it's actually going
4323
03:01:34,080 --> 03:01:35,080
right at the center of the screen and if
4324
03:01:36,359 --> 03:01:37,359
you add a Crosshair in game it would
4325
03:01:37,920 --> 03:01:38,920
land right at the center
4326
03:01:40,439 --> 03:01:41,439
so this was recasting there are many
4327
03:01:43,319 --> 03:01:44,319
other options as well such as hit actor
4328
03:01:45,540 --> 03:01:46,540
so you can cast it so let's say we cast
4329
03:01:48,120 --> 03:01:49,120
it to pick up for example so we can
4330
03:01:50,760 --> 03:01:51,760
check if we actually hit the pickup so
4331
03:01:53,340 --> 03:01:54,340
if we actually did hit a pickup what we
4332
03:01:55,800 --> 03:01:56,800
can do in fact is we can go ahead and
4333
03:01:58,920 --> 03:01:59,920
run some logic let's say we destroy it
4334
03:02:02,279 --> 03:02:03,279
so I'm just showing you guys one more
4335
03:02:04,020 --> 03:02:05,020
example to make things clear
4336
03:02:06,000 --> 03:02:07,000
so if I press play
4337
03:02:07,740 --> 03:02:08,740
so that's not the pickup so nothing
4338
03:02:10,260 --> 03:02:11,260
happened but if I hit a pickup as you
4339
03:02:12,840 --> 03:02:13,840
can see we are destroying it so
4340
03:02:14,640 --> 03:02:15,640
something like a gun
4341
03:02:16,920 --> 03:02:17,920
[Music]
4342
03:02:21,180 --> 03:02:22,180
all this is fine but we do not have any
4343
03:02:24,240 --> 03:02:25,240
sort of a user interface now apart from
4344
03:02:27,420 --> 03:02:28,420
the lighting needs to be rebuilt then
4345
03:02:29,340 --> 03:02:30,340
you can actually delete that by typing
4346
03:02:31,680 --> 03:02:32,680
in disable all screen messages
4347
03:02:34,500 --> 03:02:35,500
so oops I didn't type that so disable
4348
03:02:37,140 --> 03:02:38,140
all screen messages
4349
03:02:39,359 --> 03:02:40,359
so you can go ahead and type that and
4350
03:02:41,460 --> 03:02:42,460
it's going to remove that
4351
03:02:43,800 --> 03:02:44,800
so there's nothing much really we don't
4352
03:02:46,620 --> 03:02:47,620
even have a simple health bar so we can
4353
03:02:48,540 --> 03:02:49,540
go ahead and add a couple of components
4354
03:02:50,520 --> 03:02:51,520
on screen
4355
03:02:51,840 --> 03:02:52,840
so in order to create widgets on the
4356
03:02:54,300 --> 03:02:55,300
screen if you want user interfaces the
4357
03:02:57,060 --> 03:02:58,060
way you do that is using widget
4358
03:02:58,620 --> 03:02:59,620
blueprints so let's get to that inside
4359
03:03:01,140 --> 03:03:02,140
your content folder I want you guys to
4360
03:03:03,180 --> 03:03:04,180
create a new folder and we can call this
4361
03:03:05,160 --> 03:03:06,160
one UI
4362
03:03:06,840 --> 03:03:07,840
and inside this we can call this one for
4363
03:03:10,680 --> 03:03:11,680
example HUD to denote heads up display
4364
03:03:14,180 --> 03:03:15,180
now open it up and inside this folder
4365
03:03:17,819 --> 03:03:18,819
right click and create a widget
4366
03:03:20,460 --> 03:03:21,460
blueprint by heading into user interface
4367
03:03:22,560 --> 03:03:23,560
now you could do it through the
4368
03:03:25,200 --> 03:03:26,200
blueprint class menu as well type in
4369
03:03:27,120 --> 03:03:28,120
widget blueprint you should you should
4370
03:03:29,399 --> 03:03:30,399
find a widget blueprint somewhere over
4371
03:03:31,380 --> 03:03:32,380
here so user widget is the one actually
4372
03:03:34,020 --> 03:03:35,020
so go ahead and select that and we can
4373
03:03:37,439 --> 03:03:38,439
call this one HUD
4374
03:03:39,479 --> 03:03:40,479
BP underscore HUD generally I also like
4375
03:03:43,500 --> 03:03:44,500
to add underscore WB to represent widget
4376
03:03:46,620 --> 03:03:47,620
blueprint but if we are going to have
4377
03:03:49,200 --> 03:03:50,200
separate folders for each one it's not
4378
03:03:51,180 --> 03:03:52,180
really required
4379
03:03:52,920 --> 03:03:53,920
open it up and you will get a blank
4380
03:03:55,560 --> 03:03:56,560
canvas
4381
03:03:56,640 --> 03:03:57,640
and you'll have two tabs over here on
4382
03:03:58,620 --> 03:03:59,620
the top you have a designer and a graph
4383
03:04:00,779 --> 03:04:01,779
as well
4384
03:04:01,800 --> 03:04:02,800
so what we'll be using most of the time
4385
03:04:04,680 --> 03:04:05,680
is the designer and to add the logic for
4386
03:04:07,140 --> 03:04:08,140
it we are going to use the graph if you
4387
03:04:10,140 --> 03:04:11,140
guys have used the QT framework in C
4388
03:04:13,080 --> 03:04:14,080
plus plus the functions and stuff work
4389
03:04:16,319 --> 03:04:17,319
pretty similarly over here but since
4390
03:04:18,960 --> 03:04:19,960
this is going to be in Blueprint it's
4391
03:04:21,060 --> 03:04:22,060
going to be much much easier to
4392
03:04:22,439 --> 03:04:23,439
comprehend
4393
03:04:24,120 --> 03:04:25,120
now the most basic type of widget that
4394
03:04:27,660 --> 03:04:28,660
you can add is a canvas panel so add in
4395
03:04:30,359 --> 03:04:31,359
a canvas panel before this actually used
4396
03:04:32,399 --> 03:04:33,399
to come by default without you having to
4397
03:04:34,859 --> 03:04:35,859
actually add it now you won't worry
4398
03:04:37,080 --> 03:04:38,080
about most of the settings actually the
4399
03:04:39,540 --> 03:04:40,540
only thing that you'll worry about is
4400
03:04:41,279 --> 03:04:42,279
custom or fill screen actually these are
4401
03:04:43,620 --> 03:04:44,620
the only two which you'll most probably
4402
03:04:45,300 --> 03:04:46,300
use custom is basically used if you have
4403
03:04:49,260 --> 03:04:50,260
stuff like drop down and you're making
4404
03:04:51,120 --> 03:04:52,120
like a child widget for something
4405
03:04:53,479 --> 03:04:54,479
and I will show you guys examples for
4406
03:04:56,640 --> 03:04:57,640
that when we go to the higher level part
4407
03:04:58,560 --> 03:04:59,560
so for now we'll use fill screen so this
4408
03:05:00,960 --> 03:05:01,960
is going to take up the entire screen
4409
03:05:03,600 --> 03:05:04,600
now in order to actually create this now
4410
03:05:05,819 --> 03:05:06,819
there is nothing but we we can just
4411
03:05:07,680 --> 03:05:08,680
create it nonetheless
4412
03:05:09,180 --> 03:05:10,180
generally it's not advisable to create
4413
03:05:11,340 --> 03:05:12,340
it in in the character widgets usually
4414
03:05:14,520 --> 03:05:15,520
would be created in something a little
4415
03:05:16,200 --> 03:05:17,200
more persistent such as a player
4416
03:05:18,420 --> 03:05:19,420
controller so we have one setup already
4417
03:05:20,580 --> 03:05:21,580
so we make sure you set that in the game
4418
03:05:22,920 --> 03:05:23,920
mode open it up and we could do it on
4419
03:05:26,220 --> 03:05:27,220
begin play
4420
03:05:27,720 --> 03:05:28,720
add in a custom event and this is where
4421
03:05:30,240 --> 03:05:31,240
you actually use custom events so you
4422
03:05:33,000 --> 03:05:34,000
could use a function no harm with that
4423
03:05:34,920 --> 03:05:35,920
but let's use custom events this is what
4424
03:05:37,800 --> 03:05:38,800
you would use them for
4425
03:05:39,420 --> 03:05:40,420
so we are going to be calling this one
4426
03:05:41,460 --> 03:05:42,460
for example create HUD
4427
03:05:44,399 --> 03:05:45,399
and we can call that so create HUD
4428
03:05:49,200 --> 03:05:50,200
over here we can go ahead and type in
4429
03:05:52,979 --> 03:05:53,979
create widget
4430
03:05:55,859 --> 03:05:56,859
we'll get to select it so BP HUD does
4431
03:05:58,439 --> 03:05:59,439
what we want to create and we can
4432
03:06:00,120 --> 03:06:01,120
promote this to a variable and call this
4433
03:06:02,460 --> 03:06:03,460
one HUD
4434
03:06:03,660 --> 03:06:04,660
or you could call it hardref if you
4435
03:06:06,060 --> 03:06:07,060
really want to be that specific
4436
03:06:08,760 --> 03:06:09,760
now we have a reference to the HUD
4437
03:06:10,439 --> 03:06:11,439
however we still haven't actually
4438
03:06:12,479 --> 03:06:13,479
created it we have just internally
4439
03:06:15,540 --> 03:06:16,540
stored it but if you want to show it on
4440
03:06:17,939 --> 03:06:18,939
the screen type in add to viewport
4441
03:06:23,399 --> 03:06:24,399
so now this should be added to your
4442
03:06:27,120 --> 03:06:28,120
screen
4443
03:06:28,740 --> 03:06:29,740
however there is there is another thing
4444
03:06:31,680 --> 03:06:32,680
which you could do actually there is
4445
03:06:33,240 --> 03:06:34,240
another option called add to player
4446
03:06:35,580 --> 03:06:36,580
screen
4447
03:06:36,840 --> 03:06:37,840
however this is not really used that
4448
03:06:40,260 --> 03:06:41,260
much so this is usually used for split
4449
03:06:43,380 --> 03:06:44,380
screen and stuff like that will not get
4450
03:06:45,359 --> 03:06:46,359
into this so you'll use add to viewport
4451
03:06:47,460 --> 03:06:48,460
most of the times
4452
03:06:49,140 --> 03:06:50,140
all right so now under your HUD
4453
03:06:52,380 --> 03:06:53,380
for the health bar obviously we need a
4454
03:06:54,479 --> 03:06:55,479
progress bar so type in progress bar and
4455
03:06:57,300 --> 03:06:58,300
unreal has everything built in for us so
4456
03:07:00,000 --> 03:07:01,000
let's add it at the bottom left hand
4457
03:07:01,560 --> 03:07:02,560
side of the screen that's the reason I
4458
03:07:03,660 --> 03:07:04,660
chose the canvas panel
4459
03:07:05,819 --> 03:07:06,819
so that we can easily uh just drag stuff
4460
03:07:09,540 --> 03:07:10,540
in with other types of widget it's
4461
03:07:12,000 --> 03:07:13,000
usually like a layout which you create
4462
03:07:13,800 --> 03:07:14,800
so it's going to be harder for you to
4463
03:07:16,680 --> 03:07:17,680
just move things around
4464
03:07:19,140 --> 03:07:20,140
all right so let's add the progress bar
4465
03:07:21,660 --> 03:07:22,660
and on the right hand side under the
4466
03:07:23,760 --> 03:07:24,760
details panel we can rename it we can
4467
03:07:25,380 --> 03:07:26,380
call this one health bar
4468
03:07:27,479 --> 03:07:28,479
and we can set all sorts of parameters
4469
03:07:29,880 --> 03:07:30,880
maybe we can make this one 350 by 45
4470
03:07:35,279 --> 03:07:36,279
and over here you'll see another tab
4471
03:07:38,100 --> 03:07:39,100
called anchors now anchor is basically
4472
03:07:41,520 --> 03:07:42,520
telling you the position with respect to
4473
03:07:44,939 --> 03:07:45,939
it basically for example let's say set
4474
03:07:47,279 --> 03:07:48,279
it to bottom left in this case bottom
4475
03:07:49,680 --> 03:07:50,680
left is ideal
4476
03:07:51,180 --> 03:07:52,180
so this is going to be your 0 comma 0
4477
03:07:54,840 --> 03:07:55,840
and with respect to that your Y and your
4478
03:07:57,840 --> 03:07:58,840
other values are going to be set so when
4479
03:08:00,779 --> 03:08:01,779
I say the anchor is at the bottom left
4480
03:08:03,000 --> 03:08:04,000
and my position is 88 what I mean is I
4481
03:08:06,479 --> 03:08:07,479
have placed this progress bar 88 units
4482
03:08:09,180 --> 03:08:10,180
to the right of this anchor
4483
03:08:11,700 --> 03:08:12,700
and Y is basically your vertical
4484
03:08:15,180 --> 03:08:16,180
Direction so minus 120 is 120 units
4485
03:08:18,960 --> 03:08:19,960
upwards basically
4486
03:08:20,880 --> 03:08:21,880
and size X and size y will remain the
4487
03:08:23,580 --> 03:08:24,580
same
4488
03:08:24,560 --> 03:08:25,560
alignment is basically telling you what
4489
03:08:28,140 --> 03:08:29,140
to take as this the reference point so
4490
03:08:31,140 --> 03:08:32,140
if I make this 0.5
4491
03:08:33,120 --> 03:08:34,120
you see it's going to Center off so it's
4492
03:08:35,880 --> 03:08:36,880
the distance between this and the center
4493
03:08:37,740 --> 03:08:38,740
now
4494
03:08:38,760 --> 03:08:39,760
same with the Y so if I type in 0.5 it
4495
03:08:40,979 --> 03:08:41,979
will move a little bit down or up
4496
03:08:42,779 --> 03:08:43,779
actually because it was over here so now
4497
03:08:45,600 --> 03:08:46,600
the point shifted over there so it moved
4498
03:08:47,939 --> 03:08:48,939
a bit up and if you want to Center
4499
03:08:50,580 --> 03:08:51,580
something exactly at the center of the
4500
03:08:52,680 --> 03:08:53,680
screen so for example across here so you
4501
03:08:55,020 --> 03:08:56,020
would set the anchor to be this the
4502
03:08:57,359 --> 03:08:58,359
center one
4503
03:08:58,979 --> 03:08:59,979
and over here you will change the
4504
03:09:01,439 --> 03:09:02,439
alignment to 0.5 and set the position to
4505
03:09:03,899 --> 03:09:04,899
0 and 0. now this is going to be
4506
03:09:05,819 --> 03:09:06,819
perfectly centered regardless of your
4507
03:09:07,680 --> 03:09:08,680
resolution
4508
03:09:09,120 --> 03:09:10,120
now another reason to actually use this
4509
03:09:14,160 --> 03:09:15,160
so let me just actually move this back
4510
03:09:16,260 --> 03:09:17,260
so zero zero
4511
03:09:19,020 --> 03:09:20,020
another reason to use anchors is for
4512
03:09:21,060 --> 03:09:22,060
different resolutions let's say you had
4513
03:09:23,340 --> 03:09:24,340
an 800 by 600 screen let's say somebody
4514
03:09:25,859 --> 03:09:26,859
is playing with that and you had a
4515
03:09:27,960 --> 03:09:28,960
progress bar over here
4516
03:09:29,580 --> 03:09:30,580
let's say you left it at the default
4517
03:09:32,460 --> 03:09:33,460
anchor let's say you didn't actually
4518
03:09:34,200 --> 03:09:35,200
modify the anchors this widget is
4519
03:09:37,140 --> 03:09:38,140
actually going to go outside the player
4520
03:09:39,180 --> 03:09:40,180
screen
4521
03:09:40,020 --> 03:09:41,020
however if you change the anchor to the
4522
03:09:42,840 --> 03:09:43,840
bottom right now this widget is
4523
03:09:46,560 --> 03:09:47,560
minus 461 and minus 137 relative to the
4524
03:09:51,479 --> 03:09:52,479
bottom right corner so then it will
4525
03:09:53,520 --> 03:09:54,520
always be inside the screen so that's
4526
03:09:55,979 --> 03:09:56,979
another reason to use anchor so I'll go
4527
03:09:57,840 --> 03:09:58,840
ahead and undo all of that
4528
03:09:59,760 --> 03:10:00,760
so that should be good now if I go ahead
4529
03:10:03,000 --> 03:10:04,000
and create this so in apply controller
4530
03:10:05,460 --> 03:10:06,460
on begin play we are actually creating
4531
03:10:07,260 --> 03:10:08,260
it now if I go ahead and press play you
4532
03:10:09,479 --> 03:10:10,479
see we see our progress bar and since we
4533
03:10:11,580 --> 03:10:12,580
have our anchor over here you see it
4534
03:10:13,680 --> 03:10:14,680
always stays at the same relative
4535
03:10:15,359 --> 03:10:16,359
position on the screen
4536
03:10:17,939 --> 03:10:18,939
the next thing that you obviously want
4537
03:10:20,340 --> 03:10:21,340
to do is actually bring in the values of
4538
03:10:23,040 --> 03:10:24,040
Health from the character to the actual
4539
03:10:25,680 --> 03:10:26,680
widget so it's actually pretty simple to
4540
03:10:28,920 --> 03:10:29,920
do that so let's go step by step there
4541
03:10:31,560 --> 03:10:32,560
are quite a few ways you in which you
4542
03:10:33,359 --> 03:10:34,359
can do it so if you would have created
4543
03:10:35,760 --> 03:10:36,760
the widget on the character it would
4544
03:10:37,979 --> 03:10:38,979
have been simple to just pass in the
4545
03:10:39,840 --> 03:10:40,840
health value to the widget however since
4546
03:10:42,180 --> 03:10:43,180
we have done it in the player control
4547
03:10:43,500 --> 03:10:44,500
there is an extra step but nothing to be
4548
03:10:47,100 --> 03:10:48,100
worried about
4549
03:10:48,260 --> 03:10:49,260
so now let's create an event in the
4550
03:10:51,359 --> 03:10:52,359
player controller so that we can
4551
03:10:53,160 --> 03:10:54,160
actually interact with the widget
4552
03:10:55,500 --> 03:10:56,500
so we can call this one update health
4553
03:10:57,180 --> 03:10:58,180
for example so type in custom event and
4554
03:10:59,700 --> 03:11:00,700
call this one update help
4555
03:11:02,600 --> 03:11:03,600
and for the new value we can go ahead
4556
03:11:05,520 --> 03:11:06,520
and add in an input and it's going to be
4557
03:11:08,700 --> 03:11:09,700
of type float obviously and we'll call
4558
03:11:11,279 --> 03:11:12,279
this one new health
4559
03:11:14,399 --> 03:11:15,399
now over here in the progress bar we can
4560
03:11:17,460 --> 03:11:18,460
go ahead and create another event or we
4561
03:11:19,439 --> 03:11:20,439
could even directly adjust it here so we
4562
03:11:22,560 --> 03:11:23,560
could get the HUD
4563
03:11:23,760 --> 03:11:24,760
and over here we could type in first of
4564
03:11:27,300 --> 03:11:28,300
all let's check if our progress bar is a
4565
03:11:29,160 --> 03:11:30,160
variable make sure it's set to is
4566
03:11:31,020 --> 03:11:32,020
variable otherwise you won't be able to
4567
03:11:32,640 --> 03:11:33,640
access it
4568
03:11:33,779 --> 03:11:34,779
so if once that is variable get the
4569
03:11:36,180 --> 03:11:37,180
health bar
4570
03:11:37,880 --> 03:11:38,880
and again this is where your blue print
4571
03:11:41,100 --> 03:11:42,100
menu is going to help you a lot now you
4572
03:11:44,580 --> 03:11:45,580
want to set the percentage so type in
4573
03:11:47,640 --> 03:11:48,640
set percent
4574
03:11:50,279 --> 03:11:51,279
you will go ahead and get this node now
4575
03:11:52,620 --> 03:11:53,620
in case you guys don't know this percent
4576
03:11:55,319 --> 03:11:56,319
is going to be a value between 0 and 1
4577
03:11:57,720 --> 03:11:58,720
and our health is a value between 0 and
4578
03:12:00,180 --> 03:12:01,180
100 so let's just divide this by 100.
4579
03:12:04,859 --> 03:12:05,859
so do that or you could make your health
4580
03:12:07,020 --> 03:12:08,020
variables store 0 to 1 that works too
4581
03:12:09,960 --> 03:12:10,960
all right so you can do that or you
4582
03:12:12,240 --> 03:12:13,240
could have a custom event inside your BP
4583
03:12:15,060 --> 03:12:16,060
HUD that works too
4584
03:12:17,100 --> 03:12:18,100
so let's head back into a character now
4585
03:12:20,399 --> 03:12:21,399
and what we can do is we can actually do
4586
03:12:24,000 --> 03:12:25,000
something so let's say when we actually
4587
03:12:26,520 --> 03:12:27,520
pick something up let's say we reduce
4588
03:12:28,800 --> 03:12:29,800
our health for example so we can head
4589
03:12:31,680 --> 03:12:32,680
into our interaction so when we pick it
4590
03:12:34,200 --> 03:12:35,200
up let's say we reduce our health by 10
4591
03:12:36,840 --> 03:12:37,840
maybe
4592
03:12:37,939 --> 03:12:38,939
now if it is valid we destroy it and we
4593
03:12:41,220 --> 03:12:42,220
invalidate the nearby pickup and let's
4594
03:12:43,979 --> 03:12:44,979
reduce our health by 10. so create a
4595
03:12:46,920 --> 03:12:47,920
health variable first of all now health
4596
03:12:49,140 --> 03:12:50,140
is a variable which is dependent on
4597
03:12:52,319 --> 03:12:53,319
which character you are in so that's why
4598
03:12:54,359 --> 03:12:55,359
we are creating it in the character make
4599
03:12:56,760 --> 03:12:57,760
this private
4600
03:12:58,680 --> 03:12:59,680
over here
4601
03:13:00,060 --> 03:13:01,060
make this variable private
4602
03:13:02,899 --> 03:13:03,899
and we can go ahead and set the health
4603
03:13:07,680 --> 03:13:08,680
to be equal to whoops
4604
03:13:09,899 --> 03:13:10,899
we can go ahead and set the health to be
4605
03:13:12,120 --> 03:13:13,120
equal to health
4606
03:13:13,920 --> 03:13:14,920
minus
4607
03:13:15,779 --> 03:13:16,779
10.
4608
03:13:18,000 --> 03:13:19,000
and we don't want it to actually go
4609
03:13:22,439 --> 03:13:23,439
below zero so we can go ahead and clamp
4610
03:13:24,840 --> 03:13:25,840
the value so we can call this one clamp
4611
03:13:28,140 --> 03:13:29,140
so clamp float minimum is 0 maximum is
4612
03:13:31,979 --> 03:13:32,979
100 obviously
4613
03:13:34,800 --> 03:13:35,800
so I can go ahead and set it now if our
4614
03:13:37,800 --> 03:13:38,800
health is zero so if our health is less
4615
03:13:39,960 --> 03:13:40,960
than or equal to 0 if you don't clamp it
4616
03:13:42,479 --> 03:13:43,479
you can check for less than or equal to
4617
03:13:44,160 --> 03:13:45,160
so let's do that actually
4618
03:13:46,380 --> 03:13:47,380
so if our health is less than or equal
4619
03:13:49,020 --> 03:13:50,020
to 0
4620
03:13:50,460 --> 03:13:51,460
whoops less than or equal to zero
4621
03:13:53,819 --> 03:13:54,819
we can go ahead and just kill our player
4622
03:13:57,180 --> 03:13:58,180
so instead of killing it let's just exit
4623
03:13:59,520 --> 03:14:00,520
the game instead so we can call
4624
03:14:02,760 --> 03:14:03,760
we can execute a console command so type
4625
03:14:05,340 --> 03:14:06,340
in execute console command
4626
03:14:07,800 --> 03:14:08,800
and this one will simply type in exit
4627
03:14:10,740 --> 03:14:11,740
it's going to exit the game even quit
4628
03:14:12,840 --> 03:14:13,840
works
4629
03:14:14,100 --> 03:14:15,100
now this is something which you might
4630
03:14:15,960 --> 03:14:16,960
need multiple times
4631
03:14:17,939 --> 03:14:18,939
so what we can do instead of this is we
4632
03:14:20,640 --> 03:14:21,640
can actually make a set Health function
4633
03:14:22,260 --> 03:14:23,260
because we want to exit the game even if
4634
03:14:25,740 --> 03:14:26,740
our health is reduced for some other
4635
03:14:27,479 --> 03:14:28,479
reason
4636
03:14:28,319 --> 03:14:29,319
so here in this case we picked it up so
4637
03:14:31,020 --> 03:14:32,020
our health reduced but we want to be
4638
03:14:33,359 --> 03:14:34,359
able to reuse this so right click
4639
03:14:35,279 --> 03:14:36,279
collapse the store function and call
4640
03:14:37,560 --> 03:14:38,560
this one set health
4641
03:14:40,260 --> 03:14:41,260
now let's say you don't want this to be
4642
03:14:42,420 --> 03:14:43,420
able to call it on the other blueprints
4643
03:14:44,279 --> 03:14:45,279
so let's say you want to only be able to
4644
03:14:46,260 --> 03:14:47,260
call it in this BP character you can
4645
03:14:48,600 --> 03:14:49,600
make it a macro instead and obviously we
4646
03:14:51,420 --> 03:14:52,420
need the health value so grab in health
4647
03:14:54,359 --> 03:14:55,359
and head back into your event graph pick
4648
03:14:57,060 --> 03:14:58,060
up over here we can go ahead and pass in
4649
03:15:00,120 --> 03:15:01,120
the health so this is going to handle
4650
03:15:02,100 --> 03:15:03,100
everything for us and let's actually
4651
03:15:04,680 --> 03:15:05,680
make this a larger value let's say 40.
4652
03:15:07,200 --> 03:15:08,200
so on our third pickup in theory we
4653
03:15:09,240 --> 03:15:10,240
should exit our game
4654
03:15:10,800 --> 03:15:11,800
and if it is not less than or equal to
4655
03:15:13,080 --> 03:15:14,080
zero uh we can go ahead and update the
4656
03:15:16,020 --> 03:15:17,020
progress bar first things first and
4657
03:15:18,420 --> 03:15:19,420
remember we had our play controller
4658
03:15:20,160 --> 03:15:21,160
reference now we can go ahead and use
4659
03:15:22,500 --> 03:15:23,500
that
4660
03:15:23,520 --> 03:15:24,520
so regardless of what we do we want to
4661
03:15:25,859 --> 03:15:26,859
update the helper I mean we'll exit over
4662
03:15:27,600 --> 03:15:28,600
here so we don't need to update it so we
4663
03:15:30,120 --> 03:15:31,120
can type in update health
4664
03:15:33,000 --> 03:15:34,000
and new health is going to be our health
4665
03:15:35,520 --> 03:15:36,520
variable
4666
03:15:38,220 --> 03:15:39,220
now some people might show you how to do
4667
03:15:42,120 --> 03:15:43,120
this using a binding so you can actually
4668
03:15:44,939 --> 03:15:45,939
go into your progress bar and you can
4669
03:15:46,680 --> 03:15:47,680
type in bind and create a binding
4670
03:15:49,020 --> 03:15:50,020
however this is very very inefficient
4671
03:15:52,319 --> 03:15:53,319
and it is going to run on tick so
4672
03:15:55,260 --> 03:15:56,260
actually don't really bother using that
4673
03:15:57,479 --> 03:15:58,479
do it the way I am showing you guys this
4674
03:15:59,520 --> 03:16:00,520
is the proper way to do it however there
4675
03:16:01,920 --> 03:16:02,920
is a good there is a small chance that
4676
03:16:04,200 --> 03:16:05,200
it might miss it might not update but
4677
03:16:07,620 --> 03:16:08,620
that's nothing to worry about it's going
4678
03:16:09,300 --> 03:16:10,300
to be like one in a million maybe so it
4679
03:16:11,819 --> 03:16:12,819
honestly doesn't matter
4680
03:16:13,620 --> 03:16:14,620
so once that said we should be good to
4681
03:16:16,260 --> 03:16:17,260
go and make sure by default your health
4682
03:16:18,420 --> 03:16:19,420
is set to 100
4683
03:16:20,640 --> 03:16:21,640
and once just update the progress bar
4684
03:16:23,640 --> 03:16:24,640
once you set the player controller
4685
03:16:25,859 --> 03:16:26,859
reference because we are not actually
4686
03:16:27,120 --> 03:16:28,120
setting the health by default
4687
03:16:29,160 --> 03:16:30,160
uh in the heart you could set it however
4688
03:16:31,800 --> 03:16:32,800
what if a player disconnected from a
4689
03:16:34,500 --> 03:16:35,500
match and is coming back so you don't
4690
03:16:36,180 --> 03:16:37,180
want it to be 100 because you'll be
4691
03:16:37,859 --> 03:16:38,859
creating the widget once again right so
4692
03:16:40,740 --> 03:16:41,740
set it once you get the player
4693
03:16:42,359 --> 03:16:43,359
controller so in our initialize function
4694
03:16:45,479 --> 03:16:46,479
once we get the play controller
4695
03:16:47,460 --> 03:16:48,460
reference we can go ahead and set that
4696
03:16:50,160 --> 03:16:51,160
and we'll clear the timer at the last
4697
03:16:53,340 --> 03:16:54,340
order doesn't matter here since this
4698
03:16:55,620 --> 03:16:56,620
function is already being executed the
4699
03:16:58,319 --> 03:16:59,319
order honestly doesn't matter but we can
4700
03:17:00,720 --> 03:17:01,720
do it like this
4701
03:17:01,920 --> 03:17:02,920
now if I go ahead and press play you'd
4702
03:17:04,800 --> 03:17:05,800
see our health is set to 100
4703
03:17:07,319 --> 03:17:08,319
and if I go closer okay let me just
4704
03:17:09,720 --> 03:17:10,720
speed that up a bit
4705
03:17:13,100 --> 03:17:14,100
so if I interact with this nothing
4706
03:17:15,840 --> 03:17:16,840
happens but if I go ahead and interact
4707
03:17:18,899 --> 03:17:19,899
with this our health reduces my health
4708
03:17:21,300 --> 03:17:22,300
reduced and now we exit the game the
4709
03:17:23,760 --> 03:17:24,760
third time we do that
4710
03:17:25,319 --> 03:17:26,319
so this is basically how you work with
4711
03:17:27,240 --> 03:17:28,240
widgets so if you want to update it you
4712
03:17:29,939 --> 03:17:30,939
would just use one of the functions
4713
03:17:31,319 --> 03:17:32,319
which are there in one of these widgets
4714
03:17:33,540 --> 03:17:34,540
and what if you wanted text obviously
4715
03:17:36,660 --> 03:17:37,660
you just search accordingly type in text
4716
03:17:39,540 --> 03:17:40,540
and you should be able to find text
4717
03:17:42,600 --> 03:17:43,600
so let's actually type in the actual
4718
03:17:45,300 --> 03:17:46,300
health value
4719
03:17:46,680 --> 03:17:47,680
so over here
4720
03:17:48,420 --> 03:17:49,420
what we can do is we can just give 100
4721
03:17:51,420 --> 03:17:52,420
by default or we could leave it a text
4722
03:17:53,399 --> 03:17:54,399
block and set it normally so over here
4723
03:17:57,300 --> 03:17:58,300
get back into your play controller
4724
03:18:00,319 --> 03:18:01,319
and in your update Health function we
4725
03:18:03,600 --> 03:18:04,600
can go ahead and grab our text I don't
4726
03:18:06,479 --> 03:18:07,479
know if it's set variable so it is not
4727
03:18:09,000 --> 03:18:10,000
set to be variable so we can type this
4728
03:18:10,920 --> 03:18:11,920
one Health text
4729
03:18:13,859 --> 03:18:14,859
now you should be able to access health
4730
03:18:15,660 --> 03:18:16,660
text from the player controller once you
4731
03:18:18,060 --> 03:18:19,060
set that to its variable
4732
03:18:19,800 --> 03:18:20,800
so grab in our HUD
4733
03:18:22,800 --> 03:18:23,800
Health text so get your health text
4734
03:18:26,880 --> 03:18:27,880
and over here we can go ahead and set
4735
03:18:29,700 --> 03:18:30,700
the text
4736
03:18:30,660 --> 03:18:31,660
to be equal to the health value itself
4737
03:18:33,420 --> 03:18:34,420
now there is a special node which you'll
4738
03:18:35,760 --> 03:18:36,760
use a lot called format text
4739
03:18:38,939 --> 03:18:39,939
so this is very simple actually use
4740
03:18:41,279 --> 03:18:42,279
curly braces
4741
03:18:42,899 --> 03:18:43,899
and type in health
4742
03:18:45,540 --> 03:18:46,540
it will make a pin for you whatever you
4743
03:18:47,399 --> 03:18:48,399
type in curly braces will be a pin
4744
03:18:49,680 --> 03:18:50,680
and the first one let's just put a plus
4745
03:18:52,260 --> 03:18:53,260
over there because it's usually usually
4746
03:18:55,200 --> 03:18:56,200
health is denoted with a plus before
4747
03:18:57,779 --> 03:18:58,779
so your current so your text is
4748
03:19:00,240 --> 03:19:01,240
basically going to be plus along with a
4749
03:19:02,880 --> 03:19:03,880
health appended with your health so let
4750
03:19:05,399 --> 03:19:06,399
me just show that actually so grab in
4751
03:19:08,279 --> 03:19:09,279
your new health
4752
03:19:09,420 --> 03:19:10,420
you can grab in any sort of pin by the
4753
03:19:11,640 --> 03:19:12,640
way
4754
03:19:12,840 --> 03:19:13,840
now if I go ahead and press play you see
4755
03:19:15,359 --> 03:19:16,359
it says plus hundred because it took
4756
03:19:18,060 --> 03:19:19,060
plus and the actual health value itself
4757
03:19:20,460 --> 03:19:21,460
now I apologize I do realize that the
4758
03:19:23,340 --> 03:19:24,340
screen is a little bit black and white
4759
03:19:24,660 --> 03:19:25,660
so now it should be fine
4760
03:19:27,420 --> 03:19:28,420
so you have plus and you have your
4761
03:19:29,760 --> 03:19:30,760
health
4762
03:19:31,260 --> 03:19:32,260
similarly you could you could do
4763
03:19:33,600 --> 03:19:34,600
something like maybe hyphens
4764
03:19:37,200 --> 03:19:38,200
so it's just going to append it as is
4765
03:19:40,979 --> 03:19:41,979
you can go ahead and mess around with it
4766
03:19:43,080 --> 03:19:44,080
a little bit let's say you wanted
4767
03:19:44,520 --> 03:19:45,520
another parameter you could put curly
4768
03:19:47,700 --> 03:19:48,700
braces once again and type this one
4769
03:19:50,279 --> 03:19:51,279
maybe
4770
03:19:51,540 --> 03:19:52,540
something
4771
03:19:53,220 --> 03:19:54,220
and over here you can go ahead and make
4772
03:19:56,700 --> 03:19:57,700
make a little a little string or a text
4773
03:19:59,819 --> 03:20:00,819
so
4774
03:20:01,200 --> 03:20:02,200
let's just say hi for example so it's
4775
03:20:03,240 --> 03:20:04,240
going to print
4776
03:20:04,560 --> 03:20:05,560
plus 100 space High
4777
03:20:07,439 --> 03:20:08,439
if I put a hyphen here it's going to
4778
03:20:09,720 --> 03:20:10,720
take it as is so plus 100 hyphen height
4779
03:20:14,640 --> 03:20:15,640
so stuff like that which you can do
4780
03:20:16,620 --> 03:20:17,620
using this format text node and it's
4781
03:20:19,020 --> 03:20:20,020
really handy in my opinion
4782
03:20:21,240 --> 03:20:22,240
so now if I go ahead and press play we
4783
03:20:23,399 --> 03:20:24,399
have our health bar
4784
03:20:25,680 --> 03:20:26,680
now we could do a little more of
4785
03:20:27,899 --> 03:20:28,899
Designing so head back into your HUD
4786
03:20:31,040 --> 03:20:32,040
and you can actually wrap this around
4787
03:20:33,779 --> 03:20:34,779
with a border if you right click and
4788
03:20:36,359 --> 03:20:37,359
type in wrap with
4789
03:20:38,040 --> 03:20:39,040
you can wrap it with a border and
4790
03:20:40,380 --> 03:20:41,380
actually have a border color and stuff
4791
03:20:42,359 --> 03:20:43,359
so I can select this and make sure you
4792
03:20:45,479 --> 03:20:46,479
set your padding to whatever you want
4793
03:20:47,399 --> 03:20:48,399
padding is basically the spacing you
4794
03:20:49,620 --> 03:20:50,620
give
4795
03:20:50,340 --> 03:20:51,340
so if I change the padding in this case
4796
03:20:52,859 --> 03:20:53,859
so if I change this to 10 you'd see that
4797
03:20:56,040 --> 03:20:57,040
you're giving more space on all
4798
03:20:57,479 --> 03:20:58,479
directions I'll just set it to something
4799
03:20:59,399 --> 03:21:00,399
like 5 Maybe
4800
03:21:01,319 --> 03:21:02,319
and I'll make this one black so not
4801
03:21:03,899 --> 03:21:04,899
content color that's going to be a
4802
03:21:05,520 --> 03:21:06,520
progress Parts color instead go to brush
4803
03:21:07,920 --> 03:21:08,920
color and change that to something dark
4804
03:21:09,720 --> 03:21:10,720
Maybe
4805
03:21:10,859 --> 03:21:11,859
and over here as well let's just change
4806
03:21:13,140 --> 03:21:14,140
the fill color to Green because that's
4807
03:21:15,060 --> 03:21:16,060
more appropriate for your health widget
4808
03:21:16,800 --> 03:21:17,800
so change that to something a bit more
4809
03:21:19,920 --> 03:21:20,920
greener
4810
03:21:21,060 --> 03:21:22,060
now if I go ahead and press play you'll
4811
03:21:24,180 --> 03:21:25,180
be able to see we get the appropriate
4812
03:21:25,859 --> 03:21:26,859
color and our health bar updates as
4813
03:21:27,899 --> 03:21:28,899
normal under text updates as well
4814
03:21:31,140 --> 03:21:32,140
so that's basically it so that's the
4815
03:21:33,660 --> 03:21:34,660
basics of widget blueprints we will talk
4816
03:21:36,300 --> 03:21:37,300
a lot more in depth about this as we
4817
03:21:38,640 --> 03:21:39,640
move further but now you guys should
4818
03:21:40,680 --> 03:21:41,680
have a pretty basic idea on how to
4819
03:21:42,300 --> 03:21:43,300
create stuff now the palette is
4820
03:21:44,520 --> 03:21:45,520
something which I want you guys to
4821
03:21:46,080 --> 03:21:47,080
explore so check boxes a checkbox and
4822
03:21:49,740 --> 03:21:50,740
you won't use most of these most often
4823
03:21:52,380 --> 03:21:53,380
you'll use text slider button image
4824
03:21:55,680 --> 03:21:56,680
border and images as it says it's an
4825
03:21:58,500 --> 03:21:59,500
image and one more which you might use
4826
03:22:01,020 --> 03:22:02,020
if you want something like a username
4827
03:22:03,240 --> 03:22:04,240
password menu is a text box
4828
03:22:05,640 --> 03:22:06,640
so you can grab in a text box and this
4829
03:22:09,000 --> 03:22:10,000
will allow the user to enter any text
4830
03:22:11,340 --> 03:22:12,340
inside
4831
03:22:12,600 --> 03:22:13,600
stuff like that
4832
03:22:14,580 --> 03:22:15,580
now
4833
03:22:15,899 --> 03:22:16,899
I want to cover widgets in a little more
4834
03:22:18,420 --> 03:22:19,420
detail
4835
03:22:19,500 --> 03:22:20,500
so let's actually
4836
03:22:21,720 --> 03:22:22,720
create another level called main menu
4837
03:22:23,760 --> 03:22:24,760
and let's accelerate transition to this
4838
03:22:26,100 --> 03:22:27,100
level using a widget so like you click
4839
03:22:28,979 --> 03:22:29,979
the play button in your widget and then
4840
03:22:31,020 --> 03:22:32,020
you would enter this level let's do that
4841
03:22:32,939 --> 03:22:33,939
now
4842
03:22:34,319 --> 03:22:35,319
first we can go ahead and create our map
4843
03:22:36,660 --> 03:22:37,660
so heading to content maps right click
4844
03:22:39,540 --> 03:22:40,540
create a new level and we can call this
4845
03:22:41,819 --> 03:22:42,819
one main menu
4846
03:22:43,740 --> 03:22:44,740
open it up or rather let's just be a
4847
03:22:46,439 --> 03:22:47,439
little more descriptive call this one
4848
03:22:47,760 --> 03:22:48,760
main menu level open it up and this
4849
03:22:50,939 --> 03:22:51,939
should be blank and that's really none
4850
03:22:53,220 --> 03:22:54,220
of our concern head into UI create a new
4851
03:22:56,640 --> 03:22:57,640
folder and we'll call this one main menu
4852
03:22:59,819 --> 03:23:00,819
over here go to user interface widget
4853
03:23:02,640 --> 03:23:03,640
blueprint and go ahead and select user
4854
03:23:05,220 --> 03:23:06,220
widget
4855
03:23:06,180 --> 03:23:07,180
now we can start making our main menu so
4856
03:23:09,660 --> 03:23:10,660
we can call this one BP underscore main
4857
03:23:12,960 --> 03:23:13,960
menu
4858
03:23:15,000 --> 03:23:16,000
open the widget
4859
03:23:16,560 --> 03:23:17,560
and we can just have a canvas panel
4860
03:23:18,960 --> 03:23:19,960
again
4861
03:23:22,800 --> 03:23:23,800
add in a button
4862
03:23:25,739 --> 03:23:26,739
we can Center it first of all
4863
03:23:29,340 --> 03:23:30,340
so make it 0.5 and 0.5
4864
03:23:32,399 --> 03:23:33,399
and set the positions to be zero
4865
03:23:35,279 --> 03:23:36,279
we can increase the size a little bit
4866
03:23:37,080 --> 03:23:38,080
maybe we could make that something like
4867
03:23:38,939 --> 03:23:39,939
350 by 100 Maybe
4868
03:23:41,700 --> 03:23:42,700
maybe 450 again size is your personal
4869
03:23:45,779 --> 03:23:46,779
preference
4870
03:23:47,279 --> 03:23:48,279
and we can make the background black so
4871
03:23:50,340 --> 03:23:51,340
background color change that to
4872
03:23:52,020 --> 03:23:53,020
something darker
4873
03:23:53,340 --> 03:23:54,340
maybe something like a dark gray
4874
03:23:55,979 --> 03:23:56,979
we can go in and add in some text and we
4875
03:23:58,920 --> 03:23:59,920
can call this one play
4876
03:24:02,220 --> 03:24:03,220
now you can change the font as well by
4877
03:24:04,920 --> 03:24:05,920
the way under font
4878
03:24:06,779 --> 03:24:07,779
uh you can actually import your own
4879
03:24:09,060 --> 03:24:10,060
custom fonts will not get into that but
4880
03:24:11,700 --> 03:24:12,700
it's actually pretty simple to do it
4881
03:24:13,800 --> 03:24:14,800
we'll try to get into that in the later
4882
03:24:15,840 --> 03:24:16,840
part of the course but I'm not really
4883
03:24:17,279 --> 03:24:18,279
sure if I will so maybe change that to
4884
03:24:19,739 --> 03:24:20,739
regular increase the font size to 35
4885
03:24:22,020 --> 03:24:23,020
let's say this should be good
4886
03:24:24,600 --> 03:24:25,600
now head into your event graph and let's
4887
03:24:26,580 --> 03:24:27,580
call this one play button
4888
03:24:28,979 --> 03:24:29,979
so select the button and then under the
4889
03:24:31,620 --> 03:24:32,620
details panel rename that
4890
03:24:33,840 --> 03:24:34,840
now if you select the play button
4891
03:24:37,080 --> 03:24:38,080
variable you should get a bunch of
4892
03:24:39,239 --> 03:24:40,239
events including on clicked on pressed
4893
03:24:41,399 --> 03:24:42,399
on release all of these are as they
4894
03:24:44,399 --> 03:24:45,399
stand obviously maybe if you have a
4895
03:24:46,500 --> 03:24:47,500
sound effect or something you could play
4896
03:24:47,880 --> 03:24:48,880
it on on hovered or there's another way
4897
03:24:50,580 --> 03:24:51,580
actually where you can play sound effect
4898
03:24:51,960 --> 03:24:52,960
when you hover your mouse so over here
4899
03:24:54,899 --> 03:24:55,899
if I just type in Hover
4900
03:24:57,660 --> 03:24:58,660
I should be able to find Howard sound
4901
03:24:59,819 --> 03:25:00,819
let's just play uh
4902
03:25:04,140 --> 03:25:05,140
so
4903
03:25:05,520 --> 03:25:06,520
maybe let's just play this I mean it
4904
03:25:07,439 --> 03:25:08,439
doesn't make any sense but anyways
4905
03:25:10,439 --> 03:25:11,439
and
4906
03:25:12,120 --> 03:25:13,120
I think there is a clicked sound or a
4907
03:25:14,460 --> 03:25:15,460
pla press sound I guess it's called
4908
03:25:17,040 --> 03:25:18,040
so we can play press sound so
4909
03:25:20,040 --> 03:25:21,040
click on button
4910
03:25:22,800 --> 03:25:23,800
and what we can do is on click we can go
4911
03:25:26,160 --> 03:25:27,160
ahead and open our map so we can type in
4912
03:25:29,279 --> 03:25:30,279
open level
4913
03:25:30,600 --> 03:25:31,600
and we can do by object reference
4914
03:25:33,420 --> 03:25:34,420
so over here let's just select our level
4915
03:25:36,720 --> 03:25:37,720
beginner course level and that should be
4916
03:25:39,479 --> 03:25:40,479
good now if I go ahead and press play
4917
03:25:43,260 --> 03:25:44,260
as you see nothing happens because we
4918
03:25:45,239 --> 03:25:46,239
haven't created the widget yet now since
4919
03:25:47,580 --> 03:25:48,580
this is a widget which is the only thing
4920
03:25:51,660 --> 03:25:52,660
in this level you could simply go ahead
4921
03:25:53,819 --> 03:25:54,819
and create the widget here on begin play
4922
03:25:55,560 --> 03:25:56,560
so create widget
4923
03:25:59,279 --> 03:26:00,279
create widget
4924
03:26:01,020 --> 03:26:02,020
BP main menu add to viewport we don't
4925
03:26:04,620 --> 03:26:05,620
really need to store it because we are
4926
03:26:06,239 --> 03:26:07,239
not actually calling any functions
4927
03:26:08,340 --> 03:26:09,340
so if I press play you can see it and
4928
03:26:10,200 --> 03:26:11,200
when we hover over it you see you get
4929
03:26:12,060 --> 03:26:13,060
the sound effect
4930
03:26:13,260 --> 03:26:14,260
however one thing you would notice is if
4931
03:26:15,540 --> 03:26:16,540
you actually have your focus on the
4932
03:26:17,460 --> 03:26:18,460
window
4933
03:26:18,420 --> 03:26:19,420
you can't see a mouse cursor so the way
4934
03:26:20,939 --> 03:26:21,939
you do that is first of all get your
4935
03:26:23,040 --> 03:26:24,040
player controller so type in get player
4936
03:26:24,899 --> 03:26:25,899
controller this is a static function
4937
03:26:27,359 --> 03:26:28,359
so in inside any actor basically you can
4938
03:26:31,140 --> 03:26:32,140
get your player controller reference
4939
03:26:33,720 --> 03:26:34,720
and from here there's actually a
4940
03:26:35,279 --> 03:26:36,279
variable called set show mouse cursor so
4941
03:26:37,319 --> 03:26:38,319
show mouse cursor is the variable
4942
03:26:39,420 --> 03:26:40,420
set that to true and another thing which
4943
03:26:42,300 --> 03:26:43,300
you can do actually is change the input
4944
03:26:45,300 --> 03:26:46,300
mode to UI only so that it only focuses
4945
03:26:49,380 --> 03:26:50,380
on this widget there is another option
4946
03:26:51,239 --> 03:26:52,239
called game and UI only we'll use that
4947
03:26:53,880 --> 03:26:54,880
set input mode to game and UI only
4948
03:26:56,880 --> 03:26:57,880
grab in the player controller reference
4949
03:27:00,560 --> 03:27:01,560
and that should be good so we can just
4950
03:27:03,840 --> 03:27:04,840
reroute it double click on the PIN to
4951
03:27:06,060 --> 03:27:07,060
reroute it
4952
03:27:08,040 --> 03:27:09,040
and now if I go ahead and press play
4953
03:27:11,220 --> 03:27:12,220
you see even when I focus it I can still
4954
03:27:13,800 --> 03:27:14,800
see my mouse cursor now if I press play
4955
03:27:16,439 --> 03:27:17,439
you see we transition to the level now
4956
03:27:18,899 --> 03:27:19,899
we obviously spawned at 0 comma zero
4957
03:27:21,300 --> 03:27:22,300
comma zero so that's the reason that
4958
03:27:22,680 --> 03:27:23,680
happened
4959
03:27:23,760 --> 03:27:24,760
now if you want to fix that you can go
4960
03:27:27,359 --> 03:27:28,359
ahead and add in a player start where
4961
03:27:29,399 --> 03:27:30,399
your default player will spawn so now if
4962
03:27:32,220 --> 03:27:33,220
I head back into the main menu play it
4963
03:27:34,979 --> 03:27:35,979
if I head in we will spawn where our
4964
03:27:37,200 --> 03:27:38,200
player start was but one thing you'll
4965
03:27:39,120 --> 03:27:40,120
notice is uh we still haven't actually
4966
03:27:41,960 --> 03:27:42,960
got rid of the mouse focusing part so
4967
03:27:44,939 --> 03:27:45,939
your mouse isn't behaving like how it
4968
03:27:47,520 --> 03:27:48,520
should
4969
03:27:48,779 --> 03:27:49,779
so what we can do is on begin play now
4970
03:27:52,319 --> 03:27:53,319
we are in a main menu level
4971
03:27:54,060 --> 03:27:55,060
head into our beginner course level
4972
03:27:56,340 --> 03:27:57,340
generally you do it on your player
4973
03:27:58,020 --> 03:27:59,020
controller so BP black controller and
4974
03:28:01,080 --> 03:28:02,080
what you can do is you can set input
4975
03:28:03,479 --> 03:28:04,479
mode
4976
03:28:05,660 --> 03:28:06,660
game only
4977
03:28:08,939 --> 03:28:09,939
and we can get a reference to self
4978
03:28:12,420 --> 03:28:13,420
and you can also set show mouse cursor
4979
03:28:14,640 --> 03:28:15,640
to false so set show mouse cursor make
4980
03:28:17,100 --> 03:28:18,100
that false
4981
03:28:19,020 --> 03:28:20,020
now if I go ahead and press play okay I
4982
03:28:21,840 --> 03:28:22,840
mean that wasn't what I intended
4983
03:28:25,140 --> 03:28:26,140
now
4984
03:28:26,640 --> 03:28:27,640
head back into your main menu
4985
03:28:28,979 --> 03:28:29,979
go ahead and press play now you see your
4986
03:28:31,739 --> 03:28:32,739
mouse is going to behave normally
4987
03:28:34,020 --> 03:28:35,020
so that's basically how you deal with it
4988
03:28:35,939 --> 03:28:36,939
now you can do your normal gameplay
4989
03:28:37,800 --> 03:28:38,800
stuff so that's how you would actually
4990
03:28:39,479 --> 03:28:40,479
create
4991
03:28:40,859 --> 03:28:41,859
you would actually interact with your
4992
03:28:42,840 --> 03:28:43,840
actual levels and stuff your transition
4993
03:28:45,300 --> 03:28:46,300
levels and stuff using widget blueprints
4994
03:28:47,460 --> 03:28:48,460
so head back into UI main menu and if we
4995
03:28:50,399 --> 03:28:51,399
take a look at our code it's really
4996
03:28:52,200 --> 03:28:53,200
simple and a widget as well it's really
4997
03:28:54,840 --> 03:28:55,840
simple
4998
03:28:55,920 --> 03:28:56,920
so that's about it now let's say we
4999
03:28:58,500 --> 03:28:59,500
wanted to have more than one option
5000
03:29:00,960 --> 03:29:01,960
and let's say we wanted to layer them
5001
03:29:02,819 --> 03:29:03,819
vertically so if you want to add
5002
03:29:05,100 --> 03:29:06,100
multiple rows you can go ahead and use
5003
03:29:07,680 --> 03:29:08,680
something known as a vertical box so if
5004
03:29:09,899 --> 03:29:10,899
I right click on this type in wrap width
5005
03:29:12,120 --> 03:29:13,120
and use a vertical box
5006
03:29:14,580 --> 03:29:15,580
you can go ahead and get this now the
5007
03:29:17,700 --> 03:29:18,700
vertical box will automatically use the
5008
03:29:19,500 --> 03:29:20,500
same anchor as we used for the child
5009
03:29:21,899 --> 03:29:22,899
but nonetheless just something which you
5010
03:29:24,540 --> 03:29:25,540
can change
5011
03:29:25,439 --> 03:29:26,439
the size y to something big Maybe
5012
03:29:28,700 --> 03:29:29,700
and press Ctrl D to duplicate this
5013
03:29:32,100 --> 03:29:33,100
button
5014
03:29:34,200 --> 03:29:35,200
now over here I can type in exit let's
5015
03:29:36,720 --> 03:29:37,720
say
5016
03:29:37,560 --> 03:29:38,560
and again on clicked we can change that
5017
03:29:40,319 --> 03:29:41,319
so play button one is not appropriate
5018
03:29:43,080 --> 03:29:44,080
we'll change that to exit button
5019
03:29:46,080 --> 03:29:47,080
so exit button
5020
03:29:49,260 --> 03:29:50,260
and on clicked we can go ahead and
5021
03:29:51,899 --> 03:29:52,899
execute console command and we can type
5022
03:29:54,720 --> 03:29:55,720
in exit
5023
03:29:57,420 --> 03:29:58,420
so that should be good to go and you'll
5024
03:29:59,100 --> 03:30:00,100
notice one thing it's just taking up a
5025
03:30:02,040 --> 03:30:03,040
fixed amount of space and it's not
5026
03:30:03,600 --> 03:30:04,600
actually filling it properly so if you
5027
03:30:05,939 --> 03:30:06,939
want to do that you can select both of
5028
03:30:07,859 --> 03:30:08,859
these and select fill
5029
03:30:09,359 --> 03:30:10,359
now let's say you wanted your play
5030
03:30:11,100 --> 03:30:12,100
button to occupy more amount of space
5031
03:30:13,979 --> 03:30:14,979
than exit so you can increase this uh
5032
03:30:18,420 --> 03:30:19,420
what a text box which is available to
5033
03:30:21,120 --> 03:30:22,120
you so if I hit 2
5034
03:30:22,620 --> 03:30:23,620
and the exit button has one on this
5035
03:30:25,439 --> 03:30:26,439
option basically they are occupying
5036
03:30:28,140 --> 03:30:29,140
space in the ratio two is to one that's
5037
03:30:30,960 --> 03:30:31,960
basically what it means so you don't
5038
03:30:33,060 --> 03:30:34,060
want your place to exit obviously so
5039
03:30:34,739 --> 03:30:35,739
you'd make the play button bigger so
5040
03:30:36,359 --> 03:30:37,359
this is how you do it
5041
03:30:38,580 --> 03:30:39,580
now if I press play
5042
03:30:41,640 --> 03:30:42,640
now the same logic is copied over the
5043
03:30:44,100 --> 03:30:45,100
reason why the sound is playing even for
5044
03:30:45,779 --> 03:30:46,779
the exit button is because we copied
5045
03:30:47,700 --> 03:30:48,700
over the code so that's why so all the
5046
03:30:51,479 --> 03:30:52,479
sound effects as well is copied so as
5047
03:30:53,819 --> 03:30:54,819
you can see press sound and hover sound
5048
03:30:55,500 --> 03:30:56,500
are actually the same in both of these
5049
03:30:58,560 --> 03:30:59,560
now if I press play I press exit we are
5050
03:31:00,960 --> 03:31:01,960
going to quit the game if I press play
5051
03:31:03,060 --> 03:31:04,060
We load into this level
5052
03:31:06,920 --> 03:31:07,920
so that's pretty cool so that's about it
5053
03:31:10,080 --> 03:31:11,080
for this part
5054
03:31:11,279 --> 03:31:12,279
foreign
5055
03:31:18,020 --> 03:31:19,020
talking about another feature which
5056
03:31:20,760 --> 03:31:21,760
blueprint offers that is blueprint
5057
03:31:23,460 --> 03:31:24,460
function libraries now let's say you
5058
03:31:26,520 --> 03:31:27,520
wanted to have some functions which
5059
03:31:29,300 --> 03:31:30,300
might be used in multiple places but are
5060
03:31:32,520 --> 03:31:33,520
not relative to a certain object
5061
03:31:34,920 --> 03:31:35,920
so in that case you would use a
5062
03:31:36,840 --> 03:31:37,840
blueprint function Library so let me
5063
03:31:39,359 --> 03:31:40,359
actually show you guys an example
5064
03:31:41,640 --> 03:31:42,640
so head into blueprints and or maybe we
5065
03:31:46,680 --> 03:31:47,680
could create another folder let's call
5066
03:31:48,239 --> 03:31:49,239
this one function libraries
5067
03:31:54,359 --> 03:31:55,359
open it up and over here right click
5068
03:31:57,600 --> 03:31:58,600
head into Blueprints and
5069
03:32:01,200 --> 03:32:02,200
select blueprint function Library
5070
03:32:04,200 --> 03:32:05,200
and we can call this one my or our
5071
03:32:08,640 --> 03:32:09,640
blueprint function Library
5072
03:32:15,420 --> 03:32:16,420
now inside here you would notice that we
5073
03:32:18,540 --> 03:32:19,540
actually have functions options to write
5074
03:32:21,300 --> 03:32:22,300
functions
5075
03:32:22,620 --> 03:32:23,620
so for example let's say we have
5076
03:32:25,380 --> 03:32:26,380
something generic so for example let's
5077
03:32:27,660 --> 03:32:28,660
say
5078
03:32:28,560 --> 03:32:29,560
uh we have a vector and let's say we
5079
03:32:31,439 --> 03:32:32,439
wanted to normalize it now obviously
5080
03:32:33,120 --> 03:32:34,120
there is a normalized function already
5081
03:32:34,739 --> 03:32:35,739
but I'm just taking an example now
5082
03:32:37,800 --> 03:32:38,800
normalizing a vector is a general
5083
03:32:39,540 --> 03:32:40,540
operation it's not relative to any
5084
03:32:41,880 --> 03:32:42,880
object so we can type in
5085
03:32:44,580 --> 03:32:45,580
normalize
5086
03:32:47,100 --> 03:32:48,100
and for the input obviously we are going
5087
03:32:49,620 --> 03:32:50,620
to take in a vector so take in a vector
5088
03:32:52,260 --> 03:32:53,260
and we can type this one in maybe
5089
03:32:56,340 --> 03:32:57,340
uh now once we have the vector we are
5090
03:32:59,760 --> 03:33:00,760
going to first of all get the magnitude
5091
03:33:02,340 --> 03:33:03,340
of this Vector the way you get magnitude
5092
03:33:04,859 --> 03:33:05,859
of a vector in Blueprint is by typing in
5093
03:33:07,380 --> 03:33:08,380
Vector length so get Vector length
5094
03:33:11,220 --> 03:33:12,220
now this is this is the magnitude of the
5095
03:33:14,700 --> 03:33:15,700
vector so we can divide this vector by
5096
03:33:17,520 --> 03:33:18,520
the magnitude
5097
03:33:18,899 --> 03:33:19,899
so that is going to normalize the vector
5098
03:33:21,660 --> 03:33:22,660
for us
5099
03:33:22,800 --> 03:33:23,800
and once we actually do that we can go
5100
03:33:25,800 --> 03:33:26,800
ahead and return it
5101
03:33:28,439 --> 03:33:29,439
so this is going to be the return value
5102
03:33:31,340 --> 03:33:32,340
and obviously we'll make it a pure
5103
03:33:33,840 --> 03:33:34,840
function now
5104
03:33:36,660 --> 03:33:37,660
let's just call this one normalize
5105
03:33:38,880 --> 03:33:39,880
underscore hours because I I think there
5106
03:33:42,060 --> 03:33:43,060
is another function called normalize so
5107
03:33:43,979 --> 03:33:44,979
just so that it's understandable for us
5108
03:33:47,700 --> 03:33:48,700
now head back into any one of your
5109
03:33:50,040 --> 03:33:51,040
blueprints let's say our level blueprint
5110
03:33:52,399 --> 03:33:53,399
and over here if we just type in
5111
03:33:55,260 --> 03:33:56,260
normalize
5112
03:33:56,819 --> 03:33:57,819
so we already had a normalized function
5113
03:33:59,100 --> 03:34:00,100
but I just took the example underscore
5114
03:34:01,620 --> 03:34:02,620
RS you see we actually get our function
5115
03:34:05,160 --> 03:34:06,160
and this is not relative to any object
5116
03:34:07,140 --> 03:34:08,140
so you can call this pretty much
5117
03:34:09,000 --> 03:34:10,000
Everywhere You Wish so this is basically
5118
03:34:12,000 --> 03:34:13,000
our blueprint function Library you just
5119
03:34:14,399 --> 03:34:15,399
go on creating functions
5120
03:34:16,800 --> 03:34:17,800
[Music]
5121
03:34:21,239 --> 03:34:22,239
so once that's all settled now what if
5122
03:34:24,000 --> 03:34:25,000
you wanted to use some code or some
5123
03:34:26,399 --> 03:34:27,399
assets created by somebody else there is
5124
03:34:30,180 --> 03:34:31,180
actually a huge Marketplace called the
5125
03:34:32,819 --> 03:34:33,819
unreal Marketplace and you can access it
5126
03:34:35,040 --> 03:34:36,040
through the epic games launcher so if I
5127
03:34:36,840 --> 03:34:37,840
head into my epic games launcher head
5128
03:34:39,060 --> 03:34:40,060
into Marketplace under the Unreal Engine
5129
03:34:41,520 --> 03:34:42,520
section you would see that you get a
5130
03:34:44,340 --> 03:34:45,340
massive library of assets and there are
5131
03:34:46,800 --> 03:34:47,800
a bunch of free ones as well like I I
5132
03:34:49,859 --> 03:34:50,859
really mean a lot of free assets
5133
03:34:52,319 --> 03:34:53,319
so what if you wanted to use them so
5134
03:34:55,020 --> 03:34:56,020
that is where using plugins and other
5135
03:34:58,080 --> 03:34:59,080
content packs comes in handy so how you
5136
03:35:00,899 --> 03:35:01,899
do it is really simple actually so for
5137
03:35:03,359 --> 03:35:04,359
example I know one which is very handy
5138
03:35:05,399 --> 03:35:06,399
it's called low entry I believe
5139
03:35:09,060 --> 03:35:10,060
oops low entry
5140
03:35:12,300 --> 03:35:13,300
so I actually have it in my library so
5141
03:35:15,479 --> 03:35:16,479
so it's by this publisher actually
5142
03:35:18,060 --> 03:35:19,060
so low entry low entry standard Library
5143
03:35:21,540 --> 03:35:22,540
this is the one which I'm using this is
5144
03:35:24,779 --> 03:35:25,779
really useful so once you search it up
5145
03:35:28,319 --> 03:35:29,319
and you can look it up in the
5146
03:35:30,359 --> 03:35:31,359
marketplace and there are many Forums on
5147
03:35:32,520 --> 03:35:33,520
Reddit and stuff talking about which
5148
03:35:34,859 --> 03:35:35,859
plugins are good and stuff so you can go
5149
03:35:38,100 --> 03:35:39,100
ahead and install it according to your
5150
03:35:40,439 --> 03:35:41,439
needs so let's say I wanted some weapon
5151
03:35:42,180 --> 03:35:43,180
models for prototyping you could just
5152
03:35:44,760 --> 03:35:45,760
type in weapon and you're going to get
5153
03:35:46,200 --> 03:35:47,200
weapon packs the way you install it is
5154
03:35:48,720 --> 03:35:49,720
by clicking on this install to engine
5155
03:35:50,399 --> 03:35:51,399
button I've already done that so that's
5156
03:35:52,260 --> 03:35:53,260
why it shows that I can't
5157
03:35:54,359 --> 03:35:55,359
now over here in my plugins panel now I
5158
03:35:57,600 --> 03:35:58,600
should be able to access it over here
5159
03:35:59,580 --> 03:36:00,580
under installed or if you just search it
5160
03:36:02,760 --> 03:36:03,760
up you would be able to find it and you
5161
03:36:04,680 --> 03:36:05,680
can enable it so low entry extended
5162
03:36:07,319 --> 03:36:08,319
standard library and I need to restart
5163
03:36:09,239 --> 03:36:10,239
the editor so let me go ahead and do
5164
03:36:11,279 --> 03:36:12,279
that
5165
03:36:12,180 --> 03:36:13,180
now that it's done I can go ahead and
5166
03:36:14,760 --> 03:36:15,760
use the content in the plugin now how do
5167
03:36:17,520 --> 03:36:18,520
I know what content is there there will
5168
03:36:19,680 --> 03:36:20,680
actually be a documentation and source
5169
03:36:22,620 --> 03:36:23,620
code and stuff available so you could
5170
03:36:25,200 --> 03:36:26,200
just look it up so there will be a place
5171
03:36:27,300 --> 03:36:28,300
where the documentation is given so you
5172
03:36:30,239 --> 03:36:31,239
have a preview over here then you also
5173
03:36:32,640 --> 03:36:33,640
have access to the source code
5174
03:36:34,620 --> 03:36:35,620
and a bunch of stuff you could also take
5175
03:36:37,200 --> 03:36:38,200
a look at this over here so maybe let's
5176
03:36:40,800 --> 03:36:41,800
say we wanted to use uh some function
5177
03:36:44,640 --> 03:36:45,640
here so for example I type in is debug
5178
03:36:48,420 --> 03:36:49,420
build let's say I wanted to see if I am
5179
03:36:51,180 --> 03:36:52,180
currently in a debug build
5180
03:36:52,920 --> 03:36:53,920
so I can type in is debug build whoops
5181
03:36:56,580 --> 03:36:57,580
debug build and as you can see I can use
5182
03:36:59,279 --> 03:37:00,279
the function now this was a plugin which
5183
03:37:02,580 --> 03:37:03,580
has to be installed to the engine
5184
03:37:04,920 --> 03:37:05,920
however we will also look at other types
5185
03:37:08,160 --> 03:37:09,160
of plugins such as let's say I type in
5186
03:37:10,200 --> 03:37:11,200
weapon for example I needed a weapon
5187
03:37:12,000 --> 03:37:13,000
pack
5188
03:37:13,380 --> 03:37:14,380
so I actually have some in the library
5189
03:37:15,660 --> 03:37:16,660
you could find a free one so you can
5190
03:37:17,399 --> 03:37:18,399
head under free and you can look for it
5191
03:37:19,439 --> 03:37:20,439
but again now in my library I actually
5192
03:37:22,560 --> 03:37:23,560
have some weapon packs if I want to
5193
03:37:24,660 --> 03:37:25,660
install those it's actually really
5194
03:37:26,279 --> 03:37:27,279
simple so FPS weapons bundle this is one
5195
03:37:29,399 --> 03:37:30,399
thing which I have so I can go ahead and
5196
03:37:31,739 --> 03:37:32,739
add this to a project and it does say
5197
03:37:34,500 --> 03:37:35,500
none of my projects are compatible but
5198
03:37:37,020 --> 03:37:38,020
plugins like these actually it doesn't
5199
03:37:39,779 --> 03:37:40,779
really matter if you are using a later
5200
03:37:41,939 --> 03:37:42,939
version then what is supported as long
5201
03:37:45,479 --> 03:37:46,479
as you're using a later version than
5202
03:37:47,160 --> 03:37:48,160
that it should be totally good to go so
5203
03:37:49,080 --> 03:37:50,080
click on show all projects and you can
5204
03:37:50,880 --> 03:37:51,880
go ahead and select this and you can
5205
03:37:53,040 --> 03:37:54,040
change the version to the latest
5206
03:37:54,239 --> 03:37:55,239
available one and you can go ahead and
5207
03:37:56,100 --> 03:37:57,100
add it now just another thing in case
5208
03:37:59,640 --> 03:38:00,640
you don't have a plug-in of this sort so
5209
03:38:03,720 --> 03:38:04,720
the one which we saw last time
5210
03:38:07,020 --> 03:38:08,020
so let's search for low entry once again
5211
03:38:13,380 --> 03:38:14,380
so let's say we have a plugin of this
5212
03:38:15,359 --> 03:38:16,359
sort
5213
03:38:16,380 --> 03:38:17,380
which you install to the engine but you
5214
03:38:19,200 --> 03:38:20,200
actually don't have the appropriate
5215
03:38:21,300 --> 03:38:22,300
version
5216
03:38:22,319 --> 03:38:23,319
so the way would actually go about
5217
03:38:24,479 --> 03:38:25,479
upgrading your version is actually
5218
03:38:26,279 --> 03:38:27,279
really simple people haven't made any
5219
03:38:29,100 --> 03:38:30,100
tutorials on this I don't see any Forum
5220
03:38:31,620 --> 03:38:32,620
or anything talking about that either so
5221
03:38:33,960 --> 03:38:34,960
basically you just come into your Unreal
5222
03:38:37,560 --> 03:38:38,560
Engine installation directory so I go to
5223
03:38:39,540 --> 03:38:40,540
program files Unreal Engine this is
5224
03:38:41,640 --> 03:38:42,640
where I have it
5225
03:38:42,840 --> 03:38:43,840
and over here under engine
5226
03:38:45,479 --> 03:38:46,479
plugins
5227
03:38:46,800 --> 03:38:47,800
and the marketplace ones will be in the
5228
03:38:49,020 --> 03:38:50,020
marketplace
5229
03:38:50,040 --> 03:38:51,040
and for example I go to low entry
5230
03:38:52,260 --> 03:38:53,260
extended standard Library I can right
5231
03:38:54,479 --> 03:38:55,479
click on this U plugin file and I can
5232
03:38:57,359 --> 03:38:58,359
actually open it with any text editor or
5233
03:38:59,760 --> 03:39:00,760
I can open it with something like vs
5234
03:39:01,620 --> 03:39:02,620
code so I'll open it with Visual Studio
5235
03:39:04,500 --> 03:39:05,500
inside the U plugin file you should see
5236
03:39:06,899 --> 03:39:07,899
something a little like this so you
5237
03:39:11,640 --> 03:39:12,640
don't have to worry about any of these
5238
03:39:13,800 --> 03:39:14,800
things the only thing is the engine
5239
03:39:15,120 --> 03:39:16,120
version let's say it was there for 4.27
5240
03:39:18,420 --> 03:39:19,420
and you are using 5 and if you want to
5241
03:39:20,880 --> 03:39:21,880
make it compatible and let's say you're
5242
03:39:22,620 --> 03:39:23,620
getting build errors you could just go
5243
03:39:24,720 --> 03:39:25,720
ahead and change 4.27 to 5.0.0 so let's
5244
03:39:27,899 --> 03:39:28,899
say it was
5245
03:39:29,479 --> 03:39:30,479
4.27.0 by default so you can go ahead
5246
03:39:32,700 --> 03:39:33,700
and change it to 5.0.0
5247
03:39:35,040 --> 03:39:36,040
whoops y dot or dot O So stuff like that
5248
03:39:39,300 --> 03:39:40,300
[Music]
5249
03:39:44,160 --> 03:39:45,160
all right so that's about it there isn't
5250
03:39:46,680 --> 03:39:47,680
really that much depth to plugins I mean
5251
03:39:49,080 --> 03:39:50,080
I will talk about creating plugins and
5252
03:39:51,600 --> 03:39:52,600
stuff integrating third-party libraries
5253
03:39:53,399 --> 03:39:54,399
a bit later on in the advanced part of
5254
03:39:55,319 --> 03:39:56,319
this course but now let's go ahead and
5255
03:39:58,500 --> 03:39:59,500
actually talk about a recently release
5256
03:40:01,380 --> 03:40:02,380
tool and which is quite handy in my
5257
03:40:04,200 --> 03:40:05,200
opinion and those are the modeling tools
5258
03:40:06,000 --> 03:40:07,000
first of all in your plugin section make
5259
03:40:09,000 --> 03:40:10,000
sure your plugin is enabled so make sure
5260
03:40:11,279 --> 03:40:12,279
modeling tools editor mode plugin is
5261
03:40:13,380 --> 03:40:14,380
enabled and if you don't want to
5262
03:40:16,140 --> 03:40:17,140
separately drag your model in the level
5263
03:40:18,239 --> 03:40:19,239
and edit it then you can press this as
5264
03:40:21,000 --> 03:40:22,000
well
5265
03:40:22,100 --> 03:40:23,100
ah now if you check your content browser
5266
03:40:25,739 --> 03:40:26,739
uh make sure you have some sort of a 3D
5267
03:40:28,500 --> 03:40:29,500
model make sure you have some sort of a
5268
03:40:30,060 --> 03:40:31,060
static mesh
5269
03:40:31,380 --> 03:40:32,380
so you can import that from your 3D
5270
03:40:33,540 --> 03:40:34,540
software
5271
03:40:34,680 --> 03:40:35,680
so I just got one in from the engine
5272
03:40:37,380 --> 03:40:38,380
content so what I did was basically
5273
03:40:39,540 --> 03:40:40,540
actually I'll just go ahead and delete
5274
03:40:40,859 --> 03:40:41,859
that and redo it
5275
03:40:42,600 --> 03:40:43,600
so delete that
5276
03:40:45,479 --> 03:40:46,479
and delete this folder as well
5277
03:40:47,760 --> 03:40:48,760
save everything now I just search for SM
5278
03:40:51,359 --> 03:40:52,359
underscore usually it's a convention to
5279
03:40:53,880 --> 03:40:54,880
name it SM underscore for static mesh
5280
03:40:56,040 --> 03:40:57,040
under content I just went ahead and
5281
03:40:58,920 --> 03:40:59,920
created a new folder
5282
03:41:00,720 --> 03:41:01,720
so new folder and I called it models
5283
03:41:04,319 --> 03:41:05,319
open it up and just paste it in uh just
5284
03:41:07,859 --> 03:41:08,859
using the one from the engine content
5285
03:41:09,660 --> 03:41:10,660
now you can drag it in the level and
5286
03:41:12,420 --> 03:41:13,420
start editing it by heading into this
5287
03:41:14,399 --> 03:41:15,399
tab right here and heading into modeling
5288
03:41:17,160 --> 03:41:18,160
so we have a bunch of options the first
5289
03:41:19,260 --> 03:41:20,260
few are for creating objects but some of
5290
03:41:23,819 --> 03:41:24,819
the useful ones are for example moving
5291
03:41:25,859 --> 03:41:26,859
the pivot so let's say you didn't want
5292
03:41:28,020 --> 03:41:29,020
this to rotate along the center you can
5293
03:41:30,420 --> 03:41:31,420
go ahead and type pivot and you can move
5294
03:41:32,760 --> 03:41:33,760
this point over here now if I rotate it
5295
03:41:35,580 --> 03:41:36,580
it's going to rotate along this point
5296
03:41:37,680 --> 03:41:38,680
and these changes are actually applied
5297
03:41:39,899 --> 03:41:40,899
to this so
5298
03:41:41,700 --> 03:41:42,700
even if I just drag in another ball
5299
03:41:44,580 --> 03:41:45,580
these changes will be applied to that so
5300
03:41:46,800 --> 03:41:47,800
just be careful while using them of
5301
03:41:48,239 --> 03:41:49,239
course you can undo them at any point
5302
03:41:50,460 --> 03:41:51,460
so just save that and sculpt is
5303
03:41:53,100 --> 03:41:54,100
basically to deform the shape so
5304
03:41:54,779 --> 03:41:55,779
something like this
5305
03:41:56,779 --> 03:41:57,779
and again you can use shift the same
5306
03:41:59,700 --> 03:42:00,700
principle works over here as well as we
5307
03:42:01,680 --> 03:42:02,680
did with the landscape editing so stuff
5308
03:42:04,380 --> 03:42:05,380
like that then descalp does a similar
5309
03:42:06,899 --> 03:42:07,899
thing just works a little bit
5310
03:42:08,279 --> 03:42:09,279
differently so I can just drag it like
5311
03:42:10,380 --> 03:42:11,380
this
5312
03:42:11,700 --> 03:42:12,700
I'm not sure what I did there but yeah
5313
03:42:14,279 --> 03:42:15,279
so I'm not really here to talk about the
5314
03:42:16,859 --> 03:42:17,859
tools in detail but just to give you an
5315
03:42:18,899 --> 03:42:19,899
overview of how to actually use it so
5316
03:42:21,600 --> 03:42:22,600
you could experiment around with all of
5317
03:42:23,460 --> 03:42:24,460
these
5318
03:42:24,359 --> 03:42:25,359
so if you type in accept so now we have
5319
03:42:27,239 --> 03:42:28,239
the ship obviously this is it just
5320
03:42:30,120 --> 03:42:31,120
messed up with the UV map and the
5321
03:42:31,739 --> 03:42:32,739
materials and stuff but anyways that was
5322
03:42:33,899 --> 03:42:34,899
not our point
5323
03:42:35,279 --> 03:42:36,279
now a couple of useful things first of
5324
03:42:38,399 --> 03:42:39,399
all creating shapes so if I just type in
5325
03:42:40,859 --> 03:42:41,859
stair over here
5326
03:42:42,779 --> 03:42:43,779
and if I head into this and I can
5327
03:42:46,800 --> 03:42:47,800
actually make it a curved staircase I
5328
03:42:49,380 --> 03:42:50,380
can actually increase the number of
5329
03:42:50,819 --> 03:42:51,819
stairs I can decrease the step height so
5330
03:42:53,819 --> 03:42:54,819
I can increase the curve angle for
5331
03:42:55,439 --> 03:42:56,439
example then I can decrease the step
5332
03:42:57,960 --> 03:42:58,960
height so I can make it something like
5333
03:42:59,399 --> 03:43:00,399
10
5334
03:43:00,420 --> 03:43:01,420
maybe place that and type in complete
5335
03:43:02,760 --> 03:43:03,760
now if I go ahead and press play
5336
03:43:06,660 --> 03:43:07,660
you would be able to see that I can
5337
03:43:08,880 --> 03:43:09,880
actually use my stairs
5338
03:43:12,060 --> 03:43:13,060
so that works well
5339
03:43:15,239 --> 03:43:16,239
so stuff like that and now shapes are
5340
03:43:19,500 --> 03:43:20,500
pretty obvious obviously just create a
5341
03:43:21,540 --> 03:43:22,540
box do stuff with that and now you might
5342
03:43:24,479 --> 03:43:25,479
be wondering where these are stored over
5343
03:43:27,359 --> 03:43:28,359
here just check uh what is selected
5344
03:43:30,660 --> 03:43:31,660
under this under the new asset location
5345
03:43:32,520 --> 03:43:33,520
if it is selected to Global in your
5346
03:43:35,399 --> 03:43:36,399
content folder folder there should be a
5347
03:43:37,800 --> 03:43:38,800
underscore generated folder in my case
5348
03:43:40,380 --> 03:43:41,380
it was set to World relative so wherever
5349
03:43:42,600 --> 03:43:43,600
you have your map over here this you
5350
03:43:45,000 --> 03:43:46,000
should see a underscore generated folder
5351
03:43:47,819 --> 03:43:48,819
and if you open it up you should be able
5352
03:43:50,760 --> 03:43:51,760
to see your static meshes
5353
03:43:53,399 --> 03:43:54,399
so for example we have this stair which
5354
03:43:55,319 --> 03:43:56,319
we just created and we can drag this in
5355
03:43:58,680 --> 03:43:59,680
so this is going to come in really
5356
03:44:00,720 --> 03:44:01,720
really handy for many people in my
5357
03:44:03,239 --> 03:44:04,239
opinion
5358
03:44:04,859 --> 03:44:05,859
now not only that it provides us with
5359
03:44:08,220 --> 03:44:09,220
several other cool features I'll just
5360
03:44:10,020 --> 03:44:11,020
showcase one of them actually
5361
03:44:11,880 --> 03:44:12,880
so if you head into your modeling tools
5362
03:44:14,520 --> 03:44:15,520
once again so I'll just close it and
5363
03:44:17,040 --> 03:44:18,040
open it up again so I'll open up the
5364
03:44:19,200 --> 03:44:20,200
modeling tools and if I type in poly
5365
03:44:22,260 --> 03:44:23,260
extrude you can actually draw a shape so
5366
03:44:25,739 --> 03:44:26,739
if I just click somewhere drag a point
5367
03:44:29,340 --> 03:44:30,340
do something like this
5368
03:44:32,100 --> 03:44:33,100
and if I join them
5369
03:44:35,100 --> 03:44:36,100
now I would be able to create something
5370
03:44:37,380 --> 03:44:38,380
like this so let's say I wanted to
5371
03:44:39,120 --> 03:44:40,120
create a castle wall or something
5372
03:44:41,160 --> 03:44:42,160
you could do that and the good part
5373
03:44:43,380 --> 03:44:44,380
about this is this is UV map by default
5374
03:44:46,439 --> 03:44:47,439
you don't have to actually you remap it
5375
03:44:48,660 --> 03:44:49,660
the UVS are pretty good so you can
5376
03:44:51,540 --> 03:44:52,540
directly go ahead and apply a texture
5377
03:44:53,160 --> 03:44:54,160
and it is going to look decent generally
5378
03:44:55,739 --> 03:44:56,739
if you create a weird shape like this in
5379
03:44:57,779 --> 03:44:58,779
a 3D modeling software you separately
5380
03:44:59,640 --> 03:45:00,640
have to go through the effort of UV
5381
03:45:01,800 --> 03:45:02,800
mapping it so that the textures don't
5382
03:45:03,600 --> 03:45:04,600
look distorted but in this case you are
5383
03:45:06,359 --> 03:45:07,359
good to go
5384
03:45:07,560 --> 03:45:08,560
so that's about it for the modeling
5385
03:45:09,960 --> 03:45:10,960
tools so you can mess around with those
5386
03:45:12,479 --> 03:45:13,479
these are really you know specific to
5387
03:45:15,120 --> 03:45:16,120
what you're doing
5388
03:45:16,260 --> 03:45:17,260
so according to what you would need you
5389
03:45:18,300 --> 03:45:19,300
would use the appropriate tools but it
5390
03:45:20,580 --> 03:45:21,580
is there now even over here you can
5391
03:45:22,680 --> 03:45:23,680
change the Pivot Point let's say for
5392
03:45:24,779 --> 03:45:25,779
example so I'll just show you guys once
5393
03:45:27,300 --> 03:45:28,300
again so modeling
5394
03:45:30,060 --> 03:45:31,060
if I select pivot
5395
03:45:32,960 --> 03:45:33,960
and if I
5396
03:45:36,060 --> 03:45:37,060
move this over and press accept you
5397
03:45:39,239 --> 03:45:40,239
would see that the pivot point mode over
5398
03:45:40,859 --> 03:45:41,859
there so that's about it so let's move
5399
03:45:43,680 --> 03:45:44,680
on to the next part
5400
03:45:45,670 --> 03:45:46,670
[Music]
5401
03:45:50,220 --> 03:45:51,220
so what I'm going to be talking about
5402
03:45:52,020 --> 03:45:53,020
next is kind of the basics of what we
5403
03:45:54,840 --> 03:45:55,840
did till now so basically we worked with
5404
03:45:57,600 --> 03:45:58,600
these models over here basically these
5405
03:46:00,720 --> 03:46:01,720
are called Static meshes so any and all
5406
03:46:04,140 --> 03:46:05,140
3D models which you get in the engine
5407
03:46:06,120 --> 03:46:07,120
without any sort of animations or
5408
03:46:09,000 --> 03:46:10,000
anything those will generally be static
5409
03:46:11,520 --> 03:46:12,520
meshes
5410
03:46:12,479 --> 03:46:13,479
uh any mesh with some sort of Animation
5411
03:46:15,540 --> 03:46:16,540
is going to be a skeletal mesh basically
5412
03:46:17,580 --> 03:46:18,580
so stuff like characters gun models and
5413
03:46:20,819 --> 03:46:21,819
those are going to be your skeletal
5414
03:46:22,800 --> 03:46:23,800
meshes anything which simulate physics
5415
03:46:26,040 --> 03:46:27,040
or which does not have animations so for
5416
03:46:29,220 --> 03:46:30,220
example the staircase may be a weapon
5417
03:46:32,640 --> 03:46:33,640
model in a pickup blueprint stuff like
5418
03:46:35,279 --> 03:46:36,279
that are going to be static meshes
5419
03:46:37,800 --> 03:46:38,800
so they are recognized by a light blue
5420
03:46:40,680 --> 03:46:41,680
color in the content browser so if I
5421
03:46:42,720 --> 03:46:43,720
head into models you see it has a light
5422
03:46:45,000 --> 03:46:46,000
blue color coding and this indicates
5423
03:46:47,700 --> 03:46:48,700
that it's a static mesh
5424
03:46:49,979 --> 03:46:50,979
now we will dive into skeletal meshes a
5425
03:46:54,180 --> 03:46:55,180
little more in depth later on but for
5426
03:46:56,640 --> 03:46:57,640
now I'll just head into static meshes
5427
03:46:58,620 --> 03:46:59,620
there are a couple of things which I
5428
03:47:00,180 --> 03:47:01,180
would like to cover first one is
5429
03:47:01,560 --> 03:47:02,560
enabling nanite now if I head into
5430
03:47:04,680 --> 03:47:05,680
wireframe mode
5431
03:47:06,899 --> 03:47:07,899
so now I can actually see
5432
03:47:10,200 --> 03:47:11,200
all of the vertices in space
5433
03:47:13,140 --> 03:47:14,140
foreign
5434
03:47:17,279 --> 03:47:18,279
now say I have many of the Spheres and
5435
03:47:20,939 --> 03:47:21,939
in this case I have more than six
5436
03:47:24,120 --> 03:47:25,120
thousand so six thousand four hundred
5437
03:47:25,920 --> 03:47:26,920
and eighty so your first question over
5438
03:47:28,800 --> 03:47:29,800
here is how's the performance still this
5439
03:47:31,080 --> 03:47:32,080
great
5440
03:47:31,859 --> 03:47:32,859
that is thanks to nanite so if you right
5441
03:47:35,040 --> 03:47:36,040
click on your model and enable nanite
5442
03:47:37,020 --> 03:47:38,020
over here if you right click and click
5443
03:47:39,120 --> 03:47:40,120
on enable you will enable nanite now if
5444
03:47:41,220 --> 03:47:42,220
I go ahead and disable this you would
5445
03:47:43,739 --> 03:47:44,739
see that the performance dips
5446
03:47:45,120 --> 03:47:46,120
immediately
5447
03:47:46,620 --> 03:47:47,620
so that's one thing about nanite so as
5448
03:47:50,640 --> 03:47:51,640
you can see it's really not playable at
5449
03:47:52,800 --> 03:47:53,800
this point now if I mean obviously this
5450
03:47:55,319 --> 03:47:56,319
is highly unrealistic and moreover it
5451
03:47:57,420 --> 03:47:58,420
will depend more on your computer as
5452
03:47:59,220 --> 03:48:00,220
well so if I go ahead and enable nanite
5453
03:48:01,680 --> 03:48:02,680
now and if I press play as you can see
5454
03:48:04,020 --> 03:48:05,020
even with so many spheres right in front
5455
03:48:05,939 --> 03:48:06,939
of me
5456
03:48:06,840 --> 03:48:07,840
it's absolutely not affecting
5457
03:48:08,819 --> 03:48:09,819
performance now we are not here to talk
5458
03:48:10,500 --> 03:48:11,500
about the actual technology involved in
5459
03:48:12,420 --> 03:48:13,420
nanite so that's the reason I'm not
5460
03:48:13,920 --> 03:48:14,920
telling anything else but this is
5461
03:48:16,080 --> 03:48:17,080
basically it currently in 5.0.3 there
5462
03:48:19,200 --> 03:48:20,200
are a few limitations for example let's
5463
03:48:21,840 --> 03:48:22,840
say I wanted to use this on a tree you
5464
03:48:23,880 --> 03:48:24,880
probably cannot because trees contain
5465
03:48:26,700 --> 03:48:27,700
leaves and leaves used masked materials
5466
03:48:29,580 --> 03:48:30,580
and those are not yet supported on
5467
03:48:31,739 --> 03:48:32,739
nanite and it but they will be supported
5468
03:48:33,899 --> 03:48:34,899
in 5.1 so very very soon you would be
5469
03:48:37,020 --> 03:48:38,020
able to use them
5470
03:48:38,420 --> 03:48:39,420
so that's about it there are few
5471
03:48:40,680 --> 03:48:41,680
material features which you can't use
5472
03:48:42,359 --> 03:48:43,359
and we will talk about materials so
5473
03:48:44,279 --> 03:48:45,279
stuff like dithering and stuff you will
5474
03:48:46,500 --> 03:48:47,500
have to just disable those notes if you
5475
03:48:48,660 --> 03:48:49,660
want to use nanite but for most objects
5476
03:48:51,660 --> 03:48:52,660
or stuff like walls or maybe if you have
5477
03:48:54,960 --> 03:48:55,960
an insane level something like this
5478
03:48:56,779 --> 03:48:57,779
nanite is going to come in handy so
5479
03:48:59,399 --> 03:49:00,399
that's about nanite
5480
03:49:01,970 --> 03:49:02,970
[Music]
5481
03:49:06,239 --> 03:49:07,239
by now one thing that we would have
5482
03:49:08,580 --> 03:49:09,580
probably noticed is that any and all
5483
03:49:10,979 --> 03:49:11,979
objects in the scene actually have some
5484
03:49:13,739 --> 03:49:14,739
sort of a material on them so for
5485
03:49:16,560 --> 03:49:17,560
example this has some neon blue texture
5486
03:49:19,439 --> 03:49:20,439
on it and it seems to be glowing and
5487
03:49:22,859 --> 03:49:23,859
this box right here has some sort of
5488
03:49:24,979 --> 03:49:25,979
checkerboard and same with the ground so
5489
03:49:28,439 --> 03:49:29,439
what's up with that so basically those
5490
03:49:30,420 --> 03:49:31,420
are materials and that's what gives the
5491
03:49:33,779 --> 03:49:34,779
color and all the other roughness
5492
03:49:36,359 --> 03:49:37,359
related properties of a given surface
5493
03:49:39,479 --> 03:49:40,479
now let's actually go about seeing how
5494
03:49:42,120 --> 03:49:43,120
to create a material and apply it on
5495
03:49:43,920 --> 03:49:44,920
objects so let's just use a cube for
5496
03:49:47,279 --> 03:49:48,279
example in order to demonstrate using
5497
03:49:49,500 --> 03:49:50,500
materials so let me just grab in a cube
5498
03:49:52,620 --> 03:49:53,620
and I'll just place it in the scene
5499
03:49:54,899 --> 03:49:55,899
now this has a material basic shape
5500
03:49:57,540 --> 03:49:58,540
material you can actually explore this
5501
03:49:58,920 --> 03:49:59,920
by clicking on this search icon over
5502
03:50:00,779 --> 03:50:01,779
here
5503
03:50:01,979 --> 03:50:02,979
so we'll actually go to the directory
5504
03:50:04,080 --> 03:50:05,080
where the material is stored but in our
5505
03:50:06,960 --> 03:50:07,960
case let's create a new folder called
5506
03:50:08,640 --> 03:50:09,640
materials
5507
03:50:11,359 --> 03:50:12,359
and let's go ahead and open it up
5508
03:50:14,939 --> 03:50:15,939
right click and create a new material or
5509
03:50:18,540 --> 03:50:19,540
you can head into materials and create a
5510
03:50:20,520 --> 03:50:21,520
new material here now the most important
5511
03:50:22,739 --> 03:50:23,739
ones are just materials and material
5512
03:50:24,840 --> 03:50:25,840
instances the rest are just stuff which
5513
03:50:28,080 --> 03:50:29,080
you might need in specific circumstances
5514
03:50:30,300 --> 03:50:31,300
so we'll take a look at material and
5515
03:50:32,880 --> 03:50:33,880
let's call this one our material now
5516
03:50:35,220 --> 03:50:36,220
applying a material on a surface is
5517
03:50:37,260 --> 03:50:38,260
actually really simple now we aren't
5518
03:50:39,479 --> 03:50:40,479
going to be dealing with multiple
5519
03:50:41,420 --> 03:50:42,420
materials on a single object in this
5520
03:50:44,100 --> 03:50:45,100
part of the course we will try to deal
5521
03:50:46,439 --> 03:50:47,439
with it later on but for now we won't be
5522
03:50:48,540 --> 03:50:49,540
doing anything so by default you get
5523
03:50:50,760 --> 03:50:51,760
this Checker material so I'll just drag
5524
03:50:52,500 --> 03:50:53,500
this in
5525
03:50:53,520 --> 03:50:54,520
and you can in order to apply it you
5526
03:50:55,979 --> 03:50:56,979
just drag it basically on the surface
5527
03:50:58,020 --> 03:50:59,020
that's how you do it or if you want to
5528
03:51:00,359 --> 03:51:01,359
apply it to a static mesh in general so
5529
03:51:04,080 --> 03:51:05,080
let's say I wanted all of the uh okay
5530
03:51:07,319 --> 03:51:08,319
whatever this object is so let's say I
5531
03:51:09,840 --> 03:51:10,840
wanted all of this object to have our
5532
03:51:12,600 --> 03:51:13,600
material so what I do is I head into the
5533
03:51:15,239 --> 03:51:16,239
static mesh and over here I'm going to
5534
03:51:17,399 --> 03:51:18,399
select our material so
5535
03:51:19,920 --> 03:51:20,920
let me go back
5536
03:51:21,779 --> 03:51:22,779
so all content materials are material
5537
03:51:25,319 --> 03:51:26,319
you can select that and you can click on
5538
03:51:27,300 --> 03:51:28,300
this Arrow icon which will use our
5539
03:51:29,700 --> 03:51:30,700
material so now it's actually using our
5540
03:51:32,160 --> 03:51:33,160
material so we haven't seen any change
5541
03:51:34,439 --> 03:51:35,439
because
5542
03:51:35,520 --> 03:51:36,520
we don't have anything set up in the
5543
03:51:37,560 --> 03:51:38,560
material but the way you actually start
5544
03:51:41,220 --> 03:51:42,220
working with this is by using these
5545
03:51:44,460 --> 03:51:45,460
nodes so this pin right here is as the
5546
03:51:47,939 --> 03:51:48,939
name suggests the base color now how do
5547
03:51:50,460 --> 03:51:51,460
you define a base color so the most
5548
03:51:52,800 --> 03:51:53,800
basic node over here is going to be a
5549
03:51:55,140 --> 03:51:56,140
constant
5550
03:51:56,399 --> 03:51:57,399
so whoops I press C on the keyboard I'm
5551
03:51:58,739 --> 03:51:59,739
supposed to press 1 on the keyboard and
5552
03:52:00,899 --> 03:52:01,899
left click and you see you get this node
5553
03:52:03,779 --> 03:52:04,779
here which allows you to enter value now
5554
03:52:06,660 --> 03:52:07,660
generally you would enter a value
5555
03:52:07,920 --> 03:52:08,920
between 0 and 1 but in some cases you
5556
03:52:10,800 --> 03:52:11,800
would enter higher and lower values so
5557
03:52:12,960 --> 03:52:13,960
in this case if I just plug this in the
5558
03:52:15,420 --> 03:52:16,420
base color and you can see it's
5559
03:52:16,739 --> 03:52:17,739
compatible
5560
03:52:18,300 --> 03:52:19,300
so you would see that our material is
5561
03:52:21,899 --> 03:52:22,899
fully black
5562
03:52:23,160 --> 03:52:24,160
now
5563
03:52:24,720 --> 03:52:25,720
it's just a fully black material what if
5564
03:52:27,899 --> 03:52:28,899
I increase this a bit
5565
03:52:32,340 --> 03:52:33,340
now save that again as you can see it
5566
03:52:35,760 --> 03:52:36,760
became a lighter shade of gray
5567
03:52:38,580 --> 03:52:39,580
so one is going to be white so this is
5568
03:52:40,620 --> 03:52:41,620
basically a gradient 0 is black and one
5569
03:52:43,800 --> 03:52:44,800
is white
5570
03:52:44,760 --> 03:52:45,760
what if you wanted to give a color so
5571
03:52:47,460 --> 03:52:48,460
you'd hold three on your keyboard and
5572
03:52:49,380 --> 03:52:50,380
left click then you'd get something
5573
03:52:51,960 --> 03:52:52,960
known as a constant three Vector this is
5574
03:52:54,779 --> 03:52:55,779
basically our r g and B value so red
5575
03:52:57,239 --> 03:52:58,239
green and blue
5576
03:52:58,859 --> 03:52:59,859
so you can go ahead if you wanted red
5577
03:53:00,720 --> 03:53:01,720
you could do 100
5578
03:53:03,239 --> 03:53:04,239
and as you can see
5579
03:53:05,640 --> 03:53:06,640
you get a red color material and it's
5580
03:53:07,739 --> 03:53:08,739
applied to all the objects which are
5581
03:53:09,660 --> 03:53:10,660
using our material so that's about it
5582
03:53:12,060 --> 03:53:13,060
for base color now if you want to bring
5583
03:53:14,880 --> 03:53:15,880
in any textures I recommend this website
5584
03:53:17,520 --> 03:53:18,520
called cc0 textures
5585
03:53:19,979 --> 03:53:20,979
so open it up now it's renamed to
5586
03:53:22,979 --> 03:53:23,979
ambient CG keep forgetting about that so
5587
03:53:26,220 --> 03:53:27,220
if you just head in and you can just
5588
03:53:28,319 --> 03:53:29,319
grab in any texture
5589
03:53:30,540 --> 03:53:31,540
so just I'll just grab in the lowest
5590
03:53:32,939 --> 03:53:33,939
resolution one
5591
03:53:34,739 --> 03:53:35,739
so I can open it up in my folder over
5592
03:53:37,020 --> 03:53:38,020
there
5593
03:53:39,620 --> 03:53:40,620
and over here I'll just drag it into
5594
03:53:42,060 --> 03:53:43,060
images for now I just have it set up
5595
03:53:44,460 --> 03:53:45,460
like this
5596
03:53:45,479 --> 03:53:46,479
so I'm just going to extract it
5597
03:53:49,680 --> 03:53:50,680
and over here you see you get a bunch of
5598
03:53:52,319 --> 03:53:53,319
textures if you want to import it in the
5599
03:53:54,960 --> 03:53:55,960
engine it's really simple actually to
5600
03:53:57,000 --> 03:53:58,000
import any asset B textures models or
5601
03:53:59,700 --> 03:54:00,700
whatever so we'll create a new folder
5602
03:54:01,560 --> 03:54:02,560
and we'll import it so textures
5603
03:54:04,859 --> 03:54:05,859
open it up and if I go ahead and drag
5604
03:54:08,700 --> 03:54:09,700
this for example so
5605
03:54:10,920 --> 03:54:11,920
I can just select all of these
5606
03:54:14,100 --> 03:54:15,100
and I can go ahead and drag this in my
5607
03:54:17,160 --> 03:54:18,160
content browser
5608
03:54:19,200 --> 03:54:20,200
and we can go ahead and save it
5609
03:54:21,660 --> 03:54:22,660
now if I want to apply this texture to
5610
03:54:23,939 --> 03:54:24,939
this material now first of all we'll see
5611
03:54:26,460 --> 03:54:27,460
which one is the base color sometimes
5612
03:54:28,680 --> 03:54:29,680
these textures are labeled as Albedo but
5613
03:54:31,620 --> 03:54:32,620
Albedo is basically a base color without
5614
03:54:34,080 --> 03:54:35,080
any sort of uh Shadow related
5615
03:54:36,779 --> 03:54:37,779
information that's basically what it
5616
03:54:38,939 --> 03:54:39,939
means without any other sort of
5617
03:54:40,979 --> 03:54:41,979
detailing it's just the raw color
5618
03:54:45,239 --> 03:54:46,239
so if I drag this in the base color I
5619
03:54:48,060 --> 03:54:49,060
can do that now you could do this as
5620
03:54:51,359 --> 03:54:52,359
well
5621
03:54:52,560 --> 03:54:53,560
totally fine
5622
03:54:54,660 --> 03:54:55,660
so this is how you would bring in a
5623
03:54:56,340 --> 03:54:57,340
texture now if I go ahead and look into
5624
03:54:59,399 --> 03:55:00,399
my level you see we have this wood
5625
03:55:01,380 --> 03:55:02,380
texture on our little wall here now what
5626
03:55:04,680 --> 03:55:05,680
if I wanted to tile this texture a
5627
03:55:08,040 --> 03:55:09,040
little better now let's say I wanted to
5628
03:55:10,080 --> 03:55:11,080
make this bigger or smaller you'd use
5629
03:55:12,540 --> 03:55:13,540
something known as a texture coordinate
5630
03:55:14,460 --> 03:55:15,460
so you type in text chord and you're
5631
03:55:17,279 --> 03:55:18,279
gonna see
5632
03:55:18,420 --> 03:55:19,420
texture coordinate plug that into the
5633
03:55:21,180 --> 03:55:22,180
UVs
5634
03:55:22,439 --> 03:55:23,439
and now let's say I press 0.1 your
5635
03:55:25,620 --> 03:55:26,620
texture will now be scaled 10 times you
5636
03:55:27,720 --> 03:55:28,720
and we are basically like your X and Y
5637
03:55:30,660 --> 03:55:31,660
to be very vague now we zoomed in way
5638
03:55:33,479 --> 03:55:34,479
too much so let's let's make two now so
5639
03:55:36,420 --> 03:55:37,420
now you see it's going to be more tiled
5640
03:55:39,120 --> 03:55:40,120
so now if you would see
5641
03:55:42,600 --> 03:55:43,600
you would have a more tiled material so
5642
03:55:45,600 --> 03:55:46,600
if I make this three for example
5643
03:55:48,899 --> 03:55:49,899
and if I go ahead and save this you
5644
03:55:52,260 --> 03:55:53,260
would see that it'll be even more tiled
5645
03:55:54,120 --> 03:55:55,120
so I can make this 3.5 I can increase
5646
03:55:57,660 --> 03:55:58,660
the value and it's going to be more
5647
03:55:59,399 --> 03:56:00,399
tiled so I can click apply save
5648
03:56:03,000 --> 03:56:04,000
and I should be able to see there are
5649
03:56:05,160 --> 03:56:06,160
more number of Tricks now I'll I'll just
5650
03:56:07,319 --> 03:56:08,319
set this to one once again
5651
03:56:09,600 --> 03:56:10,600
and save that and as you can see it's
5652
03:56:11,580 --> 03:56:12,580
applied to our level now this may be
5653
03:56:15,899 --> 03:56:16,899
fine but what if you wanted more details
5654
03:56:18,479 --> 03:56:19,479
let's say you wanted to make this very
5655
03:56:20,100 --> 03:56:21,100
glossy so in that case you can use the
5656
03:56:23,160 --> 03:56:24,160
roughness node now the roughness is
5657
03:56:26,460 --> 03:56:27,460
basically a zero to one value so you can
5658
03:56:28,319 --> 03:56:29,319
again use a constant if you want so 0 is
5659
03:56:31,020 --> 03:56:32,020
going to be fully reflective
5660
03:56:34,560 --> 03:56:35,560
now you could use the specular Channel
5661
03:56:36,479 --> 03:56:37,479
as well but most of the times you will
5662
03:56:38,520 --> 03:56:39,520
only use roughness
5663
03:56:40,380 --> 03:56:41,380
it's very rare that you'll actually mess
5664
03:56:42,239 --> 03:56:43,239
with the specular channel so now if I go
5665
03:56:46,260 --> 03:56:47,260
ahead and apply this
5666
03:56:47,819 --> 03:56:48,819
you'd see that it's very glossy
5667
03:56:51,000 --> 03:56:52,000
and if that's not really that clear drag
5668
03:56:53,819 --> 03:56:54,819
in a point light
5669
03:56:55,859 --> 03:56:56,859
just move this and as you can see it's
5670
03:56:57,720 --> 03:56:58,720
reflecting everything over there you see
5671
03:56:59,520 --> 03:57:00,520
the little point over there so that's
5672
03:57:02,580 --> 03:57:03,580
showing roughness 0
5673
03:57:04,739 --> 03:57:05,739
now if I change this to 1 for example
5674
03:57:07,020 --> 03:57:08,020
and if I hit save
5675
03:57:09,960 --> 03:57:10,960
you'd see that it's not reflecting the
5676
03:57:12,479 --> 03:57:13,479
light at all
5677
03:57:13,739 --> 03:57:14,739
so that's the use of the roughness
5678
03:57:16,199 --> 03:57:17,199
Channel now obviously this is some sort
5679
03:57:20,160 --> 03:57:21,160
of a wood floor texture so obviously it
5680
03:57:24,120 --> 03:57:25,120
will be depending on the grains of
5681
03:57:25,979 --> 03:57:26,979
what's there over there so
5682
03:57:28,680 --> 03:57:29,680
how you would set it up is by using a
5683
03:57:31,020 --> 03:57:32,020
roughness map now generally in in
5684
03:57:33,060 --> 03:57:34,060
websites such as cc0 or ambient CG now
5685
03:57:36,479 --> 03:57:37,479
as it's called you would get something
5686
03:57:38,279 --> 03:57:39,279
known as a roughness map basically the
5687
03:57:41,580 --> 03:57:42,580
brighter parts of the image are where
5688
03:57:43,620 --> 03:57:44,620
the light is reflected more the darker
5689
03:57:46,380 --> 03:57:47,380
parts of the image are where light is
5690
03:57:48,479 --> 03:57:49,479
not reflected so let's say there is a
5691
03:57:51,899 --> 03:57:52,899
fully black area here so that's where
5692
03:57:54,199 --> 03:57:55,199
all the light is going to be reflected
5693
03:57:56,580 --> 03:57:57,580
so I might have told it the other way
5694
03:57:58,739 --> 03:57:59,739
around basically the more bright the
5695
03:58:01,140 --> 03:58:02,140
color the more the roughness
5696
03:58:04,020 --> 03:58:05,020
now if I drag this in
5697
03:58:06,420 --> 03:58:07,420
use this in the roughness Channel
5698
03:58:09,359 --> 03:58:10,359
as you can see this gives us a little
5699
03:58:11,399 --> 03:58:12,399
more definition
5700
03:58:12,899 --> 03:58:13,899
now as you can see at the borders over
5701
03:58:15,660 --> 03:58:16,660
there you can clearly see that the
5702
03:58:17,760 --> 03:58:18,760
roughness map is doing something
5703
03:58:19,979 --> 03:58:20,979
so this is about roughness
5704
03:58:22,199 --> 03:58:23,199
similarly normal is basically uh your
5705
03:58:27,180 --> 03:58:28,180
depth so as you can see this texture
5706
03:58:30,300 --> 03:58:31,300
although it has a bit of roughness it
5707
03:58:32,279 --> 03:58:33,279
looks completely flat
5708
03:58:33,840 --> 03:58:34,840
now if I go ahead and add in the normal
5709
03:58:36,060 --> 03:58:37,060
map so if I just snap this to the left
5710
03:58:38,279 --> 03:58:39,279
and bring in my
5711
03:58:41,160 --> 03:58:42,160
unreal editor on the right
5712
03:58:43,620 --> 03:58:44,620
and if I go ahead and apply my normal
5713
03:58:46,380 --> 03:58:47,380
map here
5714
03:58:48,359 --> 03:58:49,359
and if I hit apply
5715
03:58:51,300 --> 03:58:52,300
as you can see you would see a little
5716
03:58:53,699 --> 03:58:54,699
bit of a depth over there
5717
03:58:56,160 --> 03:58:57,160
now if you can't really see it
5718
03:58:58,859 --> 03:58:59,859
that's probably because this is pretty
5719
03:59:00,720 --> 03:59:01,720
subtle so you can use something known as
5720
03:59:03,779 --> 03:59:04,779
a multiply basically it's just going to
5721
03:59:06,359 --> 03:59:07,359
multiply the value of each pixel in this
5722
03:59:08,939 --> 03:59:09,939
texture so multiply this you can use a
5723
03:59:12,300 --> 03:59:13,300
constant or you can set the value over
5724
03:59:14,040 --> 03:59:15,040
here itself in the multiply node so if I
5725
03:59:15,960 --> 03:59:16,960
type in 100 let's say
5726
03:59:19,199 --> 03:59:20,199
for example
5727
03:59:21,060 --> 03:59:22,060
so now you would be able to see a little
5728
03:59:23,580 --> 03:59:24,580
bit of the depth over there
5729
03:59:25,680 --> 03:59:26,680
but since this sort of a texture isn't
5730
03:59:28,439 --> 03:59:29,439
really containing much of depth so you
5731
03:59:31,380 --> 03:59:32,380
won't really see it
5732
03:59:32,939 --> 03:59:33,939
there are other ways to increase the
5733
03:59:34,739 --> 03:59:35,739
depth of a normal map but that's not the
5734
03:59:36,899 --> 03:59:37,899
point of this tutorial so basically
5735
03:59:38,460 --> 03:59:39,460
normal map is for your depth if you are
5736
03:59:41,340 --> 03:59:42,340
into PBR rendering you'll probably
5737
03:59:42,960 --> 03:59:43,960
already know all this stuff ambient
5738
03:59:45,359 --> 03:59:46,359
occlusion is basically like your depth
5739
03:59:50,699 --> 03:59:51,699
in your crevices and stuff it's kind of
5740
03:59:54,060 --> 03:59:55,060
hard to explain it there's actually a
5741
03:59:55,739 --> 03:59:56,739
comment here so simulate the self
5742
03:59:57,840 --> 03:59:58,840
shadowing that happens within crevices
5743
04:00:00,300 --> 04:00:01,300
of a surface basically that's what
5744
04:00:02,939 --> 04:00:03,939
ambient occlusion is so in stuff like
5745
04:00:04,979 --> 04:00:05,979
trees and rocks ambient occlusion is
5746
04:00:07,380 --> 04:00:08,380
something which would play a major role
5747
04:00:09,899 --> 04:00:10,899
on this sort of a texture it's really
5748
04:00:12,779 --> 04:00:13,779
not going to do much
5749
04:00:15,180 --> 04:00:16,180
so this is about the basics of materials
5750
04:00:18,779 --> 04:00:19,779
now obviously this is completely wrong
5751
04:00:22,140 --> 04:00:23,140
because we only have a texture
5752
04:00:24,120 --> 04:00:25,120
coordinate for that one texture so make
5753
04:00:26,460 --> 04:00:27,460
sure you plug everything in
5754
04:00:29,520 --> 04:00:30,520
so just plug everything in
5755
04:00:31,859 --> 04:00:32,859
now if you go ahead and apply and save
5756
04:00:34,199 --> 04:00:35,199
that
5757
04:00:35,340 --> 04:00:36,340
now you'd be able to see that it's
5758
04:00:37,800 --> 04:00:38,800
applied properly
5759
04:00:39,439 --> 04:00:40,439
this had a subtle effect from the start
5760
04:00:42,479 --> 04:00:43,479
itself so that's the reason you couldn't
5761
04:00:44,640 --> 04:00:45,640
really see anything wrong with it
5762
04:00:48,020 --> 04:00:49,020
so we created a basic material here
5763
04:00:52,080 --> 04:00:53,080
now for any of these you can actually
5764
04:00:54,779 --> 04:00:55,779
use your constants but most of the time
5765
04:00:57,660 --> 04:00:58,660
except base color you won't be using
5766
04:00:59,580 --> 04:01:00,580
constants you will be using textures
5767
04:01:02,580 --> 04:01:03,580
now
5768
04:01:03,899 --> 04:01:04,899
that's the very basics of materials
5769
04:01:06,420 --> 04:01:07,420
there are a lot you can do let's say you
5770
04:01:08,520 --> 04:01:09,520
wanted to make this thing glow so let me
5771
04:01:10,859 --> 04:01:11,859
just remove all of this stuff
5772
04:01:13,199 --> 04:01:14,199
let's say I just wanted a glowing neon
5773
04:01:15,720 --> 04:01:16,720
green color so let me just get a
5774
04:01:17,880 --> 04:01:18,880
constant pre vector
5775
04:01:20,279 --> 04:01:21,279
so the same right click search menu
5776
04:01:22,199 --> 04:01:23,199
exists in the material editor as well
5777
04:01:25,439 --> 04:01:26,439
drag that in the base color
5778
04:01:27,660 --> 04:01:28,660
and what you want to do is first you can
5779
04:01:30,000 --> 04:01:31,000
grab in a constant and maybe let's say
5780
04:01:32,460 --> 04:01:33,460
you have 10 this has to be a value
5781
04:01:34,319 --> 04:01:35,319
greater than 1.
5782
04:01:36,060 --> 04:01:37,060
so let's say I have 2 for example
5783
04:01:39,300 --> 04:01:40,300
so now you'd see that it's completely
5784
04:01:41,760 --> 04:01:42,760
glowing white in color
5785
04:01:44,640 --> 04:01:45,640
now if you wanted it to Glow in this
5786
04:01:46,979 --> 04:01:47,979
color itself what you do is you would
5787
04:01:49,739 --> 04:01:50,739
actually get this and you would multiply
5788
04:01:51,600 --> 04:01:52,600
this by 2.
5789
04:01:53,279 --> 04:01:54,279
so you would multiply this by two
5790
04:01:56,760 --> 04:01:57,760
now if I go ahead and press save you see
5791
04:01:59,460 --> 04:02:00,460
it's glowing in
5792
04:02:00,960 --> 04:02:01,960
sort of green color
5793
04:02:03,420 --> 04:02:04,420
so this is basically called an emissive
5794
04:02:06,779 --> 04:02:07,779
material because it emits light and it's
5795
04:02:10,080 --> 04:02:11,080
pretty cool to look at
5796
04:02:12,120 --> 04:02:13,120
by adjusting the value you multiplied
5797
04:02:15,000 --> 04:02:16,000
with you adjust the intensity now one
5798
04:02:18,899 --> 04:02:19,899
problem which you might have noticed
5799
04:02:20,220 --> 04:02:21,220
here is every time we want to change a
5800
04:02:22,560 --> 04:02:23,560
value so for example we want to make
5801
04:02:26,220 --> 04:02:27,220
this less bright let's say 1.5
5802
04:02:29,640 --> 04:02:30,640
now every time we have to apply and save
5803
04:02:32,040 --> 04:02:33,040
this what if we could dynamically change
5804
04:02:34,680 --> 04:02:35,680
this that's where material instances
5805
04:02:37,020 --> 04:02:38,020
come in is basically like your derived
5806
04:02:39,720 --> 04:02:40,720
class in your C plus plus inheritance
5807
04:02:42,960 --> 04:02:43,960
but to put that in short basically you
5808
04:02:47,279 --> 04:02:48,279
create another asset known as a material
5809
04:02:49,979 --> 04:02:50,979
instance which is subordinate to this
5810
04:02:53,279 --> 04:02:54,279
material and you can edit all the
5811
04:02:55,979 --> 04:02:56,979
parameters in it so I can right click on
5812
04:02:58,680 --> 04:02:59,680
our material and create the material
5813
04:03:00,660 --> 04:03:01,660
instance and let's just keep it as the
5814
04:03:04,319 --> 04:03:05,319
engine has suggested now instead of
5815
04:03:06,600 --> 04:03:07,600
applying our material we'll apply our
5816
04:03:08,880 --> 04:03:09,880
material instance nothing has changed
5817
04:03:11,460 --> 04:03:12,460
obviously however if I head into our
5818
04:03:15,300 --> 04:03:16,300
material instance now I can change the
5819
04:03:17,640 --> 04:03:18,640
parameters over here the first thing you
5820
04:03:19,800 --> 04:03:20,800
might notice is there is nothing to
5821
04:03:21,420 --> 04:03:22,420
change
5822
04:03:22,260 --> 04:03:23,260
so how do you do that basically you
5823
04:03:25,800 --> 04:03:26,800
would have to head in here right click
5824
04:03:28,439 --> 04:03:29,439
and convert it to a parameter
5825
04:03:30,899 --> 04:03:31,899
so any constant or any texture which you
5826
04:03:33,840 --> 04:03:34,840
convert to a parameter will be a value
5827
04:03:36,000 --> 04:03:37,000
which you can change so this is going to
5828
04:03:38,040 --> 04:03:39,040
be called brightness let's say
5829
04:03:40,500 --> 04:03:41,500
brightness
5830
04:03:42,479 --> 04:03:43,479
and this one is going to be called color
5831
04:03:44,460 --> 04:03:45,460
so right click convert to parameter and
5832
04:03:46,319 --> 04:03:47,319
call this one color
5833
04:03:47,760 --> 04:03:48,760
now apply and save it
5834
04:03:51,060 --> 04:03:52,060
now if I open up my instance
5835
04:03:53,939 --> 04:03:54,939
you would see that you get two
5836
04:03:55,800 --> 04:03:56,800
parameters and now I can edit them so
5837
04:03:57,899 --> 04:03:58,899
now if I press 2 you see the changes are
5838
04:04:00,660 --> 04:04:01,660
live so zero works one
5839
04:04:03,720 --> 04:04:04,720
two
5840
04:04:05,279 --> 04:04:06,279
not point three
5841
04:04:08,640 --> 04:04:09,640
so I can adjust my values just like this
5842
04:04:11,939 --> 04:04:12,939
and I can change the color as well and
5843
04:04:14,580 --> 04:04:15,580
it's updating dynamically
5844
04:04:16,979 --> 04:04:17,979
so for the most part you will be using
5845
04:04:20,279 --> 04:04:21,279
material instances for this purpose
5846
04:04:22,199 --> 04:04:23,199
itself
5847
04:04:23,399 --> 04:04:24,399
so these were the basics of materials
5848
04:04:25,979 --> 04:04:26,979
now you could Tinker around a bit look
5849
04:04:28,260 --> 04:04:29,260
into the documentation and create
5850
04:04:30,000 --> 04:04:31,000
something yourself
5851
04:04:31,700 --> 04:04:32,700
[Music]
5852
04:04:35,880 --> 04:04:36,880
now we haven't talked too much about the
5853
04:04:38,520 --> 04:04:39,520
other type of mesh that is the skeletal
5854
04:04:41,520 --> 04:04:42,520
mesh so let's talk about that now now if
5855
04:04:44,699 --> 04:04:45,699
I go ahead and press play actually you'd
5856
04:04:46,859 --> 04:04:47,859
see that we have a character over here
5857
04:04:49,859 --> 04:04:50,859
which is moving around
5858
04:04:51,660 --> 04:04:52,660
now the animations aren't actually
5859
04:04:54,300 --> 04:04:55,300
complete if you were to notice he's just
5860
04:04:56,460 --> 04:04:57,460
sliding around he's not actually doing
5861
04:04:58,380 --> 04:04:59,380
anything
5862
04:04:59,160 --> 04:05:00,160
now how do you define the logic where
5863
04:05:02,220 --> 04:05:03,220
you know if you are moving above a
5864
04:05:04,380 --> 04:05:05,380
certain speed
5865
04:05:05,520 --> 04:05:06,520
maybe let's say you start moving you
5866
04:05:08,040 --> 04:05:09,040
want to play an animation how do you
5867
04:05:09,840 --> 04:05:10,840
define that so that is where you use an
5868
04:05:12,060 --> 04:05:13,060
animation blueprint and that is what I
5869
04:05:14,220 --> 04:05:15,220
was searching at the start of this
5870
04:05:16,020 --> 04:05:17,020
course when we actually did the
5871
04:05:17,640 --> 04:05:18,640
character so head into your character
5872
04:05:20,699 --> 04:05:21,699
over here one thing that you would
5873
04:05:23,040 --> 04:05:24,040
notice is if I just head into mesh and
5874
04:05:26,699 --> 04:05:27,699
if I just click on the search icon on
5875
04:05:28,680 --> 04:05:29,680
the animation blueprint it actually
5876
04:05:30,660 --> 04:05:31,660
takes us to a folder inside the engine
5877
04:05:32,640 --> 04:05:33,640
directory where there is an animation
5878
04:05:34,979 --> 04:05:35,979
blueprint which actually
5879
04:05:38,040 --> 04:05:39,040
does something over here
5880
04:05:40,080 --> 04:05:41,080
so this is how the animations are
5881
04:05:43,439 --> 04:05:44,439
actually controlled and we'll create one
5882
04:05:45,359 --> 04:05:46,359
from scratch we can reuse these
5883
04:05:47,520 --> 04:05:48,520
animations no problem
5884
04:05:49,140 --> 04:05:50,140
so head into your content folder not the
5885
04:05:51,960 --> 04:05:52,960
engine so content
5886
04:05:54,199 --> 04:05:55,199
and for now we can just head into our
5887
04:05:58,140 --> 04:05:59,140
models folder and over here let's assume
5888
04:06:01,140 --> 04:06:02,140
we had our character here so let's call
5889
04:06:03,540 --> 04:06:04,540
that tutorial character because I guess
5890
04:06:06,300 --> 04:06:07,300
that's what it was called tutorial TPP I
5891
04:06:08,580 --> 04:06:09,580
guess
5892
04:06:09,720 --> 04:06:10,720
I'll just open it up right click create
5893
04:06:12,720 --> 04:06:13,720
under animation create an animation
5894
04:06:14,760 --> 04:06:15,760
blueprint and select the skeleton now
5895
04:06:17,460 --> 04:06:18,460
now I'm assuming you have a little bit
5896
04:06:19,380 --> 04:06:20,380
of knowledge of what's a skeleton what
5897
04:06:22,020 --> 04:06:23,020
are bones and stuff so at least that
5898
04:06:24,540 --> 04:06:25,540
much would be required if you want to
5899
04:06:26,160 --> 04:06:27,160
understand this
5900
04:06:27,720 --> 04:06:28,720
basically know that each joint which you
5901
04:06:31,319 --> 04:06:32,319
have each uh point which can hinge
5902
04:06:34,979 --> 04:06:35,979
basically is going to be our bone
5903
04:06:38,779 --> 04:06:39,779
so I am not clear about that if I head
5904
04:06:41,819 --> 04:06:42,819
into the actual skeletal mesh
5905
04:06:44,040 --> 04:06:45,040
so if I head into this one so I'm not
5906
04:06:46,319 --> 04:06:47,319
sure what it's called and this one let's
5907
04:06:48,479 --> 04:06:49,479
leave it at new and MBP
5908
04:06:50,399 --> 04:06:51,399
so let's PPP I guess
5909
04:06:53,819 --> 04:06:54,819
so this is the skeletal mesh now if I
5910
04:06:56,220 --> 04:06:57,220
were to just click on this
5911
04:06:58,140 --> 04:06:59,140
and if I head into the skeleton view
5912
04:07:02,640 --> 04:07:03,640
you'd see for example this is going to
5913
04:07:05,460 --> 04:07:06,460
be your index so if I rotate it you can
5914
04:07:09,060 --> 04:07:10,060
see that we can actually control it
5915
04:07:12,120 --> 04:07:13,120
index 2 is going to be the further part
5916
04:07:14,460 --> 04:07:15,460
of the finger stuff like that I'm not
5917
04:07:17,100 --> 04:07:18,100
actually applying these changes so
5918
04:07:18,600 --> 04:07:19,600
that's totally okay
5919
04:07:20,220 --> 04:07:21,220
and for example if I take the pelvis I
5920
04:07:23,580 --> 04:07:24,580
can go ahead and rotate the entire thing
5921
04:07:25,979 --> 04:07:26,979
because that's the root that's the
5922
04:07:27,779 --> 04:07:28,779
reason it's happening if I take spine is
5923
04:07:30,000 --> 04:07:31,000
going to rotate the back
5924
04:07:32,520 --> 04:07:33,520
stuff like that let's say you wanted to
5925
04:07:35,040 --> 04:07:36,040
rotate it a little something like this
5926
04:07:38,819 --> 04:07:39,819
so you could make him Bend forward stuff
5927
04:07:41,100 --> 04:07:42,100
like that
5928
04:07:42,479 --> 04:07:43,479
so this is a skeletal mesh and output
5929
04:07:46,500 --> 04:07:47,500
pause over here in the anim graph as
5930
04:07:48,779 --> 04:07:49,779
soon as you open the animation blueprint
5931
04:07:50,819 --> 04:07:51,819
this is what determines what pose here
5932
04:07:53,040 --> 04:07:54,040
and by default it'll just take a t-pose
5933
04:07:55,080 --> 04:07:56,080
or whatever pose it was in when you
5934
04:07:56,640 --> 04:07:57,640
imported the model so let's apply our
5935
04:07:59,100 --> 04:08:00,100
animation blueprint to a character so
5936
04:08:01,380 --> 04:08:02,380
head into your character select the mesh
5937
04:08:03,960 --> 04:08:04,960
and for the animation blueprint let's
5938
04:08:06,420 --> 04:08:07,420
select new nmbp or whatever that was
5939
04:08:09,120 --> 04:08:10,120
called so new anim blueprint
5940
04:08:12,000 --> 04:08:13,000
so as you can see we are stuck in a
5941
04:08:14,340 --> 04:08:15,340
t-pose right now
5942
04:08:17,040 --> 04:08:18,040
and let's start applying animations
5943
04:08:19,680 --> 04:08:20,680
now in order to add an animation the
5944
04:08:22,439 --> 04:08:23,439
most basic way you could do it is you
5945
04:08:24,420 --> 04:08:25,420
can simply drag in this animation
5946
04:08:27,420 --> 04:08:28,420
and you can play it so this is going to
5947
04:08:30,479 --> 04:08:31,479
be
5948
04:08:31,979 --> 04:08:32,979
the idle animation
5949
04:08:33,840 --> 04:08:34,840
and these are animations which the
5950
04:08:35,699 --> 04:08:36,699
engine has provided so I haven't really
5951
04:08:37,800 --> 04:08:38,800
done anything here so if you have your
5952
04:08:41,040 --> 04:08:42,040
own character you would have your own
5953
04:08:42,359 --> 04:08:43,359
animations but as you can see there is
5954
04:08:44,819 --> 04:08:45,819
really no logic that you can Define over
5955
04:08:46,920 --> 04:08:47,920
here
5956
04:08:47,819 --> 04:08:48,819
so the way you do that
5957
04:08:49,800 --> 04:08:50,800
is by first of all we can start by
5958
04:08:52,739 --> 04:08:53,739
creating a state machine this is the
5959
04:08:54,779 --> 04:08:55,779
most basic thing you can do in an anime
5960
04:08:56,580 --> 04:08:57,580
blueprint so basically you can use your
5961
04:08:59,880 --> 04:09:00,880
variables over here
5962
04:09:01,620 --> 04:09:02,620
to determine Logic on how to change
5963
04:09:04,380 --> 04:09:05,380
between animations let me show you with
5964
04:09:07,080 --> 04:09:08,080
an example so we'll just leave it at New
5965
04:09:09,359 --> 04:09:10,359
State machine for now or we can call
5966
04:09:11,640 --> 04:09:12,640
this one uh walk run Maybe
5967
04:09:15,420 --> 04:09:16,420
idle walk run let's say
5968
04:09:20,040 --> 04:09:21,040
just name it appropriately and now if I
5969
04:09:23,100 --> 04:09:24,100
compile I'll be in a t pose again
5970
04:09:25,140 --> 04:09:26,140
now entry is where you would start so
5971
04:09:28,020 --> 04:09:29,020
obviously if nothing's really happening
5972
04:09:30,540 --> 04:09:31,540
you you'd want to idle so head into
5973
04:09:33,540 --> 04:09:34,540
tutorial Idol if you were to notice it
5974
04:09:36,899 --> 04:09:37,899
just outputs the animation because this
5975
04:09:39,239 --> 04:09:40,239
is something like your return node
5976
04:09:40,920 --> 04:09:41,920
basically
5977
04:09:41,819 --> 04:09:42,819
head back into your ideal walk run State
5978
04:09:43,979 --> 04:09:44,979
machine now if I compile
5979
04:09:46,380 --> 04:09:47,380
as you would see
5980
04:09:48,420 --> 04:09:49,420
it's playing behind the animation and if
5981
04:09:50,460 --> 04:09:51,460
I press play actually this is going to
5982
04:09:52,500 --> 04:09:53,500
work
5983
04:09:53,760 --> 04:09:54,760
now we want another state so right click
5984
04:09:56,580 --> 04:09:57,580
add State and this one is going to be
5985
04:09:58,979 --> 04:09:59,979
called walk slash run
5986
04:10:03,300 --> 04:10:04,300
now
5987
04:10:05,460 --> 04:10:06,460
this is a shortcut way to do it like I'm
5988
04:10:08,460 --> 04:10:09,460
not doing a separate Walk and Run face I
5989
04:10:11,580 --> 04:10:12,580
will do a separate Walk and Run state
5990
04:10:13,560 --> 04:10:14,560
after I do this
5991
04:10:15,180 --> 04:10:16,180
so we want to be able to transition from
5992
04:10:17,640 --> 04:10:18,640
idle to walk run so drag in an arrow
5993
04:10:20,520 --> 04:10:21,520
and when we stop we actually want to be
5994
04:10:23,340 --> 04:10:24,340
able to go back as well and I will show
5995
04:10:26,220 --> 04:10:27,220
you what I mean by that now if I head
5996
04:10:27,960 --> 04:10:28,960
into walk run
5997
04:10:29,760 --> 04:10:30,760
and if I drag this animation
5998
04:10:32,819 --> 04:10:33,819
you would see that he's not actually
5999
04:10:35,760 --> 04:10:36,760
heading into walk run
6000
04:10:39,000 --> 04:10:40,000
so what you can do is you can just set
6001
04:10:40,859 --> 04:10:41,859
this to true for example
6002
04:10:43,080 --> 04:10:44,080
and you would see that he will be in
6003
04:10:46,140 --> 04:10:47,140
this walk run state
6004
04:10:47,939 --> 04:10:48,939
so what this basically is is if this
6005
04:10:50,640 --> 04:10:51,640
Boolean is true
6006
04:10:52,279 --> 04:10:53,279
the character will be able to transition
6007
04:10:55,680 --> 04:10:56,680
from this animation to this basically
6008
04:10:58,859 --> 04:10:59,859
so how do you do that we can actually
6009
04:11:01,020 --> 04:11:02,020
set uh set up some logic here
6010
04:11:04,199 --> 04:11:05,199
so we can say is moving for example
6011
04:11:07,800 --> 04:11:08,800
this is not how you do it I'm just
6012
04:11:09,540 --> 04:11:10,540
showing you guys the basics so if he is
6013
04:11:12,000 --> 04:11:13,000
moving we want to transition to the
6014
04:11:15,060 --> 04:11:16,060
run face
6015
04:11:17,220 --> 04:11:18,220
so idle walk run we have that
6016
04:11:20,580 --> 04:11:21,580
now in the event graph we'll actually
6017
04:11:22,800 --> 04:11:23,800
set up the logic to get is moving
6018
04:11:25,140 --> 04:11:26,140
because remember we only have the
6019
04:11:27,600 --> 04:11:28,600
variable but we are not actually setting
6020
04:11:29,279 --> 04:11:30,279
the value so every time the animation
6021
04:11:32,100 --> 04:11:33,100
updates so that's going to be every
6022
04:11:33,540 --> 04:11:34,540
frame what we can do is we can try get
6023
04:11:37,319 --> 04:11:38,319
Pawn owner basically that's going to be
6024
04:11:39,720 --> 04:11:40,720
our character reference
6025
04:11:41,819 --> 04:11:42,819
and we can cast it to our uh I don't
6026
04:11:46,199 --> 04:11:47,199
know what it was called BP character I
6027
04:11:48,000 --> 04:11:49,000
guess
6028
04:11:49,920 --> 04:11:50,920
cast it to that don't do a cast on
6029
04:11:51,960 --> 04:11:52,960
update actually you can actually uh do
6030
04:11:54,660 --> 04:11:55,660
it on I guess it's called start
6031
04:12:00,060 --> 04:12:01,060
uh there's an equivalent of begin play
6032
04:12:02,160 --> 04:12:03,160
actually
6033
04:12:04,500 --> 04:12:05,500
event blueprint begin play so on this
6034
04:12:07,020 --> 04:12:08,020
node you can actually cast it and you
6035
04:12:09,120 --> 04:12:10,120
can store a reference and use that don't
6036
04:12:11,160 --> 04:12:12,160
cast to it every frame it's not
6037
04:12:12,840 --> 04:12:13,840
efficient
6038
04:12:14,160 --> 04:12:15,160
so you can promote that to a variable
6039
04:12:16,199 --> 04:12:17,199
and call this one character reference so
6040
04:12:19,140 --> 04:12:20,140
character
6041
04:12:22,080 --> 04:12:23,080
reference
6042
04:12:24,660 --> 04:12:25,660
and once we have that stored what we can
6043
04:12:27,660 --> 04:12:28,660
do is we can use that if this is valid
6044
04:12:30,359 --> 04:12:31,359
of course so convert to validated get if
6045
04:12:33,479 --> 04:12:34,479
our character reference is valid uh what
6046
04:12:36,300 --> 04:12:37,300
we'll do is we will get the speed
6047
04:12:40,500 --> 04:12:41,500
so how you get the speed is by getting
6048
04:12:43,020 --> 04:12:44,020
the velocity so velocity
6049
04:12:46,920 --> 04:12:47,920
get velocity and we are going to get the
6050
04:12:50,100 --> 04:12:51,100
vector length
6051
04:12:52,500 --> 04:12:53,500
and if this Vector length is greater
6052
04:12:56,220 --> 04:12:57,220
than zero
6053
04:12:58,020 --> 04:12:59,020
it means we are moving
6054
04:13:00,359 --> 04:13:01,359
so now if I compile you see his idle but
6055
04:13:03,239 --> 04:13:04,239
now if I press play
6056
04:13:04,680 --> 04:13:05,680
if I start moving you see the animation
6057
04:13:07,800 --> 04:13:08,800
triggers but now he's not going back
6058
04:13:10,680 --> 04:13:11,680
and that is where the transition comes
6059
04:13:12,600 --> 04:13:13,600
in we have set up the logic to go from
6060
04:13:14,640 --> 04:13:15,640
idle to walk run but the engine doesn't
6061
04:13:16,979 --> 04:13:17,979
know when to come back so a very simple
6062
04:13:19,739 --> 04:13:20,739
thing you can do is put this back and if
6063
04:13:22,800 --> 04:13:23,800
he is not moving so you can type in an
6064
04:13:25,140 --> 04:13:26,140
exclamation so if he is not moving
6065
04:13:28,500 --> 04:13:29,500
then we can go ahead and transition back
6066
04:13:31,680 --> 04:13:32,680
now if I press play
6067
04:13:33,779 --> 04:13:34,779
as you can see it's working just fine
6068
04:13:37,439 --> 04:13:38,439
now there are only two animations here
6069
04:13:39,540 --> 04:13:40,540
but what if you wanted to blend between
6070
04:13:41,399 --> 04:13:42,399
them what if you wanted a walk face
6071
04:13:43,800 --> 04:13:44,800
let's say
6072
04:13:45,180 --> 04:13:46,180
so the way you do it is by using a blend
6073
04:13:47,880 --> 04:13:48,880
space
6074
04:13:48,960 --> 04:13:49,960
so what a blend space is is basically
6075
04:13:51,660 --> 04:13:52,660
transitioning between two animations and
6076
04:13:54,600 --> 04:13:55,600
I'll just show that I'm not really going
6077
04:13:56,279 --> 04:13:57,279
to talk too much in depth about
6078
04:13:57,600 --> 04:13:58,600
animations and stuff but I I guess you
6079
04:14:00,899 --> 04:14:01,899
you guys kind of get the basic idea
6080
04:14:02,760 --> 04:14:03,760
let's say you had like a jumping
6081
04:14:04,620 --> 04:14:05,620
animation so what you do is you'd have
6082
04:14:07,380 --> 04:14:08,380
another Boolean for uh the jump State
6083
04:14:10,020 --> 04:14:11,020
and in this state machine here you'd
6084
04:14:12,060 --> 04:14:13,060
create a new state and call this one
6085
04:14:14,160 --> 04:14:15,160
jumping
6086
04:14:15,479 --> 04:14:16,479
and then you would transition from this
6087
04:14:19,020 --> 04:14:20,020
and you would go back stuff like that
6088
04:14:20,880 --> 04:14:21,880
that's basically how you do it
6089
04:14:23,760 --> 04:14:24,760
uh now if we wanted to set up our blend
6090
04:14:27,600 --> 04:14:28,600
space as I told you guys so head into
6091
04:14:29,760 --> 04:14:30,760
your models TP tutorial TPP
6092
04:14:33,479 --> 04:14:34,479
and let's just right click animation and
6093
04:14:36,600 --> 04:14:37,600
let's create a blend space
6094
04:14:39,300 --> 04:14:40,300
so now we can select a skeleton and
6095
04:14:41,880 --> 04:14:42,880
we'll call this one walk run for example
6096
04:14:43,739 --> 04:14:44,739
so walk run
6097
04:14:47,580 --> 04:14:48,580
if you have a separate walking animation
6098
04:14:49,439 --> 04:14:50,439
you can inject it in
6099
04:14:51,359 --> 04:14:52,359
but for now we won't
6100
04:14:53,819 --> 04:14:54,819
now in the access settings here this is
6101
04:14:56,939 --> 04:14:57,939
what you will actually be using so your
6102
04:14:59,340 --> 04:15:00,340
vertical axis is like your speed
6103
04:15:02,120 --> 04:15:03,120
basically I mean it's a convention you
6104
04:15:05,460 --> 04:15:06,460
can interchangeably use this but you can
6105
04:15:07,439 --> 04:15:08,439
use the vertical axis as speed so
6106
04:15:10,080 --> 04:15:11,080
basically you see the value of 0 to 100
6107
04:15:12,120 --> 04:15:13,120
so that's what it is so we can type in
6108
04:15:14,220 --> 04:15:15,220
speed
6109
04:15:15,359 --> 04:15:16,359
because we can use this name later on
6110
04:15:18,540 --> 04:15:19,540
and for the horizontal axis we can call
6111
04:15:21,060 --> 04:15:22,060
this One Direction
6112
04:15:23,100 --> 04:15:24,100
and it's going to be from minus 180 to
6113
04:15:26,279 --> 04:15:27,279
Plus 180.
6114
04:15:28,199 --> 04:15:29,199
over here for Speed we can go 0 to
6115
04:15:31,319 --> 04:15:32,319
whatever maximum speed by default at 600
6116
04:15:33,720 --> 04:15:34,720
so we'll go go with that
6117
04:15:35,699 --> 04:15:36,699
and we don't have sideways animations
6118
04:15:37,920 --> 04:15:38,920
otherwise on the left here you can place
6119
04:15:40,979 --> 04:15:41,979
your sideways animations I'll just show
6120
04:15:43,439 --> 04:15:44,439
you with these ones so obviously when
6121
04:15:45,899 --> 04:15:46,899
your speed and direction is zero you
6122
04:15:48,479 --> 04:15:49,479
would be idling
6123
04:15:49,800 --> 04:15:50,800
and walk forward is going to be over
6124
04:15:52,020 --> 04:15:53,020
here
6125
04:15:52,859 --> 04:15:53,859
now if I hold down shift and if I walk
6126
04:15:58,800 --> 04:15:59,800
through this
6127
04:16:00,779 --> 04:16:01,779
so whoops
6128
04:16:04,260 --> 04:16:05,260
so I might just leave that over there so
6129
04:16:06,600 --> 04:16:07,600
at 0 and 0.
6130
04:16:10,340 --> 04:16:11,340
and hold Ctrl actually hold Ctrl
6131
04:16:14,880 --> 04:16:15,880
and if you notice you're transitioning
6132
04:16:17,520 --> 04:16:18,520
between the animation so if I play
6133
04:16:20,880 --> 04:16:21,880
as you see now if you're walking slowly
6134
04:16:23,819 --> 04:16:24,819
so let's say I leave it at here so when
6135
04:16:26,640 --> 04:16:27,640
my speed is 373 and my direction is
6136
04:16:30,000 --> 04:16:31,000
whatever that is this is how the
6137
04:16:31,979 --> 04:16:32,979
animation is going to play
6138
04:16:34,560 --> 04:16:35,560
now if you want this to change a little
6139
04:16:36,899 --> 04:16:37,899
bit you can actually uh increase or
6140
04:16:41,220 --> 04:16:42,220
decrease the values over here
6141
04:16:43,160 --> 04:16:44,160
and smoothing time is basically for your
6142
04:16:46,020 --> 04:16:47,020
transition time so how long it will take
6143
04:16:48,060 --> 04:16:49,060
to transition from one animation to the
6144
04:16:50,040 --> 04:16:51,040
other generally I just leave it at zero
6145
04:16:52,439 --> 04:16:53,439
I've had no issues honestly
6146
04:16:54,660 --> 04:16:55,660
now in our animation blueprint instead
6147
04:16:56,880 --> 04:16:57,880
of this we can use our walk around blend
6148
04:16:58,739 --> 04:16:59,739
space
6149
04:17:00,840 --> 04:17:01,840
all right you can connect this blend
6150
04:17:03,180 --> 04:17:04,180
space to the output now we would see
6151
04:17:05,760 --> 04:17:06,760
that you have to provide the direction
6152
04:17:07,500 --> 04:17:08,500
and speed and doing that is actually
6153
04:17:10,140 --> 04:17:11,140
pretty simple so head into your event
6154
04:17:11,939 --> 04:17:12,939
graph and what you basically do is you
6155
04:17:15,420 --> 04:17:16,420
grab your character reference over here
6156
04:17:17,239 --> 04:17:18,239
and from this we can actually get the
6157
04:17:20,520 --> 04:17:21,520
velocity
6158
04:17:22,439 --> 04:17:23,439
so velocity
6159
04:17:26,040 --> 04:17:27,040
get velocity and then from here we can
6160
04:17:29,399 --> 04:17:30,399
get the vector length so basically the
6161
04:17:31,080 --> 04:17:32,080
magnitude of the vector
6162
04:17:34,680 --> 04:17:35,680
all right uh once we get that for the
6163
04:17:38,279 --> 04:17:39,279
direction actually uh we have a node
6164
04:17:40,739 --> 04:17:41,739
called calculate Direction
6165
04:17:43,020 --> 04:17:44,020
which requires uh the velocity
6166
04:17:46,500 --> 04:17:47,500
and I will tell you what to do next so
6167
04:17:50,399 --> 04:17:51,399
we need direction and speed so we can
6168
04:17:53,520 --> 04:17:54,520
promote these two variables so promote
6169
04:17:56,340 --> 04:17:57,340
to variable we can call this one
6170
04:17:58,979 --> 04:17:59,979
Direction
6171
04:18:01,500 --> 04:18:02,500
and we can call this one speed
6172
04:18:09,620 --> 04:18:10,620
and if the character is valid we can set
6173
04:18:13,439 --> 04:18:14,439
the direction and speed
6174
04:18:16,920 --> 04:18:17,920
over here in the direction
6175
04:18:19,859 --> 04:18:20,859
for the velocity
6176
04:18:22,140 --> 04:18:23,140
we can just directly grab in this pin
6177
04:18:24,540 --> 04:18:25,540
over here
6178
04:18:25,620 --> 04:18:26,620
and then what we can do is we can get
6179
04:18:29,580 --> 04:18:30,580
after
6180
04:18:31,020 --> 04:18:32,020
rotation
6181
04:18:36,359 --> 04:18:37,359
now if I hit compile and if I go ahead
6182
04:18:40,500 --> 04:18:41,500
and plug these in
6183
04:18:42,359 --> 04:18:43,359
over here in my blend space layer then
6184
04:18:46,140 --> 04:18:47,140
in my transition over here so walk run
6185
04:18:49,680 --> 04:18:50,680
to idle instead of not moving what we
6186
04:18:52,979 --> 04:18:53,979
can do is we can get the speed and if it
6187
04:18:56,160 --> 04:18:57,160
is less than a certain value
6188
04:18:58,560 --> 04:18:59,560
so if it is less than let's say about 10
6189
04:19:04,920 --> 04:19:05,920
so then we will enter this transition
6190
04:19:07,859 --> 04:19:08,859
similarly if the speed is greater than
6191
04:19:10,319 --> 04:19:11,319
10 we'll enter this transition
6192
04:19:12,600 --> 04:19:13,600
so if the speed is greater than 10
6193
04:19:16,140 --> 04:19:17,140
so then we can go ahead and transition
6194
04:19:18,359 --> 04:19:19,359
into the walk run state
6195
04:19:20,819 --> 04:19:21,819
so once we change that we should have
6196
04:19:22,920 --> 04:19:23,920
our logic working so now if I go ahead
6197
04:19:25,620 --> 04:19:26,620
and press play
6198
04:19:27,120 --> 04:19:28,120
as you can see
6199
04:19:28,920 --> 04:19:29,920
the walk run animations are working
6200
04:19:33,000 --> 04:19:34,000
so that's about it now we have finished
6201
04:19:35,640 --> 04:19:36,640
animating the character with some basic
6202
04:19:38,640 --> 04:19:39,640
animation blueprints
6203
04:19:40,979 --> 04:19:41,979
so that's all there is to it obviously
6204
04:19:44,460 --> 04:19:45,460
there are many more things you can do
6205
04:19:45,779 --> 04:19:46,779
with this animation blueprint of course
6206
04:19:48,359 --> 04:19:49,359
you can you can have sprinting as well
6207
04:19:50,460 --> 04:19:51,460
so if you would have Sprint uh you would
6208
04:19:53,040 --> 04:19:54,040
you know have another state called
6209
04:19:54,660 --> 04:19:55,660
Sprint and then you would plug it in
6210
04:19:57,239 --> 04:19:58,239
according to what logic you want
6211
04:19:59,399 --> 04:20:00,399
basically all you have to take care of
6212
04:20:01,560 --> 04:20:02,560
is when your character can transition
6213
04:20:04,439 --> 04:20:05,439
into States and make sure it's not going
6214
04:20:07,319 --> 04:20:08,319
to be in two states at the same time
6215
04:20:09,660 --> 04:20:10,660
that's about it and in the event graph
6216
04:20:12,420 --> 04:20:13,420
uh anything that has to update so for
6217
04:20:15,600 --> 04:20:16,600
example the speed of the character those
6218
04:20:17,939 --> 04:20:18,939
can be done over here on blueprint
6219
04:20:20,819 --> 04:20:21,819
update animation event
6220
04:20:23,100 --> 04:20:24,100
so now I I think this is more than
6221
04:20:26,699 --> 04:20:27,699
enough for blueprints and I I think with
6222
04:20:30,779 --> 04:20:31,779
this much of blueprint knowledge you
6223
04:20:34,380 --> 04:20:35,380
would be able to make an entire game
6224
04:20:37,040 --> 04:20:38,040
assuming of course you would be ready to
6225
04:20:40,080 --> 04:20:41,080
look into the documentation a bit and
6226
04:20:43,260 --> 04:20:44,260
look into what the various functions do
6227
04:20:46,199 --> 04:20:47,199
if you actually play around with
6228
04:20:47,939 --> 04:20:48,939
whatever we did plus look at a few extra
6229
04:20:50,279 --> 04:20:51,279
functions you can create an entire game
6230
04:20:53,420 --> 04:20:54,420
and now for the more keen ones out of
6231
04:20:57,120 --> 04:20:58,120
you here we are going to head into C
6232
04:20:59,699 --> 04:21:00,699
plus plus now
6233
04:21:01,080 --> 04:21:02,080
we'll be taking a deep dive into the
6234
04:21:03,960 --> 04:21:04,960
more advanced features of the engine now
6235
04:21:06,600 --> 04:21:07,600
not to worry for those people who don't
6236
04:21:08,819 --> 04:21:09,819
know C plus plus I will also be brushing
6237
04:21:11,279 --> 04:21:12,279
through some of the prerequisites that
6238
04:21:13,080 --> 04:21:14,080
you need in C plus plus in order to get
6239
04:21:15,600 --> 04:21:16,600
started honestly there's not much to do
6240
04:21:18,359 --> 04:21:19,359
with the language most of it would just
6241
04:21:20,340 --> 04:21:21,340
be function calls and stuff like that so
6242
04:21:23,100 --> 04:21:24,100
anyways without any more further delay
6243
04:21:25,319 --> 04:21:26,319
let's actually start learning C plus
6244
04:21:28,260 --> 04:21:29,260
plus for unreal now I will be going
6245
04:21:30,779 --> 04:21:31,779
through the basics now
6246
04:21:32,540 --> 04:21:33,540
[Music]
6247
04:21:37,680 --> 04:21:38,680
now let's just talk a little bit about
6248
04:21:39,899 --> 04:21:40,899
the prerequisite knowledge of C plus
6249
04:21:41,880 --> 04:21:42,880
plus which you'll need to actually
6250
04:21:43,260 --> 04:21:44,260
understand the further part of the
6251
04:21:45,000 --> 04:21:46,000
course I do still recommend you learn C
6252
04:21:48,060 --> 04:21:49,060
plus plus separately but I will get you
6253
04:21:50,580 --> 04:21:51,580
guys what you need for unreal because
6254
04:21:52,920 --> 04:21:53,920
it's really not that important to know
6255
04:21:54,840 --> 04:21:55,840
the language more so you need to know
6256
04:21:57,120 --> 04:21:58,120
the features which we actually will make
6257
04:21:59,520 --> 04:22:00,520
use of in unreal so I'll just create an
6258
04:22:02,520 --> 04:22:03,520
empty console application here so it's
6259
04:22:05,100 --> 04:22:06,100
just going to be a blank application
6260
04:22:07,140 --> 04:22:08,140
with in the terminal now I won't even
6261
04:22:09,899 --> 04:22:10,899
use this I'll just use an empty project
6262
04:22:11,760 --> 04:22:12,760
template
6263
04:22:13,080 --> 04:22:14,080
so I'll just search for empty in Visual
6264
04:22:15,300 --> 04:22:16,300
Studio of course
6265
04:22:16,500 --> 04:22:17,500
I mean we have it right here so just go
6266
04:22:18,960 --> 04:22:19,960
click next and doesn't really matter
6267
04:22:22,020 --> 04:22:23,020
I'll just look for a folder
6268
04:22:25,020 --> 04:22:26,020
so I'm just going to create it there and
6269
04:22:27,720 --> 04:22:28,720
click create
6270
04:22:30,359 --> 04:22:31,359
so just leave all the settings at
6271
04:22:31,920 --> 04:22:32,920
default none of these would matter for
6272
04:22:33,720 --> 04:22:34,720
now
6273
04:22:34,739 --> 04:22:35,739
now once I've created this I'll just go
6274
04:22:37,500 --> 04:22:38,500
ahead and set up
6275
04:22:38,880 --> 04:22:39,880
the basic stuff which you need for C
6276
04:22:40,979 --> 04:22:41,979
plus plus so first of all you'll need a
6277
04:22:43,020 --> 04:22:44,020
C plus plus file with a main function in
6278
04:22:45,479 --> 04:22:46,479
it so just to
6279
04:22:47,699 --> 04:22:48,699
uh just for my reference I'm going to
6280
04:22:49,859 --> 04:22:50,859
name it main.cpp
6281
04:22:52,199 --> 04:22:53,199
and we need a main function we'll not
6282
04:22:54,779 --> 04:22:55,779
get into that now so int Main
6283
04:22:57,899 --> 04:22:58,899
and we're just going to return 0. now
6284
04:23:00,600 --> 04:23:01,600
I'll not get into this but the feature
6285
04:23:03,300 --> 04:23:04,300
which first of all we'll need is to
6286
04:23:05,580 --> 04:23:06,580
include code from other files
6287
04:23:07,979 --> 04:23:08,979
now if you want to do that
6288
04:23:10,560 --> 04:23:11,560
you would do
6289
04:23:11,939 --> 04:23:12,939
hash include and inside angular brackets
6290
04:23:16,199 --> 04:23:17,199
or inside double quotes depending on the
6291
04:23:18,300 --> 04:23:19,300
situation
6292
04:23:19,319 --> 04:23:20,319
you would include the actual header file
6293
04:23:21,359 --> 04:23:22,359
so let's say I have a header file so
6294
04:23:23,340 --> 04:23:24,340
I'll create one
6295
04:23:25,380 --> 04:23:26,380
so go ahead and call this
6296
04:23:28,140 --> 04:23:29,140
I don't know header.h let's just leave
6297
04:23:30,060 --> 04:23:31,060
it as is
6298
04:23:31,279 --> 04:23:32,279
and pragma once basically means uh this
6299
04:23:35,580 --> 04:23:36,580
header file will only be included once
6300
04:23:37,680 --> 04:23:38,680
so you won't have circular dependencies
6301
04:23:40,020 --> 04:23:41,020
and stuff basically
6302
04:23:41,939 --> 04:23:42,939
but anyways let's go ahead and type some
6303
04:23:44,340 --> 04:23:45,340
code so in order to create variables
6304
04:23:47,399 --> 04:23:48,399
that's the first thing you'll need apart
6305
04:23:49,020 --> 04:23:50,020
from including so including this header
6306
04:23:51,120 --> 04:23:52,120
file is simple so in double quotes you
6307
04:23:53,460 --> 04:23:54,460
can put header dot h
6308
04:23:55,640 --> 04:23:56,640
or you could even use angular brackets
6309
04:23:58,439 --> 04:23:59,439
you know generally you would use that
6310
04:23:59,939 --> 04:24:00,939
only for like standard C plus plus stuff
6311
04:24:01,920 --> 04:24:02,920
but both of them will work
6312
04:24:04,140 --> 04:24:05,140
so if you want to include header.h
6313
04:24:06,600 --> 04:24:07,600
through this you might have to add it in
6314
04:24:08,939 --> 04:24:09,939
the include paths so will not do that we
6315
04:24:11,640 --> 04:24:12,640
will stick with this so let's say
6316
04:24:13,739 --> 04:24:14,739
something standard C plus plus such as
6317
04:24:15,600 --> 04:24:16,600
IO stream
6318
04:24:17,580 --> 04:24:18,580
so I misspelled that IO stream I can go
6319
04:24:21,000 --> 04:24:22,000
ahead and do this
6320
04:24:22,319 --> 04:24:23,319
or if I have something standard C for
6321
04:24:25,020 --> 04:24:26,020
example windows
6322
04:24:26,819 --> 04:24:27,819
dot h so I can do that so for standard C
6323
04:24:30,660 --> 04:24:31,660
plus plus libraries you would not use
6324
04:24:33,660 --> 04:24:34,660
dot h for standard C1 so you'll use dot
6325
04:24:36,960 --> 04:24:37,960
h so for example if you want cmath
6326
04:24:39,600 --> 04:24:40,600
that's going to be without a dot h or it
6327
04:24:42,840 --> 04:24:43,840
could do maths.h this is the cmat
6328
04:24:46,080 --> 04:24:47,080
library
6329
04:24:47,520 --> 04:24:48,520
so stuff like this for now we'll include
6330
04:24:50,040 --> 04:24:51,040
adder so whoops
6331
04:24:53,460 --> 04:24:54,460
so header dot h
6332
04:24:57,420 --> 04:24:58,420
now this should work and later on I will
6333
04:25:00,600 --> 04:25:01,600
be showing you guys how to include
6334
04:25:01,859 --> 04:25:02,859
unreal headers that's not an issue so
6335
04:25:04,800 --> 04:25:05,800
this main function I just like to go
6336
04:25:06,720 --> 04:25:07,720
over basically our program is going to
6337
04:25:08,520 --> 04:25:09,520
start from here but again as I told you
6338
04:25:11,279 --> 04:25:12,279
guys when you're developing a game in
6339
04:25:13,140 --> 04:25:14,140
unreal you'd really not worry about the
6340
04:25:15,120 --> 04:25:16,120
main function that is handled in the
6341
04:25:17,520 --> 04:25:18,520
engine so if you actually go through the
6342
04:25:19,620 --> 04:25:20,620
engine Source you will find somewhere
6343
04:25:21,540 --> 04:25:22,540
where you have int Main and there is
6344
04:25:24,359 --> 04:25:25,359
there will be a wild rope while loop
6345
04:25:26,220 --> 04:25:27,220
which actually runs the game so we'll
6346
04:25:28,620 --> 04:25:29,620
not talk about that so let's write some
6347
04:25:30,840 --> 04:25:31,840
code so first of all creating variables
6348
04:25:33,800 --> 04:25:34,800
and before we do that one thing to note
6349
04:25:36,420 --> 04:25:37,420
is that these are just text files
6350
04:25:38,840 --> 04:25:39,840
honestly you can put the same code in a
6351
04:25:41,399 --> 04:25:42,399
header and a c plus file
6352
04:25:43,560 --> 04:25:44,560
it it really doesn't matter by putting
6353
04:25:46,500 --> 04:25:47,500
dot hatch you just indicate that you
6354
04:25:48,540 --> 04:25:49,540
want to include it as a header so that's
6355
04:25:50,880 --> 04:25:51,880
the only reason both of these are
6356
04:25:53,159 --> 04:25:54,159
technically just text files and can be
6357
04:25:54,960 --> 04:25:55,960
opened with any text editor such as
6358
04:25:57,000 --> 04:25:58,000
notepad notepad plus plus Visual Studio
6359
04:25:59,279 --> 04:26:00,279
or Visual Studio code honestly doesn't
6360
04:26:01,920 --> 04:26:02,920
matter
6361
04:26:03,180 --> 04:26:04,180
so if you want to create a variable
6362
04:26:05,760 --> 04:26:06,760
you can first of all head into CPP
6363
04:26:08,760 --> 04:26:09,760
reference to know the basic types
6364
04:26:11,359 --> 04:26:12,359
but if you want to create an integer for
6365
04:26:14,159 --> 04:26:15,159
example you type in int space your
6366
04:26:17,100 --> 04:26:18,100
variable name so for example we'll have
6367
04:26:19,620 --> 04:26:20,620
my integer
6368
04:26:21,420 --> 04:26:22,420
and if you type in equals you can assign
6369
04:26:24,060 --> 04:26:25,060
any initial value to it
6370
04:26:26,340 --> 04:26:27,340
you actually don't need to do that you
6371
04:26:28,380 --> 04:26:29,380
can do this a bit later as well
6372
04:26:30,420 --> 04:26:31,420
but you have to do it inside of a
6373
04:26:32,640 --> 04:26:33,640
function or something so if I just put
6374
04:26:35,060 --> 04:26:36,060
my integer equals 12
6375
04:26:38,939 --> 04:26:39,939
and make sure you end everything with a
6376
04:26:40,979 --> 04:26:41,979
semicolon this is not going to work
6377
04:26:42,420 --> 04:26:43,420
because
6378
04:26:43,500 --> 04:26:44,500
even though you have this line here you
6379
04:26:45,720 --> 04:26:46,720
are not executing this at all
6380
04:26:48,300 --> 04:26:49,300
so remember I told you guys uh the
6381
04:26:51,120 --> 04:26:52,120
program starts from the main function
6382
04:26:53,819 --> 04:26:54,819
so over here if I put my integer equals
6383
04:26:56,340 --> 04:26:57,340
12 this is going to work
6384
04:26:58,500 --> 04:26:59,500
why this works is because we have
6385
04:27:00,180 --> 04:27:01,180
included header.net so it's as if it
6386
04:27:02,340 --> 04:27:03,340
just copied over all of this content and
6387
04:27:04,859 --> 04:27:05,859
pasted it in instead of this hash
6388
04:27:06,540 --> 04:27:07,540
include
6389
04:27:08,040 --> 04:27:09,040
now similarly you can have other types
6390
04:27:10,260 --> 04:27:11,260
which we discussed so you can upload
6391
04:27:12,779 --> 04:27:13,779
float X for example
6392
04:27:15,359 --> 04:27:16,359
and you can have many other types so for
6393
04:27:19,260 --> 04:27:20,260
example if you wanted a string you would
6394
04:27:21,300 --> 04:27:22,300
put in STD
6395
04:27:22,979 --> 04:27:23,979
string in unreal you use F string but
6396
04:27:26,699 --> 04:27:27,699
again now we are getting an error that's
6397
04:27:29,220 --> 04:27:30,220
simply because you have to include
6398
04:27:30,600 --> 04:27:31,600
string so these are the few additional
6399
04:27:32,880 --> 04:27:33,880
complexities which come with C plus plus
6400
04:27:34,880 --> 04:27:35,880
so STD string my string equals let's say
6401
04:27:41,279 --> 04:27:42,279
test string
6402
04:27:44,640 --> 04:27:45,640
and you can go ahead and set the value
6403
04:27:47,640 --> 04:27:48,640
again
6404
04:27:48,720 --> 04:27:49,720
test string
6405
04:27:51,359 --> 04:27:52,359
so not sure what we call that so okay my
6406
04:27:54,060 --> 04:27:55,060
string is what we called it
6407
04:27:56,100 --> 04:27:57,100
so my string
6408
04:28:00,479 --> 04:28:01,479
equals and you can assign any value to
6409
04:28:03,359 --> 04:28:04,359
it or you could even use the Constructor
6410
04:28:05,279 --> 04:28:06,279
for this
6411
04:28:06,720 --> 04:28:07,720
anyways this is how you create variables
6412
04:28:09,120 --> 04:28:10,120
like this
6413
04:28:10,800 --> 04:28:11,800
data type variable name equals value
6414
04:28:14,520 --> 04:28:15,520
need not be defined
6415
04:28:17,899 --> 04:28:18,899
initialized as soon as you create the
6416
04:28:19,859 --> 04:28:20,859
variable you can do it later as well but
6417
04:28:22,319 --> 04:28:23,319
it's always a good practice to do it
6418
04:28:24,840 --> 04:28:25,840
now one more thing is that these
6419
04:28:30,180 --> 04:28:31,180
variables can be printed out which you
6420
04:28:32,939 --> 04:28:33,939
will not use in unreal you'll use the
6421
04:28:34,800 --> 04:28:35,800
print string function to print it on the
6422
04:28:36,600 --> 04:28:37,600
viewport but in in a console application
6423
04:28:39,659 --> 04:28:40,659
you do something like STD C out
6424
04:28:44,159 --> 04:28:45,159
and you would go ahead and print my
6425
04:28:46,739 --> 04:28:47,739
string for example
6426
04:28:49,380 --> 04:28:50,380
again we're not using this in unreal so
6427
04:28:52,140 --> 04:28:53,140
that's the reason I'm not really
6428
04:28:53,279 --> 04:28:54,279
covering this
6429
04:28:54,540 --> 04:28:55,540
so the error is because we haven't
6430
04:28:56,340 --> 04:28:57,340
included the header which contains this
6431
04:28:58,439 --> 04:28:59,439
function
6432
04:28:59,460 --> 04:29:00,460
so you can go ahead and include IO
6433
04:29:02,220 --> 04:29:03,220
stream
6434
04:29:03,659 --> 04:29:04,659
and if you go ahead and run a debugger
6435
04:29:06,120 --> 04:29:07,120
here as you see we get 232 printed
6436
04:29:09,120 --> 04:29:10,120
because that was our string again if we
6437
04:29:11,939 --> 04:29:12,939
just delete this part
6438
04:29:13,739 --> 04:29:14,739
you would see we will get test string
6439
04:29:16,979 --> 04:29:17,979
and we can also print my integer
6440
04:29:22,560 --> 04:29:23,560
like this
6441
04:29:24,060 --> 04:29:25,060
so we get 12
6442
04:29:26,040 --> 04:29:27,040
so this is how we would go about
6443
04:29:27,540 --> 04:29:28,540
printing stuff
6444
04:29:29,100 --> 04:29:30,100
and what if you wanted to write your own
6445
04:29:31,620 --> 04:29:32,620
function so what if you have like 10
6446
04:29:33,359 --> 04:29:34,359
lines of code and you wanted it to
6447
04:29:36,000 --> 04:29:37,000
be in be called once so basically you
6448
04:29:40,140 --> 04:29:41,140
can create a function with this syntax
6449
04:29:44,220 --> 04:29:45,220
so if you want to create a function what
6450
04:29:46,620 --> 04:29:47,620
you do is you put the return type let's
6451
04:29:48,720 --> 04:29:49,720
say we create an addition function so
6452
04:29:50,880 --> 04:29:51,880
our result is going to be an integer so
6453
04:29:53,760 --> 04:29:54,760
the return type is in
6454
04:29:56,640 --> 04:29:57,640
space your function name so in our case
6455
04:29:59,399 --> 04:30:00,399
let's just descriptively name it add
6456
04:30:01,739 --> 04:30:02,739
and in the bracket you would put the Val
6457
04:30:05,100 --> 04:30:06,100
put the variables which
6458
04:30:08,040 --> 04:30:09,040
you know it should take from outside so
6459
04:30:11,220 --> 04:30:12,220
in order to add two numbers we will need
6460
04:30:13,680 --> 04:30:14,680
two numbers first of all
6461
04:30:15,479 --> 04:30:16,479
so we are going to pass two integers so
6462
04:30:18,120 --> 04:30:19,120
the same way in which you created a
6463
04:30:19,920 --> 04:30:20,920
variable and in the same way in which
6464
04:30:22,319 --> 04:30:23,319
you know you would handle anything else
6465
04:30:24,180 --> 04:30:25,180
you just to enter a comma into B so you
6466
04:30:27,960 --> 04:30:28,960
separate arguments through a comma
6467
04:30:30,659 --> 04:30:31,659
so what this basically means is when I
6468
04:30:33,239 --> 04:30:34,239
call add so when I say add
6469
04:30:35,760 --> 04:30:36,760
and I put my parentheses so this is how
6470
04:30:38,220 --> 04:30:39,220
you call a function so if you want to
6471
04:30:40,020 --> 04:30:41,020
execute add this is how you do it and
6472
04:30:42,060 --> 04:30:43,060
you'll end it with the semicolon
6473
04:30:43,920 --> 04:30:44,920
now inside the bracket you would put the
6474
04:30:45,960 --> 04:30:46,960
values of A and B so in my case if I
6475
04:30:48,600 --> 04:30:49,600
just put in 12 and 43 and I'll just take
6476
04:30:52,380 --> 04:30:53,380
some some random numbers
6477
04:30:55,260 --> 04:30:56,260
now the result of this
6478
04:30:57,359 --> 04:30:58,359
is going to be returned here
6479
04:30:59,580 --> 04:31:00,580
and in fact instead of you can set it
6480
04:31:03,479 --> 04:31:04,479
inside the variable so if I do my
6481
04:31:06,000 --> 04:31:07,000
integer equals add of 1342 comma 43 so
6482
04:31:10,680 --> 04:31:11,680
whatever value will be returned here
6483
04:31:12,359 --> 04:31:13,359
that will be set inside my integer now
6484
04:31:15,960 --> 04:31:16,960
if you want to actually write the logic
6485
04:31:17,520 --> 04:31:18,520
for this so it's simply to return a plus
6486
04:31:19,620 --> 04:31:20,620
b
6487
04:31:21,720 --> 04:31:22,720
something like this so this is how you
6488
04:31:24,239 --> 04:31:25,239
do a function but honestly you don't
6489
04:31:26,760 --> 04:31:27,760
need the syntax since we'll we like we
6490
04:31:30,300 --> 04:31:31,300
actually have a simpler way to actually
6491
04:31:32,100 --> 04:31:33,100
write functions we'll be using classes
6492
04:31:34,739 --> 04:31:35,739
mostly so you shouldn't really bother
6493
04:31:37,080 --> 04:31:38,080
too much about all this
6494
04:31:40,560 --> 04:31:41,560
and with that being said let me just
6495
04:31:43,439 --> 04:31:44,439
show you guys how to create a class so
6496
04:31:45,180 --> 04:31:46,180
I'll do it in my header so for example
6497
04:31:47,819 --> 04:31:48,819
I'll just do a class called student
6498
04:31:51,359 --> 04:31:52,359
and I'll open up my curly braces
6499
04:31:54,600 --> 04:31:55,600
just follow along with the syntax it's
6500
04:31:56,640 --> 04:31:57,640
just a matter of getting used to it
6501
04:31:59,100 --> 04:32:00,100
so under private so these were the
6502
04:32:02,520 --> 04:32:03,520
private variables which we talked about
6503
04:32:04,020 --> 04:32:05,020
in Blueprint as well
6504
04:32:05,699 --> 04:32:06,699
so I can say we have a name
6505
04:32:11,760 --> 04:32:12,760
and let's say we have his Mark so and
6506
04:32:14,760 --> 04:32:15,760
marks something simple like that
6507
04:32:17,340 --> 04:32:18,340
and under the public section we can have
6508
04:32:19,739 --> 04:32:20,739
some methods
6509
04:32:21,180 --> 04:32:22,180
so we can say STD string
6510
04:32:26,939 --> 04:32:27,939
oops
6511
04:32:29,340 --> 04:32:30,340
and we can call this one get name
6512
04:32:32,399 --> 04:32:33,399
and instead of writing the definition
6513
04:32:34,859 --> 04:32:35,859
over here like this so this is similar
6514
04:32:37,800 --> 04:32:38,800
to what we did here it's just that it is
6515
04:32:39,960 --> 04:32:40,960
inside the class now
6516
04:32:41,760 --> 04:32:42,760
what we can do is we can only have the
6517
04:32:44,340 --> 04:32:45,340
Declaration here like this so only the
6518
04:32:47,159 --> 04:32:48,159
name is given here
6519
04:32:48,600 --> 04:32:49,600
but we can actually have a defined
6520
04:32:51,300 --> 04:32:52,300
outside this class itself
6521
04:32:53,399 --> 04:32:54,399
so I can do this and I can go ahead and
6522
04:32:56,460 --> 04:32:57,460
actually make another function so I can
6523
04:32:59,520 --> 04:33:00,520
say in get marks
6524
04:33:06,180 --> 04:33:07,180
so now you can also go ahead and Define
6525
04:33:09,061 --> 04:33:10,061
this outside the class
6526
04:33:11,219 --> 04:33:12,219
how you do that is
6527
04:33:13,561 --> 04:33:14,561
you would use this syntax
6528
04:33:15,660 --> 04:33:16,660
I'm not talking in depth about this
6529
04:33:18,119 --> 04:33:19,119
mostly because there's a shortcut to do
6530
04:33:20,459 --> 04:33:21,459
it which I will talk about
6531
04:33:22,740 --> 04:33:23,740
so s3d string and what what was a class
6532
04:33:25,619 --> 04:33:26,619
called
6533
04:33:26,879 --> 04:33:27,879
student
6534
04:33:28,379 --> 04:33:29,379
followed by two colons you do get name
6535
04:33:32,520 --> 04:33:33,520
and you can write your function
6536
04:33:33,959 --> 04:33:34,959
definition over here
6537
04:33:35,699 --> 04:33:36,699
so you can go ahead and return
6538
04:33:39,660 --> 04:33:40,660
I guess it was called name so name
6539
04:33:42,959 --> 04:33:43,959
and similarly you can provide a
6540
04:33:44,400 --> 04:33:45,400
definition for the marks as well so int
6541
04:33:48,359 --> 04:33:49,359
student
6542
04:33:50,100 --> 04:33:51,100
get marks and you can go ahead and write
6543
04:33:52,920 --> 04:33:53,920
the definition for it return
6544
04:33:55,680 --> 04:33:56,680
locks so basically you are going to get
6545
04:33:58,799 --> 04:33:59,799
the marks from this now if you want to
6546
04:34:01,859 --> 04:34:02,859
instantiate a student so let's say you
6547
04:34:03,840 --> 04:34:04,840
wanted to create a student object from
6548
04:34:05,820 --> 04:34:06,820
this remember we talked about classes
6549
04:34:07,920 --> 04:34:08,920
and objects so you just to student let's
6550
04:34:11,580 --> 04:34:12,580
just call him S1 for example
6551
04:34:14,641 --> 04:34:15,641
and you can do S1 dot get name
6552
04:34:19,740 --> 04:34:20,740
now dot is what you'd use to
6553
04:34:22,141 --> 04:34:23,141
refer to the members inside a class
6554
04:34:25,920 --> 04:34:26,920
in unreal though when you create objects
6555
04:34:28,619 --> 04:34:29,619
you generally have a pointer to it
6556
04:34:31,980 --> 04:34:32,980
so basically the memory address of it is
6557
04:34:34,619 --> 04:34:35,619
a pointer nothing much to worry really
6558
04:34:37,279 --> 04:34:38,279
so I'll just show you guys a way to
6559
04:34:40,561 --> 04:34:41,561
create it
6560
04:34:43,020 --> 04:34:44,020
so if I type in student pointer instead
6561
04:34:46,680 --> 04:34:47,680
equals
6562
04:34:48,359 --> 04:34:49,359
new S1 basically we are Dynamic new
6563
04:34:52,799 --> 04:34:53,799
student
6564
04:34:54,240 --> 04:34:55,240
so new student
6565
04:34:56,160 --> 04:34:57,160
basically we are dynamically creating
6566
04:34:58,439 --> 04:34:59,439
this and instead of the actual variable
6567
04:35:02,580 --> 04:35:03,580
name we have a pointer to it pretty much
6568
04:35:05,641 --> 04:35:06,641
now nothing much to worry about you just
6569
04:35:08,219 --> 04:35:09,219
put a star instead of just referring to
6570
04:35:11,520 --> 04:35:12,520
student
6571
04:35:12,840 --> 04:35:13,840
and if you want to refer to something
6572
04:35:15,119 --> 04:35:16,119
through a pointer you do S1 instead of
6573
04:35:18,539 --> 04:35:19,539
putting a DOT
6574
04:35:19,859 --> 04:35:20,859
now if you were to do dot you see it
6575
04:35:22,320 --> 04:35:23,320
just got replaced with an arrow so you'd
6576
04:35:24,660 --> 04:35:25,660
refer it with an arrow so something like
6577
04:35:27,359 --> 04:35:28,359
this so if we actually just create a
6578
04:35:30,299 --> 04:35:31,299
method to set the marks
6579
04:35:32,219 --> 04:35:33,219
so I'll just do void set marks and it's
6580
04:35:36,900 --> 04:35:37,900
going to be in the parameter which we
6581
04:35:39,119 --> 04:35:40,119
need so end marks so we'll take this
6582
04:35:41,699 --> 04:35:42,699
value from outside
6583
04:35:43,500 --> 04:35:44,500
and we can say
6584
04:35:45,779 --> 04:35:46,779
marks
6585
04:35:48,240 --> 04:35:49,240
okay we are using this again so we can
6586
04:35:51,000 --> 04:35:52,000
type in marks with a lowercase so marks
6587
04:35:54,119 --> 04:35:55,119
equals marks
6588
04:35:59,039 --> 04:36:00,039
so what we can do is we can say S1 dot
6589
04:36:02,219 --> 04:36:03,219
set marks or rather with the arrow set
6590
04:36:04,859 --> 04:36:05,859
marks and we can just say 56 for example
6591
04:36:08,039 --> 04:36:09,039
just a random number
6592
04:36:09,719 --> 04:36:10,719
and we can print it by typing in stdc
6593
04:36:13,260 --> 04:36:14,260
out
6594
04:36:14,400 --> 04:36:15,400
and we can print this so run a debugger
6595
04:36:17,760 --> 04:36:18,760
and as you can see we got 56 printed so
6596
04:36:20,340 --> 04:36:21,340
we successfully set the marks
6597
04:36:22,859 --> 04:36:23,859
so this is how we would call functions
6598
04:36:25,039 --> 04:36:26,039
which are defined inside a class and you
6599
04:36:28,920 --> 04:36:29,920
will need to call them through an object
6600
04:36:30,539 --> 04:36:31,539
because you need to instantiate them
6601
04:36:32,279 --> 04:36:33,279
first of all this is something which you
6602
04:36:34,379 --> 04:36:35,379
will not do in unreal you would use the
6603
04:36:36,299 --> 04:36:37,299
function such as spawn actor and stuff
6604
04:36:38,279 --> 04:36:39,279
in order to actually create objects but
6605
04:36:41,641 --> 04:36:42,641
anyways this was just something I showed
6606
04:36:43,439 --> 04:36:44,439
you guys now with this much you can
6607
04:36:45,900 --> 04:36:46,900
pretty much do it if there's anything
6608
04:36:47,520 --> 04:36:48,520
else such as for loops and stuff you can
6609
04:36:50,219 --> 04:36:51,219
just follow along and look at the syntax
6610
04:36:53,279 --> 04:36:54,279
that's pretty much it and if statements
6611
04:36:56,340 --> 04:36:57,340
are also easy so you just do if and you
6612
04:36:58,859 --> 04:36:59,859
would have the condition in the bracket
6613
04:37:00,480 --> 04:37:01,480
so let's say
6614
04:37:02,100 --> 04:37:03,100
the marks is greater than 56 so I can do
6615
04:37:05,879 --> 04:37:06,879
S1 get marks
6616
04:37:07,799 --> 04:37:08,799
S1 get marks greater than let's say 35
6617
04:37:11,119 --> 04:37:12,119
then we can go ahead and print that the
6618
04:37:13,680 --> 04:37:14,680
student has passed so stdc out
6619
04:37:17,400 --> 04:37:18,400
and I can say past
6620
04:37:21,180 --> 04:37:22,180
so if I do this as you would see we get
6621
04:37:24,119 --> 04:37:25,119
56 and passed obviously this is not in a
6622
04:37:27,420 --> 04:37:28,420
new line but that's pretty easy to do so
6623
04:37:29,879 --> 04:37:30,879
you can do STD ndl
6624
04:37:33,779 --> 04:37:34,779
and now you'd see 56 passed
6625
04:37:37,320 --> 04:37:38,320
so with this much basic C plus plus you
6626
04:37:40,320 --> 04:37:41,320
can actually follow along but again I do
6627
04:37:43,141 --> 04:37:44,141
recommend you separately learn a bit of
6628
04:37:45,240 --> 04:37:46,240
C plus plus before you come in
6629
04:37:47,879 --> 04:37:48,879
the upcoming sections of this course is
6630
04:37:50,820 --> 04:37:51,820
going to be for intermediate and
6631
04:37:52,859 --> 04:37:53,859
advanced users so before you actually
6632
04:37:55,740 --> 04:37:56,740
get started I recommend you guys do a
6633
04:37:57,959 --> 04:37:58,959
few things first of all spend maybe a
6634
04:38:00,420 --> 04:38:01,420
few days actually exploring the engine a
6635
04:38:03,420 --> 04:38:04,420
little bit more may be creating a tiny
6636
04:38:05,400 --> 04:38:06,400
game or something
6637
04:38:06,600 --> 04:38:07,600
and secondly make sure you do know the
6638
04:38:09,240 --> 04:38:10,240
basics of object oriented programming in
6639
04:38:11,939 --> 04:38:12,939
c plus plus so stuff like your classes
6640
04:38:15,619 --> 04:38:16,619
and you know uh stuff like structs
6641
04:38:19,820 --> 04:38:20,820
functions and variables and the the
6642
04:38:23,459 --> 04:38:24,459
basic stuff basically if you guys are
6643
04:38:26,820 --> 04:38:27,820
familiar with that much of C plus plus
6644
04:38:28,619 --> 04:38:29,619
and you have used the engine a little
6645
04:38:31,199 --> 04:38:32,199
bit you would be able to follow along
6646
04:38:33,240 --> 04:38:34,240
with the further part of the course
6647
04:38:36,770 --> 04:38:37,770
[Music]
6648
04:38:41,760 --> 04:38:42,760
so in order to start coding in C plus
6649
04:38:44,580 --> 04:38:45,580
plus for unreal head into tools and open
6650
04:38:47,459 --> 04:38:48,459
your Visual Studio project by clicking
6651
04:38:50,039 --> 04:38:51,039
on that button over there
6652
04:38:52,520 --> 04:38:53,520
and you should be in some sort of a file
6653
04:38:56,820 --> 04:38:57,820
over here now you may have something
6654
04:38:59,279 --> 04:39:00,279
blank so we'll just close that
6655
04:39:01,799 --> 04:39:02,799
now under your games folder you should
6656
04:39:04,680 --> 04:39:05,680
see your project name here and this is
6657
04:39:07,619 --> 04:39:08,619
where you actually start working with
6658
04:39:09,719 --> 04:39:10,719
stuff now we don't have anything
6659
04:39:11,939 --> 04:39:12,939
actually under this we are going to be
6660
04:39:14,520 --> 04:39:15,520
having our source files
6661
04:39:16,439 --> 04:39:17,439
so you don't actually create it here in
6662
04:39:19,141 --> 04:39:20,141
unreal in unreal you actually have the
6663
04:39:22,619 --> 04:39:23,619
option to just generate all the
6664
04:39:25,379 --> 04:39:26,379
boilerplate code for you
6665
04:39:27,480 --> 04:39:28,480
you can do that by heading into tools
6666
04:39:30,299 --> 04:39:31,299
and by typing in new C plus plus class
6667
04:39:33,660 --> 04:39:34,660
now over here
6668
04:39:35,340 --> 04:39:36,340
you get various options now if you have
6669
04:39:38,458 --> 04:39:39,458
something really simple if you have some
6670
04:39:40,260 --> 04:39:41,260
pure C plus plus logic you could just
6671
04:39:42,298 --> 04:39:43,298
create an empty class and you could just
6672
04:39:44,458 --> 04:39:45,458
sticker around it's just going to create
6673
04:39:46,620 --> 04:39:47,620
a Constructor Destructor and it's going
6674
04:39:48,958 --> 04:39:49,958
to write the class definition for you
6675
04:39:50,940 --> 04:39:51,940
along with no macros just the standard C
6676
04:39:54,420 --> 04:39:55,420
plus plus one but the most basic useful
6677
04:39:57,480 --> 04:39:58,480
thing that you'll use in unreal is going
6678
04:39:59,700 --> 04:40:00,700
to be your object so under all classes
6679
04:40:02,878 --> 04:40:03,878
if you select object this is going to be
6680
04:40:06,180 --> 04:40:07,180
equivalent to your object in blueprints
6681
04:40:08,340 --> 04:40:09,340
however when you actually create it so
6682
04:40:10,620 --> 04:40:11,620
if I just create it uh just select
6683
04:40:13,500 --> 04:40:14,500
public and this is just to determine
6684
04:40:16,980 --> 04:40:17,980
where your CPP file will be whether it
6685
04:40:19,020 --> 04:40:20,020
will be in the public folder or the
6686
04:40:20,520 --> 04:40:21,520
private folder now over here we can just
6687
04:40:23,820 --> 04:40:24,820
call this CPP object
6688
04:40:28,378 --> 04:40:29,378
so let's not confuse ourselves let's
6689
04:40:30,600 --> 04:40:31,600
just call it CPP underscore yeah object
6690
04:40:34,320 --> 04:40:35,320
is fine so this is not an object this is
6691
04:40:37,860 --> 04:40:38,860
the class which is named CPP object
6692
04:40:41,040 --> 04:40:42,040
please don't get confused with that so
6693
04:40:43,680 --> 04:40:44,680
create a class
6694
04:40:45,240 --> 04:40:46,240
and now as you can see you have some
6695
04:40:47,100 --> 04:40:48,100
really basic code and one thing you
6696
04:40:49,798 --> 04:40:50,798
might not have noticed is okay live
6697
04:40:52,320 --> 04:40:53,320
coding is on that's a different story
6698
04:40:54,500 --> 04:40:55,500
but what you might notice is it already
6699
04:40:57,900 --> 04:40:58,900
has several things such as it has
6700
04:41:00,718 --> 04:41:01,718
included some header files here
6701
04:41:02,820 --> 04:41:03,820
these are just unreal standard header
6702
04:41:05,820 --> 04:41:06,820
files and you will need them
6703
04:41:09,000 --> 04:41:10,000
and you might have seen a few extra
6704
04:41:10,980 --> 04:41:11,980
macros as well so this is a u-class
6705
04:41:14,160 --> 04:41:15,160
macro
6706
04:41:15,180 --> 04:41:16,180
and inside these these actually taken
6707
04:41:17,520 --> 04:41:18,520
arguments too now these are useful for
6708
04:41:20,760 --> 04:41:21,760
the unreal header tool basically when
6709
04:41:23,040 --> 04:41:24,040
you compile this it happens in two
6710
04:41:25,560 --> 04:41:26,560
phases basically your unreal header tool
6711
04:41:28,260 --> 04:41:29,260
sets up stuff which are specific to your
6712
04:41:32,100 --> 04:41:33,100
objects for unreal called your objects
6713
04:41:35,700 --> 04:41:36,700
and in order to implement those features
6714
04:41:38,100 --> 04:41:39,100
it does certain extra steps
6715
04:41:40,860 --> 04:41:41,860
so when you get a compiler error it
6716
04:41:43,260 --> 04:41:44,260
could be either from that or from your
6717
04:41:45,180 --> 04:41:46,180
standard C plus compiler anyways that
6718
04:41:47,820 --> 04:41:48,820
shouldn't be much of a problem to you
6719
04:41:50,760 --> 04:41:51,760
guys
6720
04:41:52,260 --> 04:41:53,260
now if you might have noticed
6721
04:41:54,840 --> 04:41:55,840
even though we called it CPP object it's
6722
04:41:57,240 --> 04:41:58,240
prefixed with a u and we have inherited
6723
04:42:00,958 --> 04:42:01,958
it from U object
6724
04:42:03,138 --> 04:42:04,138
now why is it like this now basically
6725
04:42:06,958 --> 04:42:07,958
any object that you create that is a
6726
04:42:10,440 --> 04:42:11,440
derived class of your object must have
6727
04:42:12,120 --> 04:42:13,120
the prefix U and even object has the
6728
04:42:14,340 --> 04:42:15,340
prefix u in Blueprint it is just shown
6729
04:42:17,940 --> 04:42:18,940
as object however in theory it is
6730
04:42:22,080 --> 04:42:23,080
actually U object
6731
04:42:24,360 --> 04:42:25,360
and similarly for actors so let's
6732
04:42:27,060 --> 04:42:28,060
actually create an actor as well so we
6733
04:42:29,280 --> 04:42:30,280
can head back into the editor tools new
6734
04:42:32,100 --> 04:42:33,100
C plus plus class and as you can see you
6735
04:42:34,440 --> 04:42:35,440
see pretty much the same stuff over here
6736
04:42:36,600 --> 04:42:37,600
but these are the two important ones
6737
04:42:38,760 --> 04:42:39,760
object and actor now obviously character
6738
04:42:40,980 --> 04:42:41,980
pawn and stuff like that are important
6739
04:42:42,900 --> 04:42:43,900
but they don't have any specific
6740
04:42:44,458 --> 04:42:45,458
prefixes so I I'll be talking about them
6741
04:42:47,638 --> 04:42:48,638
a bit later and obviously we'll talk in
6742
04:42:49,980 --> 04:42:50,980
depth about the inheritance hierarchy so
6743
04:42:51,840 --> 04:42:52,840
I'll select actor
6744
04:42:53,580 --> 04:42:54,580
and let's call this one CPP underscore
6745
04:42:56,340 --> 04:42:57,340
actor
6746
04:42:57,840 --> 04:42:58,840
create that
6747
04:43:00,000 --> 04:43:01,000
and live coding if it works properly it
6748
04:43:03,420 --> 04:43:04,420
should in theory compile it for us
6749
04:43:06,920 --> 04:43:07,920
now if we actually open it up and reload
6750
04:43:11,040 --> 04:43:12,040
this
6751
04:43:12,000 --> 04:43:13,000
you would see
6752
04:43:13,798 --> 04:43:14,798
you find something which looks a little
6753
04:43:15,780 --> 04:43:16,780
bit overwhelming if you're looking at it
6754
04:43:17,638 --> 04:43:18,638
from the first time but if you ignore
6755
04:43:19,740 --> 04:43:20,740
this macro and if you ignore this
6756
04:43:22,200 --> 04:43:23,200
comment here I don't even know why this
6757
04:43:24,560 --> 04:43:25,560
comment exists because if you have come
6758
04:43:27,840 --> 04:43:28,840
to an extent where you can write or
6759
04:43:30,360 --> 04:43:31,360
interpret this code I don't think you
6760
04:43:32,700 --> 04:43:33,700
need to know that a Constructor sets the
6761
04:43:35,160 --> 04:43:36,160
default value so we'll just delete that
6762
04:43:36,958 --> 04:43:37,958
comment
6763
04:43:38,040 --> 04:43:39,040
and begin Place basically our event
6764
04:43:40,740 --> 04:43:41,740
begin playing blueprint same thing
6765
04:43:43,500 --> 04:43:44,500
uh tick is again your tick and blueprint
6766
04:43:46,740 --> 04:43:47,740
you can delete the comment now this code
6767
04:43:49,020 --> 04:43:50,020
looks a lot more cleaner now this is a
6768
04:43:51,180 --> 04:43:52,180
virtual function and if you were to
6769
04:43:53,340 --> 04:43:54,340
notice it's not called CPP actor it's
6770
04:43:55,980 --> 04:43:56,980
called ACP actor basically every actor
6771
04:43:59,458 --> 04:44:00,458
is prefixed with an A and the actor
6772
04:44:01,740 --> 04:44:02,740
class itself as well
6773
04:44:03,850 --> 04:44:04,850
[Music]
6774
04:44:09,360 --> 04:44:10,360
all right now that we have established a
6775
04:44:11,878 --> 04:44:12,878
basic understanding on creating a
6776
04:44:14,400 --> 04:44:15,400
blueprint equivalent actors and objects
6777
04:44:16,560 --> 04:44:17,560
let's look at the inheritance hierarchy
6778
04:44:19,740 --> 04:44:20,740
in unreal in a little more detail now
6779
04:44:22,260 --> 04:44:23,260
I'm not covering everything over here
6780
04:44:24,360 --> 04:44:25,360
now I have left a few things such as
6781
04:44:26,700 --> 04:44:27,700
interfaces and I'm not going into each
6782
04:44:29,218 --> 04:44:30,218
class I'm just talking about the ones
6783
04:44:31,740 --> 04:44:32,740
that you'll use in almost every project
6784
04:44:33,660 --> 04:44:34,660
so that should cover things for you if
6785
04:44:36,000 --> 04:44:37,000
you need anything in specific the
6786
04:44:37,560 --> 04:44:38,560
documentation should help you if you
6787
04:44:40,020 --> 04:44:41,020
understand this much so at the base
6788
04:44:42,180 --> 04:44:43,180
level you have your object of course you
6789
04:44:44,400 --> 04:44:45,400
have your typical basic C plus plus
6790
04:44:48,060 --> 04:44:49,060
class but we are not getting into that
6791
04:44:50,878 --> 04:44:51,878
now under that I can categorize a these
6792
04:44:55,620 --> 04:44:56,620
into three main other classes which
6793
04:44:57,958 --> 04:44:58,958
you'll use now there are many others but
6794
04:45:00,000 --> 04:45:01,000
you won't really use them the first one
6795
04:45:02,760 --> 04:45:03,760
and which you probably expected is a
6796
04:45:05,340 --> 04:45:06,340
actor now an actor
6797
04:45:08,280 --> 04:45:09,280
or a actor as it's called in C plus plus
6798
04:45:10,620 --> 04:45:11,620
is something which can be placed in the
6799
04:45:13,320 --> 04:45:14,320
scene so if you want to place something
6800
04:45:15,540 --> 04:45:16,540
in the scene and write the code in C
6801
04:45:17,638 --> 04:45:18,638
plus plus you would create an a actor or
6802
04:45:20,820 --> 04:45:21,820
in the menu or in the unreal editor it's
6803
04:45:24,420 --> 04:45:25,420
referred to as actor everywhere
6804
04:45:26,940 --> 04:45:27,940
now similar to pawn you have a pawn
6805
04:45:29,520 --> 04:45:30,520
which is basically something which can
6806
04:45:32,040 --> 04:45:33,040
be possessed by a controller so
6807
04:45:34,378 --> 04:45:35,378
basically you can control it and it need
6808
04:45:36,660 --> 04:45:37,660
not be you it could be an AI as well so
6809
04:45:39,840 --> 04:45:40,840
maybe you could write some code for Bots
6810
04:45:42,240 --> 04:45:43,240
or something so you would use spawn in
6811
04:45:45,240 --> 04:45:46,240
that case
6812
04:45:46,260 --> 04:45:47,260
and if you have something specific like
6813
04:45:49,320 --> 04:45:50,320
a humanoid character or something
6814
04:45:51,560 --> 04:45:52,560
generally for most of the things which
6815
04:45:54,958 --> 04:45:55,958
will be Pawn you generally use character
6816
04:45:58,378 --> 04:45:59,378
so if you need a movement component
6817
04:46:01,500 --> 04:46:02,500
and stuff like that you would use
6818
04:46:03,540 --> 04:46:04,540
character some functionality is already
6819
04:46:06,660 --> 04:46:07,660
set up in your character which is not
6820
04:46:08,760 --> 04:46:09,760
set up in Pawn so something such as
6821
04:46:11,700 --> 04:46:12,700
adding your controller pitch and your
6822
04:46:13,740 --> 04:46:14,740
input and you know many other functions
6823
04:46:17,878 --> 04:46:18,878
which we will talk about as we use them
6824
04:46:20,040 --> 04:46:21,040
so that's where you'll use character
6825
04:46:22,138 --> 04:46:23,138
this might be clear
6826
04:46:23,638 --> 04:46:24,638
now a controller is basically an actor
6827
04:46:28,020 --> 04:46:29,020
which takes an input now you cannot
6828
04:46:30,718 --> 04:46:31,718
place a controller in a level obviously
6829
04:46:32,878 --> 04:46:33,878
it sounds a bit stupid to place a
6830
04:46:34,980 --> 04:46:35,980
controller in a level but basically uh
6831
04:46:38,218 --> 04:46:39,218
each player will have his own controller
6832
04:46:40,320 --> 04:46:41,320
and to be specific he will have a player
6833
04:46:42,900 --> 04:46:43,900
controller
6834
04:46:44,160 --> 04:46:45,160
if it's an AI or something you have
6835
04:46:46,680 --> 04:46:47,680
something known as an AI controller but
6836
04:46:49,080 --> 04:46:50,080
again we are not getting into that we
6837
04:46:50,878 --> 04:46:51,878
it's really not that common to use it
6838
04:46:54,480 --> 04:46:55,480
a controller will basically take your
6839
04:46:56,940 --> 04:46:57,940
input now although you can set up your
6840
04:46:59,100 --> 04:47:00,100
input bindings in other actor blueprints
6841
04:47:02,040 --> 04:47:03,040
controller is the right one to actually
6842
04:47:04,500 --> 04:47:05,500
hard code bindings and stuff like that
6843
04:47:06,798 --> 04:47:07,798
generally when you create widgets which
6844
04:47:09,600 --> 04:47:10,600
are not associated with your character
6845
04:47:11,878 --> 04:47:12,878
you would create them inside your player
6846
04:47:13,980 --> 04:47:14,980
controller blueprint generally you
6847
04:47:15,540 --> 04:47:16,540
create a player controller you don't
6848
04:47:16,798 --> 04:47:17,798
create a controller and that's about it
6849
04:47:20,160 --> 04:47:21,160
for what you'll use for the most part
6850
04:47:22,280 --> 04:47:23,280
and if we actually head into more
6851
04:47:24,900 --> 04:47:25,900
gameplay oriented classes you have a
6852
04:47:27,718 --> 04:47:28,718
info the reason I put this is because
6853
04:47:29,638 --> 04:47:30,638
this was
6854
04:47:31,138 --> 04:47:32,138
this was just a wrapper for you know
6855
04:47:33,718 --> 04:47:34,718
these classes which you'll use you'll
6856
04:47:35,520 --> 04:47:36,520
never create an info actor so ignore
6857
04:47:38,458 --> 04:47:39,458
this this just for your reference
6858
04:47:41,340 --> 04:47:42,340
over here you'd see a game mode base as
6859
04:47:45,000 --> 04:47:46,000
the name suggests game mode base it's
6860
04:47:48,120 --> 04:47:49,120
basically your game mode so anything any
6861
04:47:51,958 --> 04:47:52,958
code logic regarding your game mode will
6862
04:47:54,360 --> 04:47:55,360
be there in this and obviously it's
6863
04:47:57,480 --> 04:47:58,480
really simple for me to just tell it
6864
04:47:59,580 --> 04:48:00,580
like this but once I take a couple of
6865
04:48:02,520 --> 04:48:03,520
examples it's going to be crystal clear
6866
04:48:04,500 --> 04:48:05,500
for you guys and there is also an a game
6867
04:48:07,440 --> 04:48:08,440
mode class which is inherited from this
6868
04:48:10,020 --> 04:48:11,020
and it has some additional functionality
6869
04:48:12,120 --> 04:48:13,120
for the most part we will stick with a
6870
04:48:14,700 --> 04:48:15,700
game mode base but again you can feel
6871
04:48:17,218 --> 04:48:18,218
free to use a game mode
6872
04:48:19,138 --> 04:48:20,138
similarly a game State base and a game
6873
04:48:22,920 --> 04:48:23,920
State now you might ask what's the
6874
04:48:25,378 --> 04:48:26,378
difference between these two the main
6875
04:48:27,180 --> 04:48:28,180
difference is that game mode exists only
6876
04:48:29,940 --> 04:48:30,940
on the server in multiplayer games
6877
04:48:32,420 --> 04:48:33,420
whereas game State exists both on the
6878
04:48:35,340 --> 04:48:36,340
server and client so things like match
6879
04:48:37,860 --> 04:48:38,860
timers which you would want all the
6880
04:48:40,320 --> 04:48:41,320
players to be able to see as well you'd
6881
04:48:42,060 --> 04:48:43,060
have them stored in the game State and
6882
04:48:44,820 --> 04:48:45,820
maybe some other variables which you
6883
04:48:47,760 --> 04:48:48,760
only want to use as a means of
6884
04:48:50,580 --> 04:48:51,580
calculating something in game so stuff
6885
04:48:52,798 --> 04:48:53,798
which will only be there on the server
6886
04:48:54,718 --> 04:48:55,718
and multiplayer games or something which
6887
04:48:56,878 --> 04:48:57,878
is core to your fundamental gameplay so
6888
04:48:58,920 --> 04:48:59,920
something like maybe you know switching
6889
04:49:01,080 --> 04:49:02,080
to another level when you enter place or
6890
04:49:03,600 --> 04:49:04,600
something I mean it depends on the game
6891
04:49:05,520 --> 04:49:06,520
honestly can't just tell what you would
6892
04:49:07,860 --> 04:49:08,860
do with it just like that but basically
6893
04:49:11,100 --> 04:49:12,100
game mode game state
6894
04:49:13,740 --> 04:49:14,740
work together hand in hand now there's
6895
04:49:16,560 --> 04:49:17,560
one more actually called the player
6896
04:49:18,780 --> 04:49:19,780
State now the player state is really
6897
04:49:22,260 --> 04:49:23,260
special because this is replica this is
6898
04:49:25,920 --> 04:49:26,920
replicated by default to all the clients
6899
04:49:28,740 --> 04:49:29,740
in multiplayer we upload in detail about
6900
04:49:31,620 --> 04:49:32,620
multiplayer later on but for now just
6901
04:49:34,798 --> 04:49:35,798
know that player state is going to be
6902
04:49:37,500 --> 04:49:38,500
kind of the class which you'll use for
6903
04:49:39,298 --> 04:49:40,298
anything that all the players must know
6904
04:49:41,580 --> 04:49:42,580
at all points of time
6905
04:49:43,340 --> 04:49:44,340
and generally you'd store info common to
6906
04:49:46,980 --> 04:49:47,980
a given player which other players need
6907
04:49:48,780 --> 04:49:49,780
to know uh stuff like your player name
6908
04:49:51,420 --> 04:49:52,420
would be there in your play State
6909
04:49:52,920 --> 04:49:53,920
because all other players need to be
6910
04:49:54,718 --> 04:49:55,718
able to access your player name at any
6911
04:49:56,458 --> 04:49:57,458
point of time so I just gave you an
6912
04:49:58,620 --> 04:49:59,620
example you could be creative with it
6913
04:50:00,958 --> 04:50:01,958
and do whatever you want
6914
04:50:03,000 --> 04:50:04,000
now one thing you might have noticed
6915
04:50:04,798 --> 04:50:05,798
over here for the last one which I'll
6916
04:50:06,958 --> 04:50:07,958
talk about under your object is are
6917
04:50:10,020 --> 04:50:11,020
actually two more uh game instances as
6918
04:50:13,138 --> 04:50:14,138
the name suggests your game's instance
6919
04:50:15,480 --> 04:50:16,480
so this is talking about your game as a
6920
04:50:18,840 --> 04:50:19,840
whole and not anything inside the game
6921
04:50:20,900 --> 04:50:21,900
so instead of begin play actually you
6922
04:50:23,940 --> 04:50:24,940
have something known as event in it here
6923
04:50:26,700 --> 04:50:27,700
so let's say you call something off of
6924
04:50:29,700 --> 04:50:30,700
event init that actually runs well
6925
04:50:32,878 --> 04:50:33,878
before your level actually loads so
6926
04:50:35,700 --> 04:50:36,700
we'll look into examples again
6927
04:50:38,760 --> 04:50:39,760
if you have anything pertaining to the
6928
04:50:41,520 --> 04:50:42,520
game which has to sustain between level
6929
04:50:44,820 --> 04:50:45,820
transitions let's say you move from your
6930
04:50:46,740 --> 04:50:47,740
main menu to your actual gameplay level
6931
04:50:49,500 --> 04:50:50,500
if you want stuff to sustain between
6932
04:50:51,540 --> 04:50:52,540
them let's say you wanted a variable to
6933
04:50:53,400 --> 04:50:54,400
sustain in that case you'd use the game
6934
04:50:55,680 --> 04:50:56,680
instance because the game instance will
6935
04:50:57,718 --> 04:50:58,718
not be destroyed between levels but when
6936
04:51:00,840 --> 04:51:01,840
you transition from one level to the
6937
04:51:02,760 --> 04:51:03,760
other all the actors and all the widgets
6938
04:51:05,700 --> 04:51:06,700
everything else that you could possibly
6939
04:51:07,260 --> 04:51:08,260
think of are going to be destroyed now
6940
04:51:10,080 --> 04:51:11,080
speaking of widgets we have multiple
6941
04:51:12,840 --> 04:51:13,840
classes here which you will probably
6942
04:51:14,400 --> 04:51:15,400
never even touch even widget to be
6943
04:51:16,200 --> 04:51:17,200
honest you will never touch in C plus
6944
04:51:17,760 --> 04:51:18,760
plus it's very rare that you re you
6945
04:51:20,218 --> 04:51:21,218
would require a C plus plus class for a
6946
04:51:22,020 --> 04:51:23,020
widget
6947
04:51:23,040 --> 04:51:24,040
so your user visit is the class which
6948
04:51:25,440 --> 04:51:26,440
you'll use of course in the editor it's
6949
04:51:27,360 --> 04:51:28,360
going to be referred to as user widget
6950
04:51:28,798 --> 04:51:29,798
so this is how you would create widgets
6951
04:51:31,260 --> 04:51:32,260
but honestly it's too much of a pain to
6952
04:51:33,480 --> 04:51:34,480
work with widgets in C plus for
6953
04:51:35,878 --> 04:51:36,878
something that's just you know very
6954
04:51:38,700 --> 04:51:39,700
simple you could just work with other
6955
04:51:40,620 --> 04:51:41,620
Blueprints and just have a blueprint
6956
04:51:42,840 --> 04:51:43,840
widget which you would interact with
6957
04:51:44,580 --> 04:51:45,580
stuff like that so that's about it
6958
04:51:47,520 --> 04:51:48,520
actually
6959
04:51:48,540 --> 04:51:49,540
now the way I'd practically use this is
6960
04:51:51,120 --> 04:51:52,120
you'd have one C plus Base Class so for
6961
04:51:54,180 --> 04:51:55,180
example we can have for a character we
6962
04:51:56,520 --> 04:51:57,520
can have one character and we can go
6963
04:51:58,260 --> 04:51:59,260
ahead and derive one so let's say we
6964
04:52:00,780 --> 04:52:01,780
call this one R character so let's say
6965
04:52:04,320 --> 04:52:05,320
it is a
6966
04:52:06,298 --> 04:52:07,298
we'll just call it CPP as a convention
6967
04:52:08,760 --> 04:52:09,760
ACP underscore our character
6968
04:52:12,000 --> 04:52:13,000
I'll just call it our care for now
6969
04:52:14,760 --> 04:52:15,760
now what you do is you would have core
6970
04:52:17,700 --> 04:52:18,700
functionality written inside this class
6971
04:52:20,218 --> 04:52:21,218
so for example your movement maybe maybe
6972
04:52:23,700 --> 04:52:24,700
if you have a first person shooter game
6973
04:52:25,500 --> 04:52:26,500
you're firing logic basically stuff that
6974
04:52:27,900 --> 04:52:28,900
is Mission critical for the game and
6975
04:52:29,760 --> 04:52:30,760
stuff which would break if they don't
6976
04:52:31,320 --> 04:52:32,320
execute so for that you write it in C
6977
04:52:33,660 --> 04:52:34,660
plus plus
6978
04:52:34,980 --> 04:52:35,980
but other cosmetic things which you
6979
04:52:37,500 --> 04:52:38,500
don't really require and it's fine if it
6980
04:52:40,920 --> 04:52:41,920
executes a bit late stuff like you know
6981
04:52:43,080 --> 04:52:44,080
uh creating widget maybe uh let's say
6982
04:52:46,920 --> 04:52:47,920
you have a Crosshair on the screen maybe
6983
04:52:48,480 --> 04:52:49,480
updating its position uh if you have a
6984
04:52:51,298 --> 04:52:52,298
dynamic Crosshair that is or maybe you
6985
04:52:53,940 --> 04:52:54,940
know stuff which is not essential like
6986
04:52:57,420 --> 04:52:58,420
effects spawning FX so if you have stuff
6987
04:53:00,480 --> 04:53:01,480
like that which is not really Mission
6988
04:53:02,580 --> 04:53:03,580
critical it's fine uh if it's a bit slow
6989
04:53:05,638 --> 04:53:06,638
and maybe if you don't have too many
6990
04:53:07,620 --> 04:53:08,620
Loops so if you have many Loops in your
6991
04:53:09,958 --> 04:53:10,958
code blueprint generally run slower I
6992
04:53:12,600 --> 04:53:13,600
will talk about why that is and stuff so
6993
04:53:15,060 --> 04:53:16,060
what you do is you'd have the core
6994
04:53:17,340 --> 04:53:18,340
functionality in your base class and
6995
04:53:19,860 --> 04:53:20,860
then uh you would create a blueprint
6996
04:53:22,200 --> 04:53:23,200
class which I'm marking in yellow and we
6997
04:53:25,138 --> 04:53:26,138
you'll call this one BP underscore r car
6998
04:53:28,378 --> 04:53:29,378
now this is just a convention I use you
6999
04:53:30,060 --> 04:53:31,060
could call it anything you could simply
7000
04:53:31,500 --> 04:53:32,500
call this one r car
7001
04:53:33,540 --> 04:53:34,540
so this is going to be our blueprint
7002
04:53:35,160 --> 04:53:36,160
class and this is what you'll spawn in
7003
04:53:36,840 --> 04:53:37,840
the level so since this is inherited
7004
04:53:39,298 --> 04:53:40,298
from this BPR car will have all the
7005
04:53:42,240 --> 04:53:43,240
properties of acpp Archer similarly you
7006
04:53:45,600 --> 04:53:46,600
do that for all the other classes and
7007
04:53:48,600 --> 04:53:49,600
that's how you would work hand in hand
7008
04:53:50,520 --> 04:53:51,520
with blueprint and C plus plus blueprint
7009
04:53:53,218 --> 04:53:54,218
is going to make your coding a lot
7010
04:53:55,500 --> 04:53:56,500
easier so it's basically your visual
7011
04:53:58,200 --> 04:53:59,200
scripting language so it's going to be
7012
04:54:00,540 --> 04:54:01,540
very simple to write game logic
7013
04:54:03,480 --> 04:54:04,480
but when it comes to finer control and
7014
04:54:06,298 --> 04:54:07,298
when it comes to using other libraries
7015
04:54:08,340 --> 04:54:09,340
when it comes to doing machine critical
7016
04:54:10,440 --> 04:54:11,440
stuff you would use C plus plus so
7017
04:54:12,718 --> 04:54:13,718
that's basically how you use blueprint
7018
04:54:14,160 --> 04:54:15,160
and C plus plus hand in hand of course
7019
04:54:16,138 --> 04:54:17,138
this is a very in-depth topic and we are
7020
04:54:18,900 --> 04:54:19,900
going to be talking about this in the
7021
04:54:21,060 --> 04:54:22,060
future now let's actually go ahead and
7022
04:54:23,820 --> 04:54:24,820
work a little bit more on whatever we
7023
04:54:25,798 --> 04:54:26,798
learned till now
7024
04:54:28,370 --> 04:54:29,370
[Music]
7025
04:54:33,360 --> 04:54:34,360
so now that we know about the basic
7026
04:54:36,180 --> 04:54:37,180
inheritance hierarchy let's actually
7027
04:54:38,280 --> 04:54:39,280
start creating stuff on our own now the
7028
04:54:41,940 --> 04:54:42,940
first thing which you might want to
7029
04:54:43,740 --> 04:54:44,740
create are variables now for our case
7030
04:54:46,740 --> 04:54:47,740
just for reference we'll be using our
7031
04:54:49,080 --> 04:54:50,080
CPP object.h but anyways you don't have
7032
04:54:52,740 --> 04:54:53,740
to use this you can you can do this
7033
04:54:54,600 --> 04:54:55,600
inside the actor as well so stuff like
7034
04:54:56,580 --> 04:54:57,580
that will remain the same most of the
7035
04:54:59,160 --> 04:55:00,160
time you will not have anything in the
7036
04:55:01,138 --> 04:55:02,138
global scope you will create everything
7037
04:55:03,600 --> 04:55:04,600
inside of your class itself so the rest
7038
04:55:06,840 --> 04:55:07,840
of your file maybe if you are creating a
7039
04:55:09,240 --> 04:55:10,240
new struct or something you'd use it but
7040
04:55:11,458 --> 04:55:12,458
most of the times you will be doing
7041
04:55:12,900 --> 04:55:13,900
stuff inside the class
7042
04:55:14,940 --> 04:55:15,940
so let's create a variable
7043
04:55:17,280 --> 04:55:18,280
now you could do your normal C plus plus
7044
04:55:19,980 --> 04:55:20,980
syntax thing so for example let me just
7045
04:55:23,400 --> 04:55:24,400
create an integer so by using int let's
7046
04:55:26,638 --> 04:55:27,638
say our integer variable
7047
04:55:31,680 --> 04:55:32,680
all right you could initialize it here
7048
04:55:34,020 --> 04:55:35,020
or in the Constructor
7049
04:55:35,940 --> 04:55:36,940
now one thing that you might know is
7050
04:55:39,900 --> 04:55:40,900
that since this is private are derived
7051
04:55:42,120 --> 04:55:43,120
classes hence any blueprint class which
7052
04:55:44,940 --> 04:55:45,940
we create out of this cannot access a
7053
04:55:47,040 --> 04:55:48,040
variable so in order to actually access
7054
04:55:50,218 --> 04:55:51,218
it there are two ways I'll be showing
7055
04:55:52,560 --> 04:55:53,560
you guys both the ways so I'll I'll type
7056
04:55:54,660 --> 04:55:55,660
in our private integer variable because
7057
04:55:56,940 --> 04:55:57,940
we made it private this is how you would
7058
04:55:58,980 --> 04:55:59,980
ideally do it I'm just uh explaining you
7059
04:56:02,400 --> 04:56:03,400
guys each thing but you could you could
7060
04:56:05,760 --> 04:56:06,760
you know brush through if you are
7061
04:56:07,440 --> 04:56:08,440
already aware of object oriented
7062
04:56:09,660 --> 04:56:10,660
programming but anyways it will give you
7063
04:56:11,760 --> 04:56:12,760
a learning experience nonetheless
7064
04:56:14,160 --> 04:56:15,160
now another way you could do it is you
7065
04:56:16,740 --> 04:56:17,740
could create a variable in the public
7066
04:56:18,480 --> 04:56:19,480
section so we'll call this one r
7067
04:56:21,600 --> 04:56:22,600
public
7068
04:56:23,218 --> 04:56:24,218
integer variable
7069
04:56:26,520 --> 04:56:27,520
now this is good if you want to access
7070
04:56:29,638 --> 04:56:30,638
it everywhere however it's really not
7071
04:56:33,718 --> 04:56:34,718
you know appropriate to do it this way
7072
04:56:35,878 --> 04:56:36,878
because if you have it in public any
7073
04:56:38,700 --> 04:56:39,700
other class can just straight up modify
7074
04:56:41,160 --> 04:56:42,160
this variable which is not good for us
7075
04:56:44,040 --> 04:56:45,040
let's say you have something like your
7076
04:56:46,400 --> 04:56:47,400
character speed or something it's very
7077
04:56:49,260 --> 04:56:50,260
easy to misinterpret that maybe
7078
04:56:51,718 --> 04:56:52,718
accidentally change the value so it's
7079
04:56:53,580 --> 04:56:54,580
better to have Getters and Setters
7080
04:56:55,440 --> 04:56:56,440
instead now this is how you would work
7081
04:56:57,780 --> 04:56:58,780
with a public variable I know you guys
7082
04:57:00,360 --> 04:57:01,360
are still waiting for the unreals
7083
04:57:02,100 --> 04:57:03,100
reflection system so all these macros
7084
04:57:05,100 --> 04:57:06,100
which is EU class use truck your
7085
04:57:07,080 --> 04:57:08,080
property I'll tell you about all those
7086
04:57:08,520 --> 04:57:09,520
not to worry foreign
7087
04:57:16,820 --> 04:57:17,820
is that since this is private in order
7088
04:57:19,620 --> 04:57:20,620
for other classes to access it we
7089
04:57:22,080 --> 04:57:23,080
actually need to define a method so we
7090
04:57:24,420 --> 04:57:25,420
can call this one int get
7091
04:57:27,958 --> 04:57:28,958
our
7092
04:57:29,580 --> 04:57:30,580
private
7093
04:57:30,958 --> 04:57:31,958
hint
7094
04:57:32,820 --> 04:57:33,820
we called it increaser order so let's
7095
04:57:36,298 --> 04:57:37,298
call it
7096
04:57:37,500 --> 04:57:38,500
like this
7097
04:57:39,540 --> 04:57:40,540
now we also probably need a Setter
7098
04:57:42,780 --> 04:57:43,780
so set our private
7099
04:57:45,718 --> 04:57:46,718
integer now we don't have a function
7100
04:57:48,298 --> 04:57:49,298
definition so if the reason I told you
7101
04:57:51,660 --> 04:57:52,660
guys at the beginning that you don't
7102
04:57:53,100 --> 04:57:54,100
really need to know too much C plus plus
7103
04:57:54,920 --> 04:57:55,920
is that once you know how to write the
7104
04:57:58,680 --> 04:57:59,680
Declaration you could just right click
7105
04:58:00,600 --> 04:58:01,600
quick actions and you could just create
7106
04:58:02,458 --> 04:58:03,458
a definition like this same way with our
7107
04:58:05,280 --> 04:58:06,280
Setter function oh and this has to be
7108
04:58:07,560 --> 04:58:08,560
void because we aren't actually
7109
04:58:09,298 --> 04:58:10,298
returning anything you could make it
7110
04:58:11,280 --> 04:58:12,280
bull so let's say you have a condition
7111
04:58:13,500 --> 04:58:14,500
where you can't set it so let's say for
7112
04:58:15,420 --> 04:58:16,420
a health variable you can't set it to
7113
04:58:17,340 --> 04:58:18,340
101 so then you would do those checkings
7114
04:58:20,218 --> 04:58:21,218
and stuff but in our case we'll just use
7115
04:58:21,958 --> 04:58:22,958
void
7116
04:58:24,060 --> 04:58:25,060
head into the file here and instead of
7117
04:58:27,298 --> 04:58:28,298
this we will return this variable so not
7118
04:58:30,298 --> 04:58:31,298
public we'll return our private integer
7119
04:58:32,520 --> 04:58:33,520
variable
7120
04:58:35,760 --> 04:58:36,760
now this is how you would set it up for
7121
04:58:38,520 --> 04:58:39,520
the private variable and this is the
7122
04:58:40,560 --> 04:58:41,560
proper way to do it
7123
04:58:42,420 --> 04:58:43,420
also
7124
04:58:43,560 --> 04:58:44,560
uh currently none of these use unreals
7125
04:58:47,218 --> 04:58:48,218
reflection system now if I just run a
7126
04:58:49,560 --> 04:58:50,560
debugger so it's going to launch the
7127
04:58:51,180 --> 04:58:52,180
editor make sure it's set to development
7128
04:58:52,980 --> 04:58:53,980
editor in the configuration
7129
04:58:56,160 --> 04:58:57,160
so wait for that to build
7130
04:58:58,500 --> 04:58:59,500
and once it's done building it should
7131
04:59:00,840 --> 04:59:01,840
start the editor
7132
04:59:04,070 --> 04:59:05,070
[Music]
7133
04:59:09,180 --> 04:59:10,180
now in order to actually use this over
7134
04:59:11,760 --> 04:59:12,760
here and actually check stuff uh in
7135
04:59:15,180 --> 04:59:16,180
Blueprint so what you would do is you
7136
04:59:17,520 --> 04:59:18,520
would right click go to blueprint class
7137
04:59:19,260 --> 04:59:20,260
and type in CPP underscore object but
7138
04:59:21,900 --> 04:59:22,900
you see that it's not visible now the
7139
04:59:24,420 --> 04:59:25,420
reason it's not visible but our actor
7140
04:59:26,700 --> 04:59:27,700
was visible because by default All
7141
04:59:28,798 --> 04:59:29,798
actors if you were to go into this file
7142
04:59:31,320 --> 04:59:32,320
by default All actors are going to be
7143
04:59:34,440 --> 04:59:35,440
marked as blueprintable so if I actually
7144
04:59:36,900 --> 04:59:37,900
head into
7145
04:59:38,458 --> 04:59:39,458
uh the actor over here
7146
04:59:41,718 --> 04:59:42,718
and if I actually look into this U class
7147
04:59:45,060 --> 04:59:46,060
macro you see it says blueprintable
7148
04:59:48,900 --> 04:59:49,900
so what we need to do is in our object
7149
04:59:51,420 --> 04:59:52,420
if we want to use this in Blueprint that
7150
04:59:52,980 --> 04:59:53,980
is inside this u-class macro type in
7151
04:59:55,440 --> 04:59:56,440
blueprint table now this is how you
7152
04:59:57,298 --> 04:59:58,298
expose your view objects to blueprint so
7153
04:59:59,700 --> 05:00:00,700
let's say anything is not accessible in
7154
05:00:02,340 --> 05:00:03,340
this menu over here okay under all
7155
05:00:04,620 --> 05:00:05,620
classes it probably means you haven't
7156
05:00:06,900 --> 05:00:07,900
marked it as blueprintable so let's stop
7157
05:00:08,820 --> 05:00:09,820
the debugger and run it again
7158
05:00:11,638 --> 05:00:12,638
so wait for it to compile then once the
7159
05:00:14,878 --> 05:00:15,878
editor loads up we should be able to use
7160
05:00:17,280 --> 05:00:18,280
our
7161
05:00:19,440 --> 05:00:20,440
CPP underscore object class
7162
05:00:22,500 --> 05:00:23,500
so give it a second for it to load
7163
05:00:26,160 --> 05:00:27,160
and now if I head back into blueprints
7164
05:00:28,320 --> 05:00:29,320
right click blueprint class CPP
7165
05:00:30,718 --> 05:00:31,718
underscore object you see that it's
7166
05:00:33,000 --> 05:00:34,000
usable
7167
05:00:34,260 --> 05:00:35,260
and this one will call it BP underscore
7168
05:00:36,660 --> 05:00:37,660
object
7169
05:00:38,280 --> 05:00:39,280
now if I just right click and if I want
7170
05:00:41,580 --> 05:00:42,580
to access the function
7171
05:00:43,200 --> 05:00:44,200
so we have get our private integer
7172
05:00:46,260 --> 05:00:47,260
so get R and as you can see there is
7173
05:00:49,680 --> 05:00:50,680
really nothing
7174
05:00:50,940 --> 05:00:51,940
the reason is
7175
05:00:52,440 --> 05:00:53,440
unreal doesn't really know that you want
7176
05:00:55,798 --> 05:00:56,798
this to come in the editor basically
7177
05:00:58,080 --> 05:00:59,080
you're not utilizing
7178
05:01:00,540 --> 05:01:01,540
uh the unreal standard macros which
7179
05:01:03,180 --> 05:01:04,180
enable you to do it
7180
05:01:05,040 --> 05:01:06,040
so how you do it is for variables what
7181
05:01:08,340 --> 05:01:09,340
you do for a public variable here we are
7182
05:01:10,378 --> 05:01:11,378
going to type in U property
7183
05:01:13,020 --> 05:01:14,020
and in the arguments will use a
7184
05:01:17,940 --> 05:01:18,940
parameter known as blueprint read write
7185
05:01:23,458 --> 05:01:24,458
now when you put this in the arguments
7186
05:01:25,980 --> 05:01:26,980
basically what you're saying is you want
7187
05:01:28,440 --> 05:01:29,440
this to be readable and writeable in
7188
05:01:31,260 --> 05:01:32,260
Blueprint let's say you only wanted to
7189
05:01:33,660 --> 05:01:34,660
be able to read it you do blueprint read
7190
05:01:35,638 --> 05:01:36,638
only now how do I know how to do this
7191
05:01:38,340 --> 05:01:39,340
basically you can just head into your
7192
05:01:40,378 --> 05:01:41,378
browser and type in you property
7193
05:01:46,680 --> 05:01:47,680
ue4
7194
05:01:47,760 --> 05:01:48,760
audio A5
7195
05:01:49,920 --> 05:01:50,920
oops not properties
7196
05:01:54,180 --> 05:01:55,180
so
7197
05:01:56,520 --> 05:01:57,520
yep your property so basically you have
7198
05:01:58,680 --> 05:01:59,680
to go to the documentation page and
7199
05:02:01,860 --> 05:02:02,860
as you can see there should be a list of
7200
05:02:04,020 --> 05:02:05,020
specifiers somewhere over here there is
7201
05:02:07,860 --> 05:02:08,860
so all of these are the specifiers so
7202
05:02:11,580 --> 05:02:12,580
let's say you wanted a function to be
7203
05:02:13,020 --> 05:02:14,020
blueprint callable you do that that is
7204
05:02:15,180 --> 05:02:16,180
blueprint PR as well I'll be showing you
7205
05:02:17,458 --> 05:02:18,458
guys the common ones but you can have a
7206
05:02:19,440 --> 05:02:20,440
look at all of these
7207
05:02:21,360 --> 05:02:22,360
the documentation is King
7208
05:02:24,000 --> 05:02:25,000
now for a private variable actually we
7209
05:02:26,580 --> 05:02:27,580
don't need to make this Au property
7210
05:02:29,100 --> 05:02:30,100
however you could choose to make it now
7211
05:02:32,340 --> 05:02:33,340
if you want to use these Getters and
7212
05:02:34,320 --> 05:02:35,320
Setters which will technically
7213
05:02:36,780 --> 05:02:37,780
you know enable us to use our private
7214
05:02:39,000 --> 05:02:40,000
variable
7215
05:02:40,378 --> 05:02:41,378
our get function will be pure of course
7216
05:02:42,420 --> 05:02:43,420
so we are going to use a u function now
7217
05:02:45,660 --> 05:02:46,660
now view function is another macro again
7218
05:02:48,480 --> 05:02:49,480
you could have a look at it so here if I
7219
05:02:51,060 --> 05:02:52,060
head into U function over here
7220
05:02:53,638 --> 05:02:54,638
you see again there is documentation
7221
05:02:56,340 --> 05:02:57,340
which talks in depth about this
7222
05:02:59,400 --> 05:03:00,400
we will be looking at the common ones
7223
05:03:01,138 --> 05:03:02,138
anyways
7224
05:03:02,340 --> 05:03:03,340
this one will be blueprint pure
7225
05:03:05,580 --> 05:03:06,580
blueprint PR means those green nodes
7226
05:03:07,860 --> 05:03:08,860
which we saw without any execution pins
7227
05:03:09,840 --> 05:03:10,840
so if I actually head into any blueprint
7228
05:03:12,180 --> 05:03:13,180
these types of nodes basically without
7229
05:03:14,700 --> 05:03:15,700
this execution pin
7230
05:03:17,040 --> 05:03:18,040
that's going to be our Pure function
7231
05:03:20,160 --> 05:03:21,160
and I talked a lot in depth about it
7232
05:03:22,680 --> 05:03:23,680
when I talked about Blueprints and stuff
7233
05:03:24,480 --> 05:03:25,480
now this one will be a u function as
7234
05:03:26,638 --> 05:03:27,638
well and this one will just be blueprint
7235
05:03:29,218 --> 05:03:30,218
callable
7236
05:03:32,820 --> 05:03:33,820
all right now we can go ahead and run a
7237
05:03:36,660 --> 05:03:37,660
debugger
7238
05:03:38,878 --> 05:03:39,878
now we should be able to access this
7239
05:03:48,360 --> 05:03:49,360
now live coding is a bit finicky that's
7240
05:03:51,600 --> 05:03:52,600
the reason I'm not using it otherwise I
7241
05:03:54,360 --> 05:03:55,360
would have chose to use it now let me
7242
05:03:57,120 --> 05:03:58,120
just create that I didn't actually save
7243
05:03:58,680 --> 05:03:59,680
it so CPP underscore object
7244
05:04:01,860 --> 05:04:02,860
we'll call this one BP underscore object
7245
05:04:05,878 --> 05:04:06,878
save that this time
7246
05:04:07,740 --> 05:04:08,740
if I open it up now and if I type in get
7247
05:04:11,760 --> 05:04:12,760
our
7248
05:04:13,020 --> 05:04:14,020
private integer you see we get this
7249
05:04:15,718 --> 05:04:16,718
function which gives us access to the
7250
05:04:17,458 --> 05:04:18,458
value similarly set our private integer
7251
05:04:20,878 --> 05:04:21,878
also works but it's kinda useless we
7252
05:04:23,638 --> 05:04:24,638
actually didn't set up any functionality
7253
05:04:25,260 --> 05:04:26,260
so let's just take in a parameter
7254
05:04:27,180 --> 05:04:28,180
parameters are pretty simple except
7255
05:04:30,060 --> 05:04:31,060
references everything else is going to
7256
05:04:32,458 --> 05:04:33,458
be the same for parameters like how you
7257
05:04:34,500 --> 05:04:35,500
do in standard C plus plus so you could
7258
05:04:37,080 --> 05:04:38,080
type in in new value
7259
05:04:40,740 --> 05:04:41,740
and over here as well we could just head
7260
05:04:43,560 --> 05:04:44,560
into the definition and change that
7261
05:04:45,840 --> 05:04:46,840
and then we could do our private or our
7262
05:04:48,958 --> 05:04:49,958
public it should be nope it should be
7263
05:04:50,760 --> 05:04:51,760
private so our private integer variable
7264
05:04:53,060 --> 05:04:54,060
equals new value
7265
05:04:56,520 --> 05:04:57,520
now that should fix things so we should
7266
05:04:59,340 --> 05:05:00,340
have our logic corrected over there
7267
05:05:02,218 --> 05:05:03,218
but that's not really our concern right
7268
05:05:04,080 --> 05:05:05,080
now
7269
05:05:05,900 --> 05:05:06,900
what if you wanted to take a value by
7270
05:05:08,820 --> 05:05:09,820
reference now this is passed by value
7271
05:05:10,620 --> 05:05:11,620
and it will work you could try it out
7272
05:05:12,298 --> 05:05:13,298
not really going to waste my time to
7273
05:05:14,280 --> 05:05:15,280
show it if you actually want your value
7274
05:05:18,060 --> 05:05:19,060
to be passed by reference you use this
7275
05:05:20,040 --> 05:05:21,040
macro known as U param
7276
05:05:22,500 --> 05:05:23,500
ref
7277
05:05:25,700 --> 05:05:26,700
and then you use an ampersand over here
7278
05:05:30,240 --> 05:05:31,240
so copy this do the same thing in your
7279
05:05:33,480 --> 05:05:34,480
CPP
7280
05:05:34,620 --> 05:05:35,620
and now if I go ahead and actually build
7281
05:05:37,440 --> 05:05:38,440
this once again
7282
05:05:39,540 --> 05:05:40,540
and and in my object if I go ahead and
7283
05:05:42,480 --> 05:05:43,480
type set our private integer you see
7284
05:05:45,540 --> 05:05:46,540
it's taking in by reference if you hover
7285
05:05:47,700 --> 05:05:48,700
over it it says new value integer by
7286
05:05:50,760 --> 05:05:51,760
reference
7287
05:05:51,958 --> 05:05:52,958
so this is how you do pass by reference
7288
05:05:53,940 --> 05:05:54,940
I just showed that this is one thing
7289
05:05:56,160 --> 05:05:57,160
which is a little different from C plus
7290
05:05:57,718 --> 05:05:58,718
plus you can't just use an ampersand
7291
05:06:00,540 --> 05:06:01,540
however if you use an ampersand it is
7292
05:06:03,298 --> 05:06:04,298
going to take it as a second return
7293
05:06:05,100 --> 05:06:06,100
value in Blueprint basically like your
7294
05:06:07,080 --> 05:06:08,080
out parameters so let me show you guys
7295
05:06:09,540 --> 05:06:10,540
what I mean by that so if I do this now
7296
05:06:11,940 --> 05:06:12,940
this is wrong logically this is wrong I
7297
05:06:14,100 --> 05:06:15,100
know that but anyways I'm just showing
7298
05:06:16,680 --> 05:06:17,680
you guys what's gonna happen
7299
05:06:18,240 --> 05:06:19,240
so if I go ahead and run a debugger once
7300
05:06:21,360 --> 05:06:22,360
again
7301
05:06:22,320 --> 05:06:23,320
this time it's going to take it as an
7302
05:06:24,360 --> 05:06:25,360
output rather than an input
7303
05:06:30,780 --> 05:06:31,780
if I open my BP object again
7304
05:06:33,958 --> 05:06:34,958
and if I type in
7305
05:06:36,780 --> 05:06:37,780
let's say set r
7306
05:06:40,440 --> 05:06:41,440
private integer you see the new value
7307
05:06:42,660 --> 05:06:43,660
goes out basically this is how you
7308
05:06:44,820 --> 05:06:45,820
handle multiple return values as well
7309
05:06:46,740 --> 05:06:47,740
you could just do pass by reference and
7310
05:06:49,620 --> 05:06:50,620
in Blueprint it's going to interpret it
7311
05:06:51,900 --> 05:06:52,900
as an out parameter in our case uh your
7312
05:06:54,718 --> 05:06:55,718
param ref was the correct choice so we
7313
05:06:57,660 --> 05:06:58,660
are going to do that undo this over here
7314
05:07:00,000 --> 05:07:01,000
as well
7315
05:07:01,020 --> 05:07:02,020
so that's about it
7316
05:07:04,260 --> 05:07:05,260
oops just correct that
7317
05:07:07,320 --> 05:07:08,320
also if you guys want to access your
7318
05:07:10,080 --> 05:07:11,080
public variable you can just directly
7319
05:07:12,120 --> 05:07:13,120
use our public variable so our public
7320
05:07:15,180 --> 05:07:16,180
integer variable so it's directly
7321
05:07:17,160 --> 05:07:18,160
accessible to us but one thing you might
7322
05:07:19,860 --> 05:07:20,860
notice is that unlike these variables
7323
05:07:22,138 --> 05:07:23,138
here it does not let you edit the
7324
05:07:24,420 --> 05:07:25,420
default value and stuff
7325
05:07:26,160 --> 05:07:27,160
now there is one reason for that that's
7326
05:07:29,520 --> 05:07:30,520
because you again need to set a flag in
7327
05:07:32,760 --> 05:07:33,760
order to do it remember the you property
7328
05:07:36,298 --> 05:07:37,298
macro or here you have to type in edit
7329
05:07:39,240 --> 05:07:40,240
anywhere in order to be able to do it so
7330
05:07:41,878 --> 05:07:42,878
edit
7331
05:07:43,138 --> 05:07:44,138
anywhere if I can spell that correctly
7332
05:07:46,560 --> 05:07:47,560
if I actually do this and run a debugger
7333
05:07:49,560 --> 05:07:50,560
once again I should be able to use our
7334
05:07:51,660 --> 05:07:52,660
public integer variable and set its
7335
05:07:53,760 --> 05:07:54,760
default value
7336
05:07:55,400 --> 05:07:56,400
now if you were to see under the class
7337
05:07:57,958 --> 05:07:58,958
defaults we have an option to set the
7338
05:08:00,240 --> 05:08:01,240
default value or when we even get our
7339
05:08:02,638 --> 05:08:03,638
public integer variable you see that we
7340
05:08:05,458 --> 05:08:06,458
can set our default value so this is
7341
05:08:08,040 --> 05:08:09,040
basically how you expose that to
7342
05:08:09,840 --> 05:08:10,840
blueprint
7343
05:08:11,490 --> 05:08:12,490
[Music]
7344
05:08:15,958 --> 05:08:16,958
I suggest that you guys now try it with
7345
05:08:19,378 --> 05:08:20,378
a few more functions of yourself
7346
05:08:21,680 --> 05:08:22,680
and maybe you know check how they work
7347
05:08:25,680 --> 05:08:26,680
in the editor and stuff once that's done
7348
05:08:28,860 --> 05:08:29,860
let's talk about the next type that is
7349
05:08:32,040 --> 05:08:33,040
u-struct so basically if you want to
7350
05:08:34,378 --> 05:08:35,378
create structs for the Unreal Engine you
7351
05:08:38,160 --> 05:08:39,160
need to use the macro known as you
7352
05:08:40,378 --> 05:08:41,378
struct now generally I prefer doing it
7353
05:08:44,280 --> 05:08:45,280
inside this dot h file for your project
7354
05:08:46,798 --> 05:08:47,798
so you will have a file like this
7355
05:08:49,740 --> 05:08:50,740
but you really don't need to you could
7356
05:08:51,780 --> 05:08:52,780
do it in any file so for example let me
7357
05:08:54,420 --> 05:08:55,420
just do it in our CPP object.h file it
7358
05:08:58,740 --> 05:08:59,740
could be really anywhere unreal is going
7359
05:09:01,320 --> 05:09:02,320
to recognize it for you so I'll just do
7360
05:09:03,298 --> 05:09:04,298
it above our U class so I'll just type
7361
05:09:06,120 --> 05:09:07,120
in struct
7362
05:09:07,500 --> 05:09:08,500
and if you guys don't know what struct
7363
05:09:09,120 --> 05:09:10,120
is uh well you got to learn that before
7364
05:09:13,138 --> 05:09:14,138
it's basically like a class but uh by
7365
05:09:17,040 --> 05:09:18,040
default all its members are public but
7366
05:09:19,500 --> 05:09:20,500
remember when you are working with the
7367
05:09:21,480 --> 05:09:22,480
Unreal Engine you don't really work with
7368
05:09:24,540 --> 05:09:25,540
struct methods you only work with
7369
05:09:27,120 --> 05:09:28,120
variables and any methods you'll have
7370
05:09:29,280 --> 05:09:30,280
you'll have it in another class as
7371
05:09:31,260 --> 05:09:32,260
static functions so that's how you work
7372
05:09:34,138 --> 05:09:35,138
with it anyways I will show you guys
7373
05:09:36,000 --> 05:09:37,000
what I mean by that real soon
7374
05:09:38,700 --> 05:09:39,700
so for example let's just create a
7375
05:09:41,940 --> 05:09:42,940
struct known as let's say book
7376
05:09:44,820 --> 05:09:45,820
this is obviously highly impractical but
7377
05:09:47,340 --> 05:09:48,340
just as a basic example and for the
7378
05:09:50,878 --> 05:09:51,878
variables we could have maybe a string
7379
05:09:53,100 --> 05:09:54,100
now remember in Unreal Engine the
7380
05:09:56,218 --> 05:09:57,218
variable you use is not STD string so
7381
05:09:59,400 --> 05:10:00,400
you don't use STD string actually what
7382
05:10:02,218 --> 05:10:03,218
you use is called fstring which is
7383
05:10:04,860 --> 05:10:05,860
unreal string type
7384
05:10:06,840 --> 05:10:07,840
obviously most of the string types are
7385
05:10:10,260 --> 05:10:11,260
just interconvertible at any point of
7386
05:10:12,480 --> 05:10:13,480
time so if you are using a third party
7387
05:10:14,280 --> 05:10:15,280
library or something you can convert it
7388
05:10:16,080 --> 05:10:17,080
so F string is the string type in unreal
7389
05:10:19,378 --> 05:10:20,378
so if I type in F string let's say name
7390
05:10:22,740 --> 05:10:23,740
and maybe we can have an integer for
7391
05:10:25,138 --> 05:10:26,138
number of pages
7392
05:10:28,138 --> 05:10:29,138
and we can have a float for rating
7393
05:10:32,878 --> 05:10:33,878
all right we have a really basic struct
7394
05:10:35,400 --> 05:10:36,400
over here now if I go ahead and build
7395
05:10:37,798 --> 05:10:38,798
this actually so I'll close my editor
7396
05:10:40,500 --> 05:10:41,500
if I go ahead and build this
7397
05:10:42,840 --> 05:10:43,840
you would see that it would build
7398
05:10:45,180 --> 05:10:46,180
successfully
7399
05:10:46,560 --> 05:10:47,560
however obviously uh as you would expect
7400
05:10:49,740 --> 05:10:50,740
you cannot access this struct in the
7401
05:10:51,958 --> 05:10:52,958
editor because we haven't used the
7402
05:10:53,940 --> 05:10:54,940
unreal macros so in order to use this in
7403
05:10:56,638 --> 05:10:57,638
the editor you you call you struct
7404
05:11:01,160 --> 05:11:02,160
and inside the parameters what you do is
7405
05:11:04,980 --> 05:11:05,980
you would make this
7406
05:11:06,718 --> 05:11:07,718
blueprint
7407
05:11:09,600 --> 05:11:10,600
type
7408
05:11:11,218 --> 05:11:12,218
so this is what you use to expose truck
7409
05:11:13,620 --> 05:11:14,620
to blueprints now if I actually run a
7410
05:11:16,320 --> 05:11:17,320
debugger right here
7411
05:11:17,760 --> 05:11:18,760
so you would find that there are a few
7412
05:11:20,638 --> 05:11:21,638
build errors
7413
05:11:22,260 --> 05:11:23,260
so what this is is this is not your C
7414
05:11:25,260 --> 05:11:26,260
plus plus compiler error
7415
05:11:27,298 --> 05:11:28,298
basically there are a few rules in order
7416
05:11:30,120 --> 05:11:31,120
to use structs in unreal similar to how
7417
05:11:32,458 --> 05:11:33,458
you have a u prefix for all structs you
7418
05:11:35,340 --> 05:11:36,340
need to have an F prefix
7419
05:11:37,560 --> 05:11:38,560
so now if I go ahead and run this
7420
05:11:42,240 --> 05:11:43,240
in the editor it's going to be visible
7421
05:11:44,100 --> 05:11:45,100
as book you see that we get another
7422
05:11:46,860 --> 05:11:47,860
error now it says expected a generated
7423
05:11:50,400 --> 05:11:51,400
body now if you notice our class here it
7424
05:11:53,160 --> 05:11:54,160
has a generated body similarly for our
7425
05:11:56,340 --> 05:11:57,340
struct as well for all U structs we are
7426
05:11:58,860 --> 05:11:59,860
supposed to be having a generated
7427
05:12:01,260 --> 05:12:02,260
u-struct body
7428
05:12:04,440 --> 05:12:05,440
so it's going to set stuff up for the
7429
05:12:06,718 --> 05:12:07,718
editor for us basically
7430
05:12:08,700 --> 05:12:09,700
so now if I go ahead and build this you
7431
05:12:11,520 --> 05:12:12,520
should see that we compiled successfully
7432
05:12:15,360 --> 05:12:16,360
and we open up the editor right now
7433
05:12:19,200 --> 05:12:20,200
but you will soon notice one problem
7434
05:12:21,298 --> 05:12:22,298
again which you probably would have
7435
05:12:23,340 --> 05:12:24,340
guessed if you would have seen these
7436
05:12:26,280 --> 05:12:27,280
so the so if I just head into my object
7437
05:12:29,340 --> 05:12:30,340
for example and if I if I type in let's
7438
05:12:32,458 --> 05:12:33,458
say I create a new variable and call
7439
05:12:34,560 --> 05:12:35,560
this one book one
7440
05:12:36,298 --> 05:12:37,298
and I get the type book
7441
05:12:39,718 --> 05:12:40,718
you see I can access this
7442
05:12:42,298 --> 05:12:43,298
there's no issue but if I right click I
7443
05:12:45,180 --> 05:12:46,180
can't actually split the struct pins
7444
05:12:47,638 --> 05:12:48,638
now if you actually hover over this
7445
05:12:50,400 --> 05:12:51,400
cannot split the struct pin it may be
7446
05:12:53,580 --> 05:12:54,580
missing blueprint exposed properties
7447
05:12:56,340 --> 05:12:57,340
so what is it basically tells us is we
7448
05:12:59,340 --> 05:13:00,340
actually need to Mark these as you
7449
05:13:01,020 --> 05:13:02,020
property as well so the same macro can
7450
05:13:04,320 --> 05:13:05,320
be used here as well so you property
7451
05:13:07,400 --> 05:13:08,400
and there's a little bit of an issue
7452
05:13:09,718 --> 05:13:10,718
with the indentation there don't mind
7453
05:13:12,840 --> 05:13:13,840
so your property again
7454
05:13:16,458 --> 05:13:17,458
make this one a you property depending
7455
05:13:19,680 --> 05:13:20,680
on what you want let's say we don't want
7456
05:13:22,080 --> 05:13:23,080
to be able to change the name so let's
7457
05:13:23,820 --> 05:13:24,820
make that blueprint read only so then we
7458
05:13:26,040 --> 05:13:27,040
won't be able to change it now if I stop
7459
05:13:29,280 --> 05:13:30,280
debugging and open the editor once again
7460
05:13:33,660 --> 05:13:34,660
now if I go ahead and take a look and if
7461
05:13:36,240 --> 05:13:37,240
I drag this in right click and split
7462
05:13:39,120 --> 05:13:40,120
struct pin I am able to split it now if
7463
05:13:42,540 --> 05:13:43,540
you drag this in and if you want to edit
7464
05:13:44,878 --> 05:13:45,878
the members you would use the set
7465
05:13:46,440 --> 05:13:47,440
members function
7466
05:13:48,180 --> 05:13:49,180
and obviously you can have number of
7467
05:13:50,638 --> 05:13:51,638
pages and rating as a parameter and we
7468
05:13:53,100 --> 05:13:54,100
set name as not being editable since we
7469
05:13:56,638 --> 05:13:57,638
did blueprint read only as you can see
7470
05:13:59,340 --> 05:14:00,340
we don't have that available as a pin so
7471
05:14:02,340 --> 05:14:03,340
this is basically how you use structs in
7472
05:14:04,620 --> 05:14:05,620
C plus plus now the way you use it in C
7473
05:14:07,200 --> 05:14:08,200
plus plus is pretty much the same like
7474
05:14:08,940 --> 05:14:09,940
how you would by the way if you want
7475
05:14:10,980 --> 05:14:11,980
struct methods you can use them but you
7476
05:14:13,200 --> 05:14:14,200
cannot write U functions inside stock
7477
05:14:15,540 --> 05:14:16,540
that's the thing so if I actually go
7478
05:14:18,000 --> 05:14:19,000
ahead and try it basically I'll show it
7479
05:14:19,980 --> 05:14:20,980
to you guys so
7480
05:14:22,260 --> 05:14:23,260
if I had in here type in let's say void
7481
05:14:25,440 --> 05:14:26,440
test function and I'll just give it a
7482
05:14:27,540 --> 05:14:28,540
simple body here and I won't do anything
7483
05:14:29,520 --> 05:14:30,520
now we would see that it will build
7484
05:14:31,620 --> 05:14:32,620
successfully there won't be any issues
7485
05:14:35,100 --> 05:14:36,100
so as you can see it builds but if I
7486
05:14:37,500 --> 05:14:38,500
actually make this a u function
7487
05:14:40,080 --> 05:14:41,080
I won't I won't even give any parameters
7488
05:14:42,240 --> 05:14:43,240
if I just make this a u function
7489
05:14:45,840 --> 05:14:46,840
as you would see it says use trucks
7490
05:14:48,540 --> 05:14:49,540
cannot contain you functions
7491
05:14:50,400 --> 05:14:51,400
so how do you actually do stuff with it
7492
05:14:53,520 --> 05:14:54,520
so how do you actually operate on
7493
05:14:55,500 --> 05:14:56,500
structs basically what you do is instead
7494
05:14:58,980 --> 05:14:59,980
of having the U function here you would
7495
05:15:00,900 --> 05:15:01,900
have it inside either a function Library
7496
05:15:03,120 --> 05:15:04,120
class or you would have it inside some
7497
05:15:06,180 --> 05:15:07,180
other object and make it a static
7498
05:15:08,218 --> 05:15:09,218
function maybe so let me actually show
7499
05:15:10,440 --> 05:15:11,440
that
7500
05:15:11,820 --> 05:15:12,820
so let's create a test function
7501
05:15:14,400 --> 05:15:15,400
so for example let's create a u function
7502
05:15:16,798 --> 05:15:17,798
here
7503
05:15:17,878 --> 05:15:18,878
so U function
7504
05:15:19,980 --> 05:15:20,980
and what we can do is we can make this
7505
05:15:23,820 --> 05:15:24,820
blueprint callable
7506
05:15:27,240 --> 05:15:28,240
and over here instead of just declaring
7507
05:15:29,940 --> 05:15:30,940
a regular function let's do a static
7508
05:15:31,920 --> 05:15:32,920
function static void test
7509
05:15:35,840 --> 05:15:36,840
and now we want to operate on this truck
7510
05:15:39,480 --> 05:15:40,480
so if you want to operate it similar to
7511
05:15:42,420 --> 05:15:43,420
your objects what you could do is you
7512
05:15:44,820 --> 05:15:45,820
could simply create your own Target pin
7513
05:15:47,100 --> 05:15:48,100
so the way you do it is fbook
7514
05:15:51,840 --> 05:15:52,840
Target and obviously you would make that
7515
05:15:54,840 --> 05:15:55,840
a reference so
7516
05:15:57,780 --> 05:15:58,780
you param
7517
05:15:59,820 --> 05:16:00,820
and in the brackets you would have ref
7518
05:16:02,940 --> 05:16:03,940
so you would pass this as a reference
7519
05:16:05,820 --> 05:16:06,820
and then you could work with it inside
7520
05:16:09,020 --> 05:16:10,020
so I can write the definition here as
7521
05:16:11,940 --> 05:16:12,940
well but just to be a bit cleaner so
7522
05:16:14,218 --> 05:16:15,218
quick actions
7523
05:16:15,958 --> 05:16:16,958
so whoops
7524
05:16:18,540 --> 05:16:19,540
quick actions and I can create the
7525
05:16:21,600 --> 05:16:22,600
definition
7526
05:16:22,500 --> 05:16:23,500
uh now now that we've actually come this
7527
05:16:25,260 --> 05:16:26,260
far I'll just show you guys how to print
7528
05:16:27,060 --> 05:16:28,060
strings so it's not like blueprint where
7529
05:16:31,200 --> 05:16:32,200
you directly just call you know print
7530
05:16:33,958 --> 05:16:34,958
string and this is not gonna work so I
7531
05:16:37,680 --> 05:16:38,680
can't just do this so let's just say
7532
05:16:40,320 --> 05:16:41,320
test function called for example
7533
05:16:44,458 --> 05:16:45,458
I actually cannot do this
7534
05:16:47,638 --> 05:16:48,638
uh the very simple reason being that
7535
05:16:52,550 --> 05:16:53,550
[Music]
7536
05:16:57,420 --> 05:16:58,420
in Blueprint unreal actually Imports or
7537
05:17:01,378 --> 05:17:02,378
rather includes all your headers for you
7538
05:17:03,780 --> 05:17:04,780
as per necessity but basically that
7539
05:17:07,500 --> 05:17:08,500
doesn't happen here so it's not exactly
7540
05:17:10,260 --> 05:17:11,260
headers but you get the point
7541
05:17:13,138 --> 05:17:14,138
so in order to use print string so how
7542
05:17:16,980 --> 05:17:17,980
you would go about searching for
7543
05:17:18,480 --> 05:17:19,480
functions is you do something like this
7544
05:17:20,160 --> 05:17:21,160
so you do print string
7545
05:17:22,160 --> 05:17:23,160
unreal C plus plus this is how you just
7546
05:17:25,020 --> 05:17:26,020
search it up and you would look for the
7547
05:17:26,940 --> 05:17:27,940
one which says docs.unreal engine.com
7548
05:17:30,420 --> 05:17:31,420
and you would head in here and it says
7549
05:17:33,298 --> 05:17:34,298
it tells you the include file so copy
7550
05:17:36,180 --> 05:17:37,180
this path
7551
05:17:38,160 --> 05:17:39,160
paste this in no not path rather the
7552
05:17:41,218 --> 05:17:42,218
include
7553
05:17:42,480 --> 05:17:43,480
and now we would see you have all the
7554
05:17:44,700 --> 05:17:45,700
various parameters some of which are
7555
05:17:46,560 --> 05:17:47,560
optional there are only two parameters
7556
05:17:48,958 --> 05:17:49,958
which actually need but anyways
7557
05:17:52,320 --> 05:17:53,320
now what we can do is
7558
05:17:55,320 --> 05:17:56,320
now you notice that you are not able to
7559
05:17:57,540 --> 05:17:58,540
call it
7560
05:17:58,560 --> 05:17:59,560
but that's because this is actually a
7561
05:18:00,420 --> 05:18:01,420
static function once again
7562
05:18:02,400 --> 05:18:03,400
so what you do is you do you Kismet
7563
05:18:04,560 --> 05:18:05,560
system Library
7564
05:18:06,718 --> 05:18:07,718
and followed by a scope resolution print
7565
05:18:09,660 --> 05:18:10,660
string and now we would see that it
7566
05:18:11,638 --> 05:18:12,638
still shows an error that's because you
7567
05:18:13,920 --> 05:18:14,920
actually need to pass in a world context
7568
05:18:16,740 --> 05:18:17,740
object because it doesn't really know
7569
05:18:19,860 --> 05:18:20,860
you know where to uh output the string
7570
05:18:23,820 --> 05:18:24,820
like how to show it on the screen so in
7571
05:18:26,458 --> 05:18:27,458
order for it to know that you actually
7572
05:18:28,080 --> 05:18:29,080
need to pass in an object if this wasn't
7573
05:18:31,320 --> 05:18:32,320
a static function you would just use
7574
05:18:33,360 --> 05:18:34,360
this so if if this were inside an actor
7575
05:18:36,200 --> 05:18:37,200
and it's not static you'd use this but
7576
05:18:39,600 --> 05:18:40,600
it says this may only be used inside a
7577
05:18:43,378 --> 05:18:44,378
non-static member function so what we
7578
05:18:45,480 --> 05:18:46,480
can do is we can just pass in a u object
7579
05:18:47,580 --> 05:18:48,580
pointer over here or rather we'll just
7580
05:18:49,740 --> 05:18:50,740
pass in an actor pointer so a actor
7581
05:18:53,520 --> 05:18:54,520
pointer now remember when you work in C
7582
05:18:57,360 --> 05:18:58,360
plus plus
7583
05:18:58,378 --> 05:18:59,378
any object any actor anything that you
7584
05:19:02,160 --> 05:19:03,160
have which is enclosed in a class
7585
05:19:04,440 --> 05:19:05,440
basically any class if you want to use
7586
05:19:06,840 --> 05:19:07,840
them you would use a pointer to it you
7587
05:19:10,260 --> 05:19:11,260
will never refer to it as a actor it'll
7588
05:19:13,138 --> 05:19:14,138
always be a pointer just remember that
7589
05:19:17,160 --> 05:19:18,160
so an actor is just to give you know
7590
05:19:20,458 --> 05:19:21,458
some context to it so we can just type
7591
05:19:23,580 --> 05:19:24,580
in context for example
7592
05:19:26,638 --> 05:19:27,638
it could be an object as well I assume
7593
05:19:28,860 --> 05:19:29,860
so if I type in context here
7594
05:19:32,340 --> 05:19:33,340
now we would see that the error is gone
7595
05:19:34,680 --> 05:19:35,680
but obviously we change the function
7596
05:19:36,540 --> 05:19:37,540
signature you could make this a u object
7597
05:19:39,298 --> 05:19:40,298
pointer I believe
7598
05:19:41,100 --> 05:19:42,100
and now what we can do is we can copy
7599
05:19:43,440 --> 05:19:44,440
this over
7600
05:19:44,340 --> 05:19:45,340
head back into our function declaration
7601
05:19:49,200 --> 05:19:50,200
and put that in
7602
05:19:51,540 --> 05:19:52,540
so now our error should go now if I go
7603
05:19:54,840 --> 05:19:55,840
ahead and actually run this
7604
05:19:58,500 --> 05:19:59,500
now if I head in to Blueprints and BP
7605
05:20:03,360 --> 05:20:04,360
object or here if I call test for
7606
05:20:07,020 --> 05:20:08,020
example I think it's called test as you
7607
05:20:10,200 --> 05:20:11,200
can see now we can operate on this truck
7608
05:20:12,180 --> 05:20:13,180
and for the context we can what we can
7609
05:20:15,900 --> 05:20:16,900
do is simply we can plug
7610
05:20:18,780 --> 05:20:19,780
any you know outer object in so I'll
7611
05:20:21,240 --> 05:20:22,240
just actually do that
7612
05:20:24,060 --> 05:20:25,060
so I'll open up the level blueprint so
7613
05:20:26,820 --> 05:20:27,820
for the context what we can do is we can
7614
05:20:29,458 --> 05:20:30,458
go ahead and
7615
05:20:31,080 --> 05:20:32,080
get a reference to sell
7616
05:20:33,240 --> 05:20:34,240
and for the Target what we would do is
7617
05:20:36,780 --> 05:20:37,780
we would go ahead and actually get a
7618
05:20:39,480 --> 05:20:40,480
struct so instead of this I'll just
7619
05:20:41,160 --> 05:20:42,160
create a struct
7620
05:20:42,660 --> 05:20:43,660
so I'll just call this truck for example
7621
05:20:46,020 --> 05:20:47,020
and it's going to be of type book
7622
05:20:50,160 --> 05:20:51,160
so we can use that and now this function
7623
05:20:52,920 --> 05:20:53,920
is going to operate on this truck
7624
05:20:55,860 --> 05:20:56,860
so this is just a basic way you can do
7625
05:20:57,780 --> 05:20:58,780
it now if I go ahead and press play
7626
05:20:59,340 --> 05:21:00,340
after three seconds you should see
7627
05:21:01,680 --> 05:21:02,680
something being printed test function
7628
05:21:03,780 --> 05:21:04,780
called
7629
05:21:04,620 --> 05:21:05,620
as you can see that works so that's
7630
05:21:07,260 --> 05:21:08,260
pretty much how we would handle struct
7631
05:21:09,240 --> 05:21:10,240
methods
7632
05:21:10,570 --> 05:21:11,570
[Music]
7633
05:21:15,060 --> 05:21:16,060
so that pretty much covers the basics of
7634
05:21:17,458 --> 05:21:18,458
using structs in unreal C plus plus now
7635
05:21:20,820 --> 05:21:21,820
the next thing is obviously enumerations
7636
05:21:23,360 --> 05:21:24,360
and that should be about it and then we
7637
05:21:26,820 --> 05:21:27,820
can start you know working with a little
7638
05:21:29,878 --> 05:21:30,878
more complicated things at the base
7639
05:21:32,458 --> 05:21:33,458
level enumerations in Blueprint and C
7640
05:21:35,400 --> 05:21:36,400
plus plus work the same but in order to
7641
05:21:37,920 --> 05:21:38,920
create them in C plus plus you can do
7642
05:21:40,020 --> 05:21:41,020
the same thing actually you can do enum
7643
05:21:42,540 --> 05:21:43,540
this one doesn't really need to have a
7644
05:21:44,580 --> 05:21:45,580
prefix by the way so for example let's
7645
05:21:47,100 --> 05:21:48,100
just say fruit
7646
05:21:49,520 --> 05:21:50,520
uh fruit list let's just call it
7647
05:21:53,660 --> 05:21:54,660
and inside that we can have our list
7648
05:21:56,580 --> 05:21:57,580
items so let's say we have apple
7649
05:21:59,638 --> 05:22:00,638
let's say we have our mango
7650
05:22:02,400 --> 05:22:03,400
and let's say we have a banana
7651
05:22:06,780 --> 05:22:07,780
stuff like that make sure I just end
7652
05:22:08,638 --> 05:22:09,638
everything with a comma
7653
05:22:10,680 --> 05:22:11,680
now again the same thing this is not
7654
05:22:15,060 --> 05:22:16,060
exactly exposed to blueprint but in
7655
05:22:18,360 --> 05:22:19,360
order to actually expose this you you
7656
05:22:20,100 --> 05:22:21,100
use the same
7657
05:22:21,480 --> 05:22:22,480
specifier as your use struct but instead
7658
05:22:24,900 --> 05:22:25,900
you type in you enum
7659
05:22:26,760 --> 05:22:27,760
if you use the U in a macro and if you
7660
05:22:30,240 --> 05:22:31,240
add in the parameter blueprint type now
7661
05:22:33,780 --> 05:22:34,780
this would be usable in Blueprint but if
7662
05:22:37,138 --> 05:22:38,138
you wanted to give it a different you
7663
05:22:39,180 --> 05:22:40,180
know name for it in Blueprint so if you
7664
05:22:41,940 --> 05:22:42,940
wanted to give a display name to this
7665
05:22:43,740 --> 05:22:44,740
basically what you do is you'd use
7666
05:22:45,840 --> 05:22:46,840
another macro known as you meta and over
7667
05:22:48,900 --> 05:22:49,900
here you change display name equals and
7668
05:22:52,680 --> 05:22:53,680
you put in the string so in our case uh
7669
05:22:56,160 --> 05:22:57,160
let's just call this one apple
7670
05:22:59,900 --> 05:23:00,900
underscore underscore one maybe
7671
05:23:03,240 --> 05:23:04,240
so just for you just for me to
7672
05:23:06,900 --> 05:23:07,900
demonstrate that it works
7673
05:23:08,878 --> 05:23:09,878
now if I actually run the editor
7674
05:23:14,100 --> 05:23:15,100
and I can just go ahead into any
7675
05:23:16,260 --> 05:23:17,260
blueprint and I can operate on that so I
7676
05:23:18,900 --> 05:23:19,900
can say switch on whatever we call that
7677
05:23:22,080 --> 05:23:23,080
fruit list as you can see instead of
7678
05:23:24,718 --> 05:23:25,718
Apple it actually shows apple one and
7679
05:23:27,360 --> 05:23:28,360
mango and banana is just shown as this
7680
05:23:29,638 --> 05:23:30,638
generally what you do is you would
7681
05:23:32,218 --> 05:23:33,218
simply have the display name to just
7682
05:23:34,500 --> 05:23:35,500
display exactly what this list item was
7683
05:23:37,980 --> 05:23:38,980
so you would simply have this and you
7684
05:23:41,040 --> 05:23:42,040
would have mango over here
7685
05:23:43,020 --> 05:23:44,020
generally you would just leave it like
7686
05:23:44,580 --> 05:23:45,580
this
7687
05:23:46,378 --> 05:23:47,378
banana
7688
05:23:48,560 --> 05:23:49,560
so this is how you would go about doing
7689
05:23:51,420 --> 05:23:52,420
it
7690
05:23:53,120 --> 05:23:54,120
[Music]
7691
05:23:57,600 --> 05:23:58,600
now we have brushed through the basics
7692
05:23:59,940 --> 05:24:00,940
of Unreal Engine C plus plus of course
7693
05:24:02,638 --> 05:24:03,638
if you want to know what function calls
7694
05:24:04,798 --> 05:24:05,798
to use for your gameplay specific needs
7695
05:24:06,900 --> 05:24:07,900
you could refer the documentation and
7696
05:24:09,420 --> 05:24:10,420
later on when we actually take an
7697
05:24:11,218 --> 05:24:12,218
example we will look into some of the
7698
05:24:13,500 --> 05:24:14,500
common ones so it's not really that you
7699
05:24:15,660 --> 05:24:16,660
have to refer the docs for everything I
7700
05:24:17,458 --> 05:24:18,458
will be going through many of them now
7701
05:24:19,740 --> 05:24:20,740
over here let's actually do a quick
7702
05:24:21,958 --> 05:24:22,958
exercise let's try to translate this
7703
05:24:24,840 --> 05:24:25,840
into C plus plus now if you were to
7704
05:24:27,540 --> 05:24:28,540
notice this entire thing is actually
7705
05:24:31,860 --> 05:24:32,860
purely in Blueprint and let's say we
7706
05:24:34,440 --> 05:24:35,440
wanted our code to run faster or for
7707
05:24:36,360 --> 05:24:37,360
whatever reason we needed it to be in C
7708
05:24:38,400 --> 05:24:39,400
plus plus so let's actually go ahead and
7709
05:24:41,160 --> 05:24:42,160
translate that so it's really simple
7710
05:24:44,400 --> 05:24:45,400
uh let's start step by step
7711
05:24:47,100 --> 05:24:48,100
so we have our get player camera manager
7712
05:24:49,560 --> 05:24:50,560
function let's see which header file we
7713
05:24:52,798 --> 05:24:53,798
need so it says Target is gameplay
7714
05:24:55,020 --> 05:24:56,020
Statics right so this tells us that we
7715
05:24:58,020 --> 05:24:59,020
need gameplay static so if I head into
7716
05:25:00,240 --> 05:25:01,240
Chrome and if I type in gameplay Statics
7717
05:25:04,160 --> 05:25:05,160
poe4 or ue5
7718
05:25:06,900 --> 05:25:07,900
you see you actually get the
7719
05:25:09,120 --> 05:25:10,120
documentation page
7720
05:25:11,580 --> 05:25:12,580
so over here we can get access to which
7721
05:25:14,218 --> 05:25:15,218
header file we need so Kismet gameplay
7722
05:25:16,740 --> 05:25:17,740
statics.net so stuff like that let's
7723
05:25:18,480 --> 05:25:19,480
actually go about doing it now for the
7724
05:25:20,760 --> 05:25:21,760
cast node we need a C plus plus class
7725
05:25:23,218 --> 05:25:24,218
because all are C plus plus classes will
7726
05:25:26,700 --> 05:25:27,700
not have access to the blueprint classes
7727
05:25:28,680 --> 05:25:29,680
but all our blueprint classes will have
7728
05:25:31,080 --> 05:25:32,080
access to the C plus ones so you cannot
7729
05:25:33,660 --> 05:25:34,660
access a blueprint class from C plus so
7730
05:25:37,560 --> 05:25:38,560
that's one disadvantage
7731
05:25:39,840 --> 05:25:40,840
now let's go about doing this
7732
05:25:42,420 --> 05:25:43,420
so
7733
05:25:43,740 --> 05:25:44,740
I'm just showing you guys one example
7734
05:25:45,860 --> 05:25:46,860
obviously we will talk about a few of
7735
05:25:48,480 --> 05:25:49,480
the common ones such as spawning actors
7736
05:25:50,700 --> 05:25:51,700
and stuff which are really common
7737
05:25:53,638 --> 05:25:54,638
now let's start in the editor so let's
7738
05:25:56,940 --> 05:25:57,940
go ahead and actually create the classes
7739
05:26:00,420 --> 05:26:01,420
that we need so first of all we need a
7740
05:26:02,820 --> 05:26:03,820
base class for our BP character so go
7741
05:26:05,340 --> 05:26:06,340
head into tools new C plus plus class
7742
05:26:07,320 --> 05:26:08,320
character and call this one CPP
7743
05:26:10,378 --> 05:26:11,378
underscore character of course you can
7744
05:26:12,660 --> 05:26:13,660
name it descriptively if you wanted
7745
05:26:14,700 --> 05:26:15,700
create the class
7746
05:26:16,620 --> 05:26:17,620
head back in
7747
05:26:18,420 --> 05:26:19,420
and we need a couple more things
7748
05:26:20,400 --> 05:26:21,400
actually
7749
05:26:21,480 --> 05:26:22,480
so one thing that we need is the pickup
7750
05:26:24,180 --> 05:26:25,180
class itself so type in actor
7751
05:26:26,940 --> 05:26:27,940
and call this one
7752
05:26:29,218 --> 05:26:30,218
CPP pickup
7753
05:26:31,860 --> 05:26:32,860
all right
7754
05:26:33,000 --> 05:26:34,000
create the class
7755
05:26:41,940 --> 05:26:42,940
now what I want you guys to do is head
7756
05:26:44,340 --> 05:26:45,340
into BP pickup and over here under class
7757
05:26:47,638 --> 05:26:48,638
settings for the parent class I want you
7758
05:26:49,798 --> 05:26:50,798
guys to select CPP pickup
7759
05:26:52,740 --> 05:26:53,740
and over here as well I want you guys to
7760
05:26:55,560 --> 05:26:56,560
select BP CPP character so CPP
7761
05:26:59,120 --> 05:27:00,120
underscore character I want you guys to
7762
05:27:01,378 --> 05:27:02,378
select that now what this basically
7763
05:27:03,240 --> 05:27:04,240
means is that you are inheriting this BP
7764
05:27:06,360 --> 05:27:07,360
character class from CPP character so
7765
05:27:09,480 --> 05:27:10,480
everything that's there in CPP character
7766
05:27:11,458 --> 05:27:12,458
will also be there in VP character
7767
05:27:13,138 --> 05:27:14,138
basically this is your inheritance
7768
05:27:15,600 --> 05:27:16,600
now let's head back in let's just reload
7769
05:27:18,180 --> 05:27:19,180
this and I think we can close the editor
7770
05:27:19,980 --> 05:27:20,980
for now
7771
05:27:21,298 --> 05:27:22,298
or actually we might need that for
7772
05:27:23,280 --> 05:27:24,280
reference so let's actually open up the
7773
05:27:25,440 --> 05:27:26,440
character
7774
05:27:26,760 --> 05:27:27,760
so we need a camera manager and from our
7775
05:27:30,000 --> 05:27:31,000
header file we from our documentation we
7776
05:27:32,820 --> 05:27:33,820
know that we need this header file so
7777
05:27:35,040 --> 05:27:36,040
inside our character.h because that's
7778
05:27:37,260 --> 05:27:38,260
where we wrote it always when you're
7779
05:27:39,240 --> 05:27:40,240
including header files you need to do it
7780
05:27:41,100 --> 05:27:42,100
above the generator.h
7781
05:27:43,500 --> 05:27:44,500
so over here Kismet gameplay statics.h
7782
05:27:47,218 --> 05:27:48,218
and let's just uh do this in the public
7783
05:27:51,480 --> 05:27:52,480
section
7784
05:27:53,340 --> 05:27:54,340
and let's have a look so when we press
7785
05:27:55,860 --> 05:27:56,860
our left Mouse button we get the player
7786
05:27:57,600 --> 05:27:58,600
camera manager so let's try calling that
7787
05:27:59,760 --> 05:28:00,760
static function
7788
05:28:01,138 --> 05:28:02,138
so go ahead
7789
05:28:03,060 --> 05:28:04,060
let's actually create the function let's
7790
05:28:05,458 --> 05:28:06,458
call this one I don't know what do we
7791
05:28:07,378 --> 05:28:08,378
call this
7792
05:28:09,120 --> 05:28:10,120
so we're just tracing and destroying so
7793
05:28:11,400 --> 05:28:12,400
let's call this one
7794
05:28:13,080 --> 05:28:14,080
remove pickup or something so avoid
7795
05:28:15,560 --> 05:28:16,560
remove pickup
7796
05:28:18,660 --> 05:28:19,660
all right we don't really require any
7797
05:28:20,458 --> 05:28:21,458
parameters
7798
05:28:21,718 --> 05:28:22,718
now let's go ahead and create a
7799
05:28:23,280 --> 05:28:24,280
definition for it
7800
05:28:25,378 --> 05:28:26,378
so whoops let's just head in and it has
7801
05:28:29,820 --> 05:28:30,820
created the definition for us
7802
05:28:33,360 --> 05:28:34,360
so let's go ahead and get that that's a
7803
05:28:35,760 --> 05:28:36,760
static function so you gameplay Statics
7804
05:28:40,440 --> 05:28:41,440
get player camera manager
7805
05:28:45,060 --> 05:28:46,060
and over here what we can do is for the
7806
05:28:47,820 --> 05:28:48,820
world context object since this is an
7807
05:28:49,798 --> 05:28:50,798
actor characters are actors so you can
7808
05:28:52,138 --> 05:28:53,138
just use this generally you just use
7809
05:28:54,420 --> 05:28:55,420
this and player index as 0 since we have
7810
05:28:56,340 --> 05:28:57,340
only one controller per screen
7811
05:28:59,340 --> 05:29:00,340
so we got the camera manager and from
7812
05:29:02,040 --> 05:29:03,040
this we need the actor location as well
7813
05:29:04,620 --> 05:29:05,620
as the forward vector so what we do is
7814
05:29:08,160 --> 05:29:09,160
let's actually just store it in a
7815
05:29:09,958 --> 05:29:10,958
temporary variable so we can type Auto
7816
05:29:11,820 --> 05:29:12,820
Temp equals
7817
05:29:13,560 --> 05:29:14,560
and we can store this in a variable and
7818
05:29:16,200 --> 05:29:17,200
what you can do is we can go ahead and
7819
05:29:18,958 --> 05:29:19,958
get the actor location
7820
05:29:21,000 --> 05:29:22,000
so this is a pointer again so temp
7821
05:29:25,138 --> 05:29:26,138
with the pointer operator we can get the
7822
05:29:28,320 --> 05:29:29,320
actor location
7823
05:29:30,900 --> 05:29:31,900
we have forward Vector here let's do
7824
05:29:32,580 --> 05:29:33,580
that as well
7825
05:29:34,040 --> 05:29:35,040
and temp
7826
05:29:36,480 --> 05:29:37,480
get actor location now this might
7827
05:29:40,200 --> 05:29:41,200
actually warn us right now uh to use the
7828
05:29:44,160 --> 05:29:45,160
get camera location function so as you
7829
05:29:46,320 --> 05:29:47,320
can see use get camera location instead
7830
05:29:49,798 --> 05:29:50,798
so get camera location
7831
05:29:52,138 --> 05:29:53,138
just spell that correctly and now we
7832
05:29:54,718 --> 05:29:55,718
have access to these locations
7833
05:29:58,020 --> 05:29:59,020
and what we are doing is we are
7834
05:30:00,298 --> 05:30:01,298
basically plugging this into the line
7835
05:30:02,100 --> 05:30:03,100
Trace
7836
05:30:03,240 --> 05:30:04,240
so what I can do right now over here to
7837
05:30:05,520 --> 05:30:06,520
simplify things is we have a forward
7838
05:30:07,378 --> 05:30:08,378
vector
7839
05:30:09,120 --> 05:30:10,120
we grab that in
7840
05:30:11,280 --> 05:30:12,280
and we multiplied by a float
7841
05:30:14,638 --> 05:30:15,638
so the operator is already overloaded so
7842
05:30:17,520 --> 05:30:18,520
we multiply that by 50 000 in our case
7843
05:30:20,340 --> 05:30:21,340
so let's just do that
7844
05:30:22,620 --> 05:30:23,620
and if we head back into our blueprint
7845
05:30:25,080 --> 05:30:26,080
so we add that to our camera location
7846
05:30:29,340 --> 05:30:30,340
so plus our camera location so you could
7847
05:30:32,160 --> 05:30:33,160
just do a plus again
7848
05:30:34,080 --> 05:30:35,080
so plus our camera location we can put
7849
05:30:37,138 --> 05:30:38,138
these in parentheses just to be a little
7850
05:30:39,780 --> 05:30:40,780
more clear on what we're actually doing
7851
05:30:42,240 --> 05:30:43,240
so we can delete this line
7852
05:30:44,400 --> 05:30:45,400
we have that next what we have is our
7853
05:30:47,820 --> 05:30:48,820
line Trace so if you just hover over
7854
05:30:49,440 --> 05:30:50,440
this you see it says Target is gizmit
7855
05:30:52,320 --> 05:30:53,320
system library and I know this header
7856
05:30:55,138 --> 05:30:56,138
file so I'll just do it for you guys
7857
05:30:57,600 --> 05:30:58,600
anyways uh what we are doing is going to
7858
05:30:59,940 --> 05:31:00,940
be correct so let's close this up
7859
05:31:02,820 --> 05:31:03,820
so it's going to be Kismet Kismet system
7860
05:31:05,160 --> 05:31:06,160
Library you could have a look at the
7861
05:31:06,660 --> 05:31:07,660
documentation as well
7862
05:31:08,638 --> 05:31:09,638
so Kismet
7863
05:31:10,440 --> 05:31:11,440
Kismet system Library
7864
05:31:14,878 --> 05:31:15,878
and if we include that our error should
7865
05:31:16,740 --> 05:31:17,740
go and if I open up the CPP file once
7866
05:31:19,920 --> 05:31:20,920
again
7867
05:31:20,638 --> 05:31:21,638
now we should be able to call the line
7868
05:31:23,100 --> 05:31:24,100
Trace function so you Kismet system
7869
05:31:26,040 --> 05:31:27,040
Library
7870
05:31:27,840 --> 05:31:28,840
line Trace if I do that I should find
7871
05:31:30,718 --> 05:31:31,718
line Trace single
7872
05:31:33,120 --> 05:31:34,120
and for the parameters we have a bunch
7873
05:31:35,580 --> 05:31:36,580
of them so first one is the world
7874
05:31:37,740 --> 05:31:38,740
context object which is going to be this
7875
05:31:39,900 --> 05:31:40,900
again and next we have the start and the
7876
05:31:43,020 --> 05:31:44,020
end location we look into all of that so
7877
05:31:45,660 --> 05:31:46,660
this
7878
05:31:47,760 --> 05:31:48,760
and our start location is going to be
7879
05:31:50,820 --> 05:31:51,820
our camera location
7880
05:31:52,500 --> 05:31:53,500
so what we can do is we can actually
7881
05:31:54,718 --> 05:31:55,718
store this in a variable right now
7882
05:31:58,378 --> 05:31:59,378
so what we can do is we can type in auto
7883
05:32:02,400 --> 05:32:03,400
camera location
7884
05:32:04,740 --> 05:32:05,740
equals
7885
05:32:06,298 --> 05:32:07,298
get camera location
7886
05:32:09,840 --> 05:32:10,840
now for the start we can go ahead and
7887
05:32:12,180 --> 05:32:13,180
type in camera location
7888
05:32:14,580 --> 05:32:15,580
and then we have our end so again we can
7889
05:32:18,000 --> 05:32:19,000
store this in another variable so Auto
7890
05:32:21,600 --> 05:32:22,600
End Lock location or let's just call
7891
05:32:23,820 --> 05:32:24,820
this one end
7892
05:32:25,020 --> 05:32:26,020
equals
7893
05:32:26,700 --> 05:32:27,700
whatever calculation we just did right
7894
05:32:28,980 --> 05:32:29,980
there so
7895
05:32:30,540 --> 05:32:31,540
end and is what we called it then the
7896
05:32:34,620 --> 05:32:35,620
next parameter we have is a trace type
7897
05:32:36,900 --> 05:32:37,900
query which is the trace channel so this
7898
05:32:39,240 --> 05:32:40,240
is what you see over here
7899
05:32:41,280 --> 05:32:42,280
now over here uh this is a little bit
7900
05:32:44,878 --> 05:32:45,878
peculiar in C plus plus so if I just do
7901
05:32:47,340 --> 05:32:48,340
e Trace type query
7902
05:32:49,798 --> 05:32:50,798
so e Trace type query
7903
05:32:54,240 --> 05:32:55,240
and if I take a look you get something
7904
05:32:56,160 --> 05:32:57,160
like one two three so on basically these
7905
05:32:59,760 --> 05:33:00,760
are what you define in the project
7906
05:33:01,980 --> 05:33:02,980
settings so if I actually head into my
7907
05:33:03,958 --> 05:33:04,958
project settings and just type in Trace
7908
05:33:07,200 --> 05:33:08,200
you would be able to see that you get
7909
05:33:09,360 --> 05:33:10,360
Trace channels by default we actually
7910
05:33:12,240 --> 05:33:13,240
get to uh that is visibility and camera
7911
05:33:15,240 --> 05:33:16,240
so if we just do a trace type query one
7912
05:33:18,540 --> 05:33:19,540
that is going to be your visibility and
7913
05:33:21,180 --> 05:33:22,180
then if we take a look we have a Boolean
7914
05:33:23,160 --> 05:33:24,160
for dress complex we don't really want
7915
05:33:25,138 --> 05:33:26,138
to dress for complex collisions here so
7916
05:33:27,120 --> 05:33:28,120
let's just do 0 or that is false
7917
05:33:30,138 --> 05:33:31,138
and over here we have a parameter which
7918
05:33:33,958 --> 05:33:34,958
we actually don't need and we also have
7919
05:33:38,040 --> 05:33:39,040
a few more I guess we'll just use the
7920
05:33:40,500 --> 05:33:41,500
ones which we absolutely need so actors
7921
05:33:43,080 --> 05:33:44,080
to ignore we can just create an empty
7922
05:33:45,540 --> 05:33:46,540
area and we can just pass that in so
7923
05:33:48,660 --> 05:33:49,660
tra
7924
05:33:50,120 --> 05:33:51,120
actor pointer
7925
05:33:53,458 --> 05:33:54,458
and I will get to TRS don't worry
7926
05:33:55,620 --> 05:33:56,620
basically this is like your STD Vector
7927
05:33:58,560 --> 05:33:59,560
in standard C plus plus uh instead of
7928
05:34:01,980 --> 05:34:02,980
that the one used in unreal is called
7929
05:34:03,900 --> 05:34:04,900
tra so all the same functions exist
7930
05:34:06,600 --> 05:34:07,600
inside this as well instead of dot size
7931
05:34:09,120 --> 05:34:10,120
you have you know dot num there are a
7932
05:34:12,000 --> 05:34:13,000
few names which have changed but it this
7933
05:34:14,580 --> 05:34:15,580
is pretty much like your STD vector and
7934
05:34:17,458 --> 05:34:18,458
let's just call this one ignore
7935
05:34:20,878 --> 05:34:21,878
and we'll just pass that in so ignore
7936
05:34:24,718 --> 05:34:25,718
and the next parameter is uh e draw
7937
05:34:29,400 --> 05:34:30,400
debug Trace so basically whether you
7938
05:34:32,400 --> 05:34:33,400
want to see the line trace or not so we
7939
05:34:35,160 --> 05:34:36,160
draw
7940
05:34:37,320 --> 05:34:38,320
debug Trace
7941
05:34:41,218 --> 05:34:42,218
whoops
7942
05:34:43,878 --> 05:34:44,878
and over here we have for duration for
7943
05:34:47,280 --> 05:34:48,280
one frame persistent uh let's keep that
7944
05:34:49,980 --> 05:34:50,980
for duration for now
7945
05:34:53,040 --> 05:34:54,040
all right
7946
05:34:54,680 --> 05:34:55,680
once that is done we have our head
7947
05:34:57,420 --> 05:34:58,420
result which we are going to Output so
7948
05:34:59,940 --> 05:35:00,940
we'll just create another variable so if
7949
05:35:02,040 --> 05:35:03,040
hit result
7950
05:35:05,400 --> 05:35:06,400
and we'll call this one
7951
05:35:07,560 --> 05:35:08,560
hit or out hit or whatever
7952
05:35:10,620 --> 05:35:11,620
and what we can do is we can just pass
7953
05:35:12,718 --> 05:35:13,718
hit over here and once we have our hit
7954
05:35:15,360 --> 05:35:16,360
result we have B ignore self yeah we
7955
05:35:17,700 --> 05:35:18,700
want to ignore ourselves
7956
05:35:19,760 --> 05:35:20,760
and don't really need the dress color
7957
05:35:24,080 --> 05:35:25,080
because this has a default value so
7958
05:35:27,660 --> 05:35:28,660
that's about it basically
7959
05:35:29,700 --> 05:35:30,700
so we can go ahead and close this
7960
05:35:32,458 --> 05:35:33,458
so I feel these parameters should be
7961
05:35:34,620 --> 05:35:35,620
enough and once this function is
7962
05:35:36,958 --> 05:35:37,958
completed we should have access to
7963
05:35:38,820 --> 05:35:39,820
everything that we can possibly think of
7964
05:35:41,400 --> 05:35:42,400
so the first thing uh that we are going
7965
05:35:44,040 --> 05:35:45,040
to do is we are going to cast it to the
7966
05:35:45,780 --> 05:35:46,780
pickup
7967
05:35:46,740 --> 05:35:47,740
now in order for us to work with this
7968
05:35:49,500 --> 05:35:50,500
first of all we need to include the
7969
05:35:51,420 --> 05:35:52,420
header file so hash include
7970
05:35:53,760 --> 05:35:54,760
because we don't know what CPP pickup is
7971
05:35:56,400 --> 05:35:57,400
so we'll just do
7972
05:35:58,860 --> 05:35:59,860
CPP
7973
05:36:00,240 --> 05:36:01,240
ickup.h
7974
05:36:02,638 --> 05:36:03,638
so this should compile because it is in
7975
05:36:04,920 --> 05:36:05,920
the same folder and once we actually
7976
05:36:06,958 --> 05:36:07,958
include the file what we can do is we
7977
05:36:08,638 --> 05:36:09,638
can simply cast it now you won't use a
7978
05:36:11,458 --> 05:36:12,458
dynamic cast here unreal actually has
7979
05:36:13,740 --> 05:36:14,740
some things built in for us
7980
05:36:16,020 --> 05:36:17,020
so we can get our hit
7981
05:36:18,958 --> 05:36:19,958
so if
7982
05:36:20,878 --> 05:36:21,878
hit
7983
05:36:23,060 --> 05:36:24,060
dot actor dot get actor
7984
05:36:27,540 --> 05:36:28,540
if this is valid now at this point if we
7985
05:36:32,160 --> 05:36:33,160
haven't actually hit any actor with our
7986
05:36:34,200 --> 05:36:35,200
line Trace basically this if is going to
7987
05:36:37,138 --> 05:36:38,138
be false and we are not going to execute
7988
05:36:39,298 --> 05:36:40,298
this code however if we have hit the
7989
05:36:41,580 --> 05:36:42,580
actor we can go ahead and cast it to our
7990
05:36:43,378 --> 05:36:44,378
pickup so if we can go ahead and cast it
7991
05:36:46,080 --> 05:36:47,080
so this is going to be acpp pickup this
7992
05:36:49,320 --> 05:36:50,320
is how you cast in unreal C plus plus
7993
05:36:51,900 --> 05:36:52,900
basically you have a cast function and
7994
05:36:54,718 --> 05:36:55,718
over here we can just pass in the actor
7995
05:36:57,840 --> 05:36:58,840
so if this actor is valid so again the
7996
05:37:00,840 --> 05:37:01,840
pointer is going to be pointing to an
7997
05:37:03,120 --> 05:37:04,120
actor if it is actually valid in that
7998
05:37:05,760 --> 05:37:06,760
case what we can do is we can go ahead
7999
05:37:07,680 --> 05:37:08,680
and destroy this actor so hit not get
8000
05:37:10,260 --> 05:37:11,260
actor and we can call the destroy
8001
05:37:12,660 --> 05:37:13,660
function
8002
05:37:14,218 --> 05:37:15,218
that's about it and just to make sure
8003
05:37:18,480 --> 05:37:19,480
what we can do is we can just print it
8004
05:37:20,400 --> 05:37:21,400
so UK is mid system Library
8005
05:37:23,520 --> 05:37:24,520
print string and over here we can just
8006
05:37:26,400 --> 05:37:27,400
pass in this instead for the world
8007
05:37:28,080 --> 05:37:29,080
context object and we can print
8008
05:37:30,560 --> 05:37:31,560
destroyed a pickup
8009
05:37:34,440 --> 05:37:35,440
and we can go ahead and terminate that
8010
05:37:37,200 --> 05:37:38,200
so now in order for us to actually be
8011
05:37:40,020 --> 05:37:41,020
able to call this from blueprint uh
8012
05:37:42,480 --> 05:37:43,480
we'll set up input and stuff a bit later
8013
05:37:44,400 --> 05:37:45,400
in Blueprint it has a couple of extra
8014
05:37:46,560 --> 05:37:47,560
steps so in order to expose this to
8015
05:37:49,500 --> 05:37:50,500
blueprint field again use a u function
8016
05:37:51,298 --> 05:37:52,298
and make this one blueprint callable
8017
05:37:54,298 --> 05:37:55,298
make sure I get the case right
8018
05:37:57,900 --> 05:37:58,900
and just indent that and now if I go
8019
05:38:00,780 --> 05:38:01,780
ahead and close my editor and run a
8020
05:38:03,120 --> 05:38:04,120
debugger now
8021
05:38:04,378 --> 05:38:05,378
the editor should load up and if we open
8022
05:38:07,320 --> 05:38:08,320
up our character we can get rid of all
8023
05:38:09,900 --> 05:38:10,900
this code and I don't know what we call
8024
05:38:11,940 --> 05:38:12,940
this so we called it remove pickup I
8025
05:38:14,100 --> 05:38:15,100
don't even know why we call this but we
8026
05:38:16,320 --> 05:38:17,320
can call remove pickup
8027
05:38:18,718 --> 05:38:19,718
remove pickup now if I go ahead and
8028
05:38:21,660 --> 05:38:22,660
press play
8029
05:38:22,680 --> 05:38:23,680
and if I left click as you can see
8030
05:38:25,798 --> 05:38:26,798
our logic actually works
8031
05:38:28,500 --> 05:38:29,500
and okay this is not a pickup this was
8032
05:38:30,480 --> 05:38:31,480
just a cube so that's the reason it
8033
05:38:32,218 --> 05:38:33,218
didn't work
8034
05:38:33,420 --> 05:38:34,420
but anyways the line Trace works
8035
05:38:37,740 --> 05:38:38,740
now the reason it's working is because
8036
05:38:39,780 --> 05:38:40,780
BP pickup is also a CPP pickup because
8037
05:38:42,958 --> 05:38:43,958
we inherited from it so that's the
8038
05:38:45,120 --> 05:38:46,120
reason what's happening is when we
8039
05:38:46,740 --> 05:38:47,740
actually cast it over here uh we are
8040
05:38:49,980 --> 05:38:50,980
actually
8041
05:38:51,060 --> 05:38:52,060
successfully casting to our CPP pickup
8042
05:38:54,600 --> 05:38:55,600
as well even though that was a BP pickup
8043
05:38:56,780 --> 05:38:57,780
so that's basically how we translate it
8044
05:39:00,360 --> 05:39:01,360
now we can go ahead and clear out some
8045
05:39:02,638 --> 05:39:03,638
stuff this was just for clarity so
8046
05:39:05,360 --> 05:39:06,360
instead of using the camera location as
8047
05:39:08,700 --> 05:39:09,700
a separate variable we can go ahead and
8048
05:39:10,320 --> 05:39:11,320
copy the server
8049
05:39:12,360 --> 05:39:13,360
similarly for n we could just do the
8050
05:39:14,700 --> 05:39:15,700
same
8051
05:39:16,020 --> 05:39:17,020
and
8052
05:39:18,060 --> 05:39:19,060
if we have anything else we could do
8053
05:39:20,040 --> 05:39:21,040
that as well so we don't have anything
8054
05:39:21,480 --> 05:39:22,480
else we can go ahead and close this up
8055
05:39:25,680 --> 05:39:26,680
we'll we'll leave this temp variable
8056
05:39:28,260 --> 05:39:29,260
because having such a long line
8057
05:39:30,480 --> 05:39:31,480
everywhere is going to be a little bit
8058
05:39:32,878 --> 05:39:33,878
weird but again you could you could do
8059
05:39:35,520 --> 05:39:36,520
this so you could just place this
8060
05:39:37,740 --> 05:39:38,740
instead of temp wherever temp is going
8061
05:39:39,958 --> 05:39:40,958
to be there you could go ahead and
8062
05:39:43,020 --> 05:39:44,020
get the player camera manager and do
8063
05:39:45,298 --> 05:39:46,298
that but in this case actually using
8064
05:39:47,400 --> 05:39:48,400
temp would be a better solution so we'll
8065
05:39:49,740 --> 05:39:50,740
just stick with using temp
8066
05:39:52,540 --> 05:39:53,540
[Music]
8067
05:39:56,940 --> 05:39:57,940
so we have brushed through quite a bit
8068
05:39:59,340 --> 05:40:00,340
regarding C plus plus and as we create
8069
05:40:02,280 --> 05:40:03,280
stuff we will go through more things now
8070
05:40:05,540 --> 05:40:06,540
what if apart from a pickup we also
8071
05:40:09,180 --> 05:40:10,180
needed to cast some other thing so let's
8072
05:40:11,638 --> 05:40:12,638
say let's actually create another actor
8073
05:40:13,740 --> 05:40:14,740
so let's do it with our interaction
8074
05:40:15,480 --> 05:40:16,480
actor itself so let's go ahead and open
8075
05:40:18,120 --> 05:40:19,120
it up not sure why we've used it so
8076
05:40:20,160 --> 05:40:21,160
let's just hit Ctrl f to find and let's
8077
05:40:24,060 --> 05:40:25,060
just find interaction
8078
05:40:29,820 --> 05:40:30,820
so
8079
05:40:32,458 --> 05:40:33,458
so we are basically nudging it so what
8080
05:40:35,580 --> 05:40:36,580
are you basically doing is we are again
8081
05:40:37,920 --> 05:40:38,920
casting so I have to just check where it
8082
05:40:40,620 --> 05:40:41,620
is
8083
05:40:41,760 --> 05:40:42,760
so if we are overlapping so that's what
8084
05:40:44,400 --> 05:40:45,400
we are doing
8085
05:40:45,600 --> 05:40:46,600
so let's actually remove this logic and
8086
05:40:47,760 --> 05:40:48,760
let's actually have the destroy logic
8087
05:40:49,620 --> 05:40:50,620
itself
8088
05:40:50,820 --> 05:40:51,820
so remove this
8089
05:40:52,500 --> 05:40:53,500
and remove this or actually we could
8090
05:40:54,360 --> 05:40:55,360
keep this
8091
05:40:56,340 --> 05:40:57,340
now if you wanted to do it with your
8092
05:40:58,500 --> 05:40:59,500
cast so what you would have to do is you
8093
05:41:00,600 --> 05:41:01,600
have to cast to interaction actor
8094
05:41:05,700 --> 05:41:06,700
if this fails and then destroy it and
8095
05:41:09,000 --> 05:41:10,000
this for the most part will work
8096
05:41:12,540 --> 05:41:13,540
so let me just go ahead and drag that in
8097
05:41:15,060 --> 05:41:16,060
forget about the C plus plus logic
8098
05:41:18,000 --> 05:41:19,000
and as you can see this works and even
8099
05:41:21,060 --> 05:41:22,060
this works
8100
05:41:22,320 --> 05:41:23,320
however one thing you might notice is
8101
05:41:25,378 --> 05:41:26,378
let's say in an actual game obviously
8102
05:41:27,480 --> 05:41:28,480
we'll have many such actors not just an
8103
05:41:30,240 --> 05:41:31,240
interaction and a pickup actor
8104
05:41:32,340 --> 05:41:33,340
so in that case
8105
05:41:34,620 --> 05:41:35,620
you will have to perform many cars and
8106
05:41:37,500 --> 05:41:38,500
casting is expensive for your computer's
8107
05:41:40,980 --> 05:41:41,980
performance
8108
05:41:42,240 --> 05:41:43,240
so the way you get around this is
8109
05:41:44,040 --> 05:41:45,040
instead of casting multiple times you
8110
05:41:46,378 --> 05:41:47,378
could cast to an interface
8111
05:41:48,480 --> 05:41:49,480
and in unreal blueprint there's actually
8112
05:41:51,480 --> 05:41:52,480
a very elegant system implemented we'll
8113
05:41:54,958 --> 05:41:55,958
be talking about both the blueprint and
8114
05:41:56,820 --> 05:41:57,820
C plus versions of interfaces now
8115
05:41:59,638 --> 05:42:00,638
so in order to handle this problem
8116
05:42:02,400 --> 05:42:03,400
what we can do is we can actually create
8117
05:42:06,060 --> 05:42:07,060
an interface so I'll show you guys step
8118
05:42:08,280 --> 05:42:09,280
by step to implement this exact logic uh
8119
05:42:11,878 --> 05:42:12,878
using an interface and we can actually
8120
05:42:14,580 --> 05:42:15,580
have separate logic as well for both the
8121
05:42:16,860 --> 05:42:17,860
interaction and the pickup Factor
8122
05:42:19,378 --> 05:42:20,378
so head into your blueprints right click
8123
05:42:21,660 --> 05:42:22,660
blueprints blueprint interface and let's
8124
05:42:24,480 --> 05:42:25,480
just call this one I don't know destruct
8125
05:42:27,060 --> 05:42:28,060
I guess
8126
05:42:28,560 --> 05:42:29,560
uh generally I have a Convention of
8127
05:42:31,440 --> 05:42:32,440
calling it BPI underscore
8128
05:42:34,920 --> 05:42:35,920
and we can call this one
8129
05:42:38,218 --> 05:42:39,218
destruct pickup Maybe
8130
05:42:42,540 --> 05:42:43,540
all right and we don't need anything for
8131
05:42:45,660 --> 05:42:46,660
the input
8132
05:42:47,400 --> 05:42:48,400
but anyways now the way you actually use
8133
05:42:50,520 --> 05:42:51,520
this is for whichever actor that needs
8134
05:42:54,180 --> 05:42:55,180
to be casted to so for example we are
8135
05:42:56,458 --> 05:42:57,458
casting to our pickup and our
8136
05:42:58,378 --> 05:42:59,378
interaction actor so we would head into
8137
05:43:00,600 --> 05:43:01,600
both of these and under your class
8138
05:43:03,000 --> 05:43:04,000
settings under implemented interfaces we
8139
05:43:06,060 --> 05:43:07,060
can go ahead and Implement BPI destruct
8140
05:43:10,980 --> 05:43:11,980
and do the same thing for the
8141
05:43:12,718 --> 05:43:13,718
interaction actor head into class
8142
05:43:14,280 --> 05:43:15,280
settings
8143
05:43:15,440 --> 05:43:16,440
DPI destruct
8144
05:43:17,660 --> 05:43:18,660
basically at at the fundamental level
8145
05:43:21,240 --> 05:43:22,240
what this is doing is it is inheriting
8146
05:43:25,200 --> 05:43:26,200
this interface along with actor so
8147
05:43:27,600 --> 05:43:28,600
basically your interface is also class
8148
05:43:29,580 --> 05:43:30,580
internally in C plus plus I will show
8149
05:43:31,980 --> 05:43:32,980
you guys the C plus plus version which
8150
05:43:34,260 --> 05:43:35,260
will make things a little more clear
8151
05:43:36,298 --> 05:43:37,298
but instead of doing all this what we
8152
05:43:38,820 --> 05:43:39,820
can do is we can call destruct
8153
05:43:43,378 --> 05:43:44,378
or I guess I call it pickup so let's
8154
05:43:45,660 --> 05:43:46,660
just call it destruct in general
8155
05:43:48,360 --> 05:43:49,360
to compile and save that so we call this
8156
05:43:51,000 --> 05:43:52,000
destruct
8157
05:43:52,080 --> 05:43:53,080
and now if I actually go ahead and press
8158
05:43:55,378 --> 05:43:56,378
play I mean nothing's going to happen
8159
05:43:57,360 --> 05:43:58,360
because
8160
05:43:58,500 --> 05:43:59,500
although we have destruct as you can see
8161
05:44:00,900 --> 05:44:01,900
we can't really Define the logic here
8162
05:44:02,760 --> 05:44:03,760
the way you define the logic is for
8163
05:44:05,638 --> 05:44:06,638
example we can head into pickup under
8164
05:44:07,980 --> 05:44:08,980
interfaces right click Implement event
8165
05:44:11,760 --> 05:44:12,760
and if I go ahead and just print a
8166
05:44:13,620 --> 05:44:14,620
string and I can type in
8167
05:44:15,798 --> 05:44:16,798
destructing pickup
8168
05:44:19,020 --> 05:44:20,020
and if I go ahead and destroy it so
8169
05:44:21,958 --> 05:44:22,958
destroy actor and Target will be self
8170
05:44:24,660 --> 05:44:25,660
and I'll do the same for the interaction
8171
05:44:26,940 --> 05:44:27,940
actor so implement this event oops
8172
05:44:30,600 --> 05:44:31,600
paste this in and we can do destructing
8173
05:44:33,600 --> 05:44:34,600
whatever this is
8174
05:44:35,280 --> 05:44:36,280
interaction after
8175
05:44:39,600 --> 05:44:40,600
so now you should be able to see that
8176
05:44:42,958 --> 05:44:43,958
both of these different implementations
8177
05:44:45,058 --> 05:44:46,058
are actually called so if I press play
8178
05:44:49,080 --> 05:44:50,080
you see our pickup is destroyed and if I
8179
05:44:52,200 --> 05:44:53,200
actually click on this side our
8180
05:44:55,020 --> 05:44:56,020
interaction actors also destroyed
8181
05:44:57,840 --> 05:44:58,840
so this is how you basically use
8182
05:44:59,400 --> 05:45:00,400
interfaces instead of casting basically
8183
05:45:02,520 --> 05:45:03,520
what it's doing internally even though
8184
05:45:05,400 --> 05:45:06,400
this looks like we got rid of casting is
8185
05:45:07,500 --> 05:45:08,500
instead of casting to our interaction
8186
05:45:10,200 --> 05:45:11,200
actor it casts to the interface because
8187
05:45:13,500 --> 05:45:14,500
interaction actor implements that
8188
05:45:15,660 --> 05:45:16,660
interface the cast is going to succeed
8189
05:45:17,760 --> 05:45:18,760
and the function will be executed
8190
05:45:20,280 --> 05:45:21,280
the situation where the cast fails is
8191
05:45:22,798 --> 05:45:23,798
automatically handled in the engine
8192
05:45:25,138 --> 05:45:26,138
now how do you do the same exact thing
8193
05:45:27,360 --> 05:45:28,360
in C plus plus you may ask it's pretty
8194
05:45:31,200 --> 05:45:32,200
simple actually you just use the concept
8195
05:45:33,360 --> 05:45:34,360
of multiple inheritance in C plus plus
8196
05:45:36,180 --> 05:45:37,180
so tools
8197
05:45:38,140 --> 05:45:39,140
[Music]
8198
05:45:42,718 --> 05:45:43,718
create a new C plus plus class and over
8199
05:45:46,378 --> 05:45:47,378
here what you have to do is Select
8200
05:45:48,360 --> 05:45:49,360
unreal interface
8201
05:45:50,218 --> 05:45:51,218
and we can just call this my interface
8202
05:45:52,558 --> 05:45:53,558
for example and create the class
8203
05:45:54,660 --> 05:45:55,660
it should load up visual studio for you
8204
05:45:59,760 --> 05:46:00,760
so just reload that and over here you
8205
05:46:03,660 --> 05:46:04,660
should be able to see my interface.h and
8206
05:46:06,420 --> 05:46:07,420
my interface.cpp basically this is where
8207
05:46:09,540 --> 05:46:10,540
you would write the function definitions
8208
05:46:11,340 --> 05:46:12,340
and you can go ahead and Define it in
8209
05:46:14,400 --> 05:46:15,400
your various classes
8210
05:46:16,200 --> 05:46:17,200
so what you do is for example let's just
8211
05:46:20,340 --> 05:46:21,340
have
8212
05:46:21,798 --> 05:46:22,798
this function
8213
05:46:23,958 --> 05:46:24,958
work for both the pickup and you know
8214
05:46:27,958 --> 05:46:28,958
our
8215
05:46:29,700 --> 05:46:30,700
whatever that was interaction actor so
8216
05:46:32,700 --> 05:46:33,700
let's say we want this function to work
8217
05:46:35,100 --> 05:46:36,100
for both of them so let's go ahead and
8218
05:46:36,780 --> 05:46:37,780
do that using an interface we'll
8219
05:46:38,520 --> 05:46:39,520
actually get rid of the C plus plus
8220
05:46:40,260 --> 05:46:41,260
logic
8221
05:46:42,780 --> 05:46:43,780
so we'll get rid of that
8222
05:46:44,878 --> 05:46:45,878
and what we got to do is first of all uh
8223
05:46:48,540 --> 05:46:49,540
since we are actually casting to the
8224
05:46:50,218 --> 05:46:51,218
interface here we can go ahead and
8225
05:46:52,378 --> 05:46:53,378
include the header for that so hash
8226
05:46:54,420 --> 05:46:55,420
include
8227
05:46:56,458 --> 05:46:57,458
over here uh we can go okay we are
8228
05:46:59,040 --> 05:47:00,040
including pickup already so what we can
8229
05:47:01,620 --> 05:47:02,620
go ahead and do is we can go ahead and
8230
05:47:04,798 --> 05:47:05,798
include this interface in the pickup
8231
05:47:07,378 --> 05:47:08,378
so not after a generated before the
8232
05:47:10,138 --> 05:47:11,138
generated dot h
8233
05:47:11,760 --> 05:47:12,760
and this is going to be
8234
05:47:14,160 --> 05:47:15,160
my
8235
05:47:15,958 --> 05:47:16,958
interface dot h
8236
05:47:19,138 --> 05:47:20,138
and over here where you see public a
8237
05:47:21,958 --> 05:47:22,958
actor
8238
05:47:22,980 --> 05:47:23,980
I put in a comma and type in public
8239
05:47:26,040 --> 05:47:27,040
I my interface
8240
05:47:28,740 --> 05:47:29,740
I is basically the prefix which is used
8241
05:47:31,138 --> 05:47:32,138
for interfaces just remember that
8242
05:47:34,020 --> 05:47:35,020
so my interface in the editor is going
8243
05:47:37,080 --> 05:47:38,080
to correspond to IMI interface in C plus
8244
05:47:41,100 --> 05:47:42,100
so let's actually write our function so
8245
05:47:43,740 --> 05:47:44,740
let's call this void disrupt Maybe
8246
05:47:50,218 --> 05:47:51,218
and we can go ahead and add in our
8247
05:47:52,620 --> 05:47:53,620
implementations
8248
05:47:54,058 --> 05:47:55,058
so we can right click first of all
8249
05:47:57,120 --> 05:47:58,120
and
8250
05:47:58,920 --> 05:47:59,920
make this one virtual
8251
05:48:04,798 --> 05:48:05,798
right click
8252
05:48:06,420 --> 05:48:07,420
actions
8253
05:48:07,980 --> 05:48:08,980
create a definition for it
8254
05:48:10,620 --> 05:48:11,620
this is just going to be like your
8255
05:48:13,798 --> 05:48:14,798
default implementation
8256
05:48:19,558 --> 05:48:20,558
so now let's say we wanted to implement
8257
05:48:22,260 --> 05:48:23,260
this function in another class it's
8258
05:48:24,718 --> 05:48:25,718
really simple to do it now that we have
8259
05:48:26,638 --> 05:48:27,638
a virtual function here we can head into
8260
05:48:29,638 --> 05:48:30,638
our pickup.h and over here along with
8261
05:48:33,600 --> 05:48:34,600
this we can type in Virtual void and I
8262
05:48:37,798 --> 05:48:38,798
don't know what the function was so I'll
8263
05:48:39,660 --> 05:48:40,660
just copy this over
8264
05:48:41,400 --> 05:48:42,400
do the same thing in the pickup
8265
05:48:45,120 --> 05:48:46,120
and since we are actually overriding a
8266
05:48:47,580 --> 05:48:48,580
base class method what we can do is we
8267
05:48:49,500 --> 05:48:50,500
can use the keyword override
8268
05:48:51,540 --> 05:48:52,540
uh now if I go ahead and right click
8269
05:48:54,420 --> 05:48:55,420
quick actions create a definition
8270
05:48:57,240 --> 05:48:58,240
head in here and now let's say we do the
8271
05:49:00,360 --> 05:49:01,360
same thing so let's say we do U Kismet
8272
05:49:04,320 --> 05:49:05,320
system Library
8273
05:49:06,900 --> 05:49:07,900
print string
8274
05:49:09,180 --> 05:49:10,180
this and let's just say
8275
05:49:12,558 --> 05:49:13,558
destroyed
8276
05:49:14,520 --> 05:49:15,520
pickup from C plus plus
8277
05:49:18,540 --> 05:49:19,540
and we need to include Kismet of course
8278
05:49:20,820 --> 05:49:21,820
so let's just do that real quick so let
8279
05:49:23,100 --> 05:49:24,100
me just copy this over
8280
05:49:26,040 --> 05:49:27,040
because let's just do this in the dot h
8281
05:49:27,840 --> 05:49:28,840
file
8282
05:49:30,480 --> 05:49:31,480
so now we can go ahead and actually
8283
05:49:32,760 --> 05:49:33,760
destroy it so we can say this
8284
05:49:36,298 --> 05:49:37,298
destroy
8285
05:49:39,958 --> 05:49:40,958
or rather you can just call destroy
8286
05:49:43,080 --> 05:49:44,080
all right so we can go ahead and test
8287
05:49:45,540 --> 05:49:46,540
this logic but remember it's not going
8288
05:49:47,940 --> 05:49:48,940
to work for our interaction actor
8289
05:49:49,798 --> 05:49:50,798
because
8290
05:49:50,700 --> 05:49:51,700
we again don't have another C plus class
8291
05:49:53,458 --> 05:49:54,458
for it so let's actually create that too
8292
05:49:55,200 --> 05:49:56,200
so new C plus plus class actor
8293
05:49:58,520 --> 05:49:59,520
let's just call it for example I don't
8294
05:50:02,400 --> 05:50:03,400
know
8295
05:50:03,320 --> 05:50:04,320
CPP underscore interaction active
8296
05:50:09,298 --> 05:50:10,298
okay so we'll create the class
8297
05:50:12,000 --> 05:50:13,000
and what we can do is we can again
8298
05:50:13,798 --> 05:50:14,798
implement this so in order to implement
8299
05:50:16,200 --> 05:50:17,200
the interface
8300
05:50:18,000 --> 05:50:19,000
so I'll just stop the editor there so in
8301
05:50:20,700 --> 05:50:21,700
order to implement the interface we'll
8302
05:50:22,138 --> 05:50:23,138
do the same thing what we did for pickup
8303
05:50:23,760 --> 05:50:24,760
so if you head into the header here
8304
05:50:26,218 --> 05:50:27,218
copy this over head into your
8305
05:50:28,700 --> 05:50:29,700
interaction actor
8306
05:50:30,840 --> 05:50:31,840
implement the interface and again we
8307
05:50:33,480 --> 05:50:34,480
need the header file so what we can do
8308
05:50:35,520 --> 05:50:36,520
is we can do hash include
8309
05:50:38,400 --> 05:50:39,400
uh whatever this is so we have my
8310
05:50:41,700 --> 05:50:42,700
interface.h
8311
05:50:43,378 --> 05:50:44,378
and then we can go ahead and implement
8312
05:50:45,480 --> 05:50:46,480
this event by using virtual void
8313
05:50:48,620 --> 05:50:49,620
destruct which was a function name and
8314
05:50:51,298 --> 05:50:52,298
we are overriding a base class method so
8315
05:50:54,600 --> 05:50:55,600
override
8316
05:50:55,740 --> 05:50:56,740
and now we can go ahead and create the
8317
05:50:57,900 --> 05:50:58,900
definition for it
8318
05:51:00,480 --> 05:51:01,480
and over here we can go ahead and print
8319
05:51:02,638 --> 05:51:03,638
the string again
8320
05:51:04,138 --> 05:51:05,138
we can do that by simply including
8321
05:51:06,900 --> 05:51:07,900
Kismet again so let me just copy it over
8322
05:51:10,020 --> 05:51:11,020
oops I'd copied that so head back into
8323
05:51:12,540 --> 05:51:13,540
your pickup
8324
05:51:14,218 --> 05:51:15,218
where we had included it copy that paste
8325
05:51:16,980 --> 05:51:17,980
that back in
8326
05:51:18,480 --> 05:51:19,480
and let's just copy over the code from
8327
05:51:20,878 --> 05:51:21,878
our pickup
8328
05:51:22,378 --> 05:51:23,378
you can have different code as well I'm
8329
05:51:24,958 --> 05:51:25,958
just showing you guys as an example on
8330
05:51:27,298 --> 05:51:28,298
how to use it so we'll change what we
8331
05:51:29,160 --> 05:51:30,160
print so destroyed
8332
05:51:32,360 --> 05:51:33,360
interaction actor from CPP and this
8333
05:51:36,600 --> 05:51:37,600
should work
8334
05:51:38,400 --> 05:51:39,400
also just head back into your CPP file
8335
05:51:41,580 --> 05:51:42,580
your CPP character and where we cast it
8336
05:51:44,580 --> 05:51:45,580
to the pickup what you basically do is
8337
05:51:46,740 --> 05:51:47,740
instead of casting to the pickup you
8338
05:51:48,480 --> 05:51:49,480
cast to the interface since we inherited
8339
05:51:51,000 --> 05:51:52,000
the interface so it's going to be I my
8340
05:51:53,280 --> 05:51:54,280
interface and make sure you actually
8341
05:51:55,378 --> 05:51:56,378
include the header file I've already
8342
05:51:56,940 --> 05:51:57,940
done that so somewhere over here we have
8343
05:51:59,700 --> 05:52:00,700
included pickup.h already and pickup.h
8344
05:52:02,760 --> 05:52:03,760
already implements the interface and we
8345
05:52:05,940 --> 05:52:06,940
have included the header so we don't
8346
05:52:07,620 --> 05:52:08,620
really need it so we can cast to this
8347
05:52:09,900 --> 05:52:10,900
interface and instead of destroying and
8348
05:52:13,080 --> 05:52:14,080
printing what we can do is we can
8349
05:52:15,540 --> 05:52:16,540
utilize this
8350
05:52:17,360 --> 05:52:18,360
so we can
8351
05:52:20,878 --> 05:52:21,878
have this separately so we'll just do
8352
05:52:23,340 --> 05:52:24,340
Auto
8353
05:52:25,798 --> 05:52:26,798
temp equals I mean I'm doing uppercase
8354
05:52:28,138 --> 05:52:29,138
temp because we've already used
8355
05:52:29,580 --> 05:52:30,580
lowercase temp here
8356
05:52:31,558 --> 05:52:32,558
and temp is going to be valid because
8357
05:52:34,080 --> 05:52:35,080
the cost has succeeded
8358
05:52:36,058 --> 05:52:37,058
so what we can do is we can call
8359
05:52:38,298 --> 05:52:39,298
destruct from here
8360
05:52:42,600 --> 05:52:43,600
all right
8361
05:52:44,100 --> 05:52:45,100
now we can go ahead and run a debugger
8362
05:52:47,120 --> 05:52:48,120
now if I head back into my character
8363
05:52:50,040 --> 05:52:51,040
connect this up
8364
05:52:51,980 --> 05:52:52,980
uh hit play
8365
05:52:54,360 --> 05:52:55,360
and you should see that we say destroyed
8366
05:52:58,260 --> 05:52:59,260
pickup from CPP but the interaction
8367
05:53:01,500 --> 05:53:02,500
actor doesn't work that's because we
8368
05:53:04,260 --> 05:53:05,260
haven't actually set up the parent class
8369
05:53:06,058 --> 05:53:07,058
over here so go ahead and change that to
8370
05:53:08,878 --> 05:53:09,878
CPP underscore interaction actor and we
8371
05:53:12,540 --> 05:53:13,540
could rename this as well BP interaction
8372
05:53:14,878 --> 05:53:15,878
actor
8373
05:53:16,440 --> 05:53:17,440
all right so if I go ahead and press
8374
05:53:19,260 --> 05:53:20,260
play the pickup works
8375
05:53:21,420 --> 05:53:22,420
and as you can see destroyed interaction
8376
05:53:23,940 --> 05:53:24,940
actor from CPP
8377
05:53:26,218 --> 05:53:27,218
so that's pretty much it that's how you
8378
05:53:28,620 --> 05:53:29,620
use interfaces and later on we will also
8379
05:53:31,980 --> 05:53:32,980
be seeing more practical examples this
8380
05:53:34,200 --> 05:53:35,200
was probably a good one but still will
8381
05:53:36,540 --> 05:53:37,540
actually implement this in our actual
8382
05:53:38,580 --> 05:53:39,580
game
8383
05:53:40,300 --> 05:53:41,300
[Music]
8384
05:53:44,638 --> 05:53:45,638
now let's look at another case where you
8385
05:53:48,180 --> 05:53:49,180
know you want to call blueprint
8386
05:53:50,040 --> 05:53:51,040
functions from C plus plus now this
8387
05:53:53,218 --> 05:53:54,218
almost seems impossible because your C
8388
05:53:56,280 --> 05:53:57,280
plus plus classes aren't actually aware
8389
05:53:58,860 --> 05:53:59,860
of what blueprint classes exist but
8390
05:54:02,040 --> 05:54:03,040
actually it is
8391
05:54:03,900 --> 05:54:04,900
it's really simple too so what you do
8392
05:54:06,718 --> 05:54:07,718
you could use it in any actor any object
8393
05:54:09,718 --> 05:54:10,718
even in the interface if you want but
8394
05:54:12,360 --> 05:54:13,360
I'll just show you guys in the character
8395
05:54:13,920 --> 05:54:14,920
by just printing something
8396
05:54:15,780 --> 05:54:16,780
so the way you actually call blueprint
8397
05:54:18,180 --> 05:54:19,180
from C plus plus is like this so you
8398
05:54:21,120 --> 05:54:22,120
just write the normal function so let's
8399
05:54:23,218 --> 05:54:24,218
just call this void
8400
05:54:26,580 --> 05:54:27,580
test BP func let's say
8401
05:54:30,000 --> 05:54:31,000
and now what you got to do is you have
8402
05:54:33,298 --> 05:54:34,298
to use the U function
8403
05:54:35,458 --> 05:54:36,458
a macro and you can make this blueprint
8404
05:54:39,058 --> 05:54:40,058
callable or not but the specifier that
8405
05:54:42,058 --> 05:54:43,058
you need is called blueprint
8406
05:54:44,540 --> 05:54:45,540
implementable event
8407
05:54:49,080 --> 05:54:50,080
so now you can have the function
8408
05:54:51,660 --> 05:54:52,660
declaration over here you can actually
8409
05:54:53,280 --> 05:54:54,280
have parameters too so we can test that
8410
05:54:56,580 --> 05:54:57,580
if you want so in X let's say
8411
05:55:00,360 --> 05:55:01,360
so now if I actually run this you won't
8412
05:55:02,400 --> 05:55:03,400
actually get a compile error because
8413
05:55:04,520 --> 05:55:05,520
unreal or automatically generates the
8414
05:55:07,440 --> 05:55:08,440
definition for you and you can Define it
8415
05:55:09,718 --> 05:55:10,718
in Blueprint
8416
05:55:10,920 --> 05:55:11,920
so if I open up my BP character
8417
05:55:14,000 --> 05:55:15,000
and under functions under overrideable
8418
05:55:17,040 --> 05:55:18,040
if you just have a look you will have
8419
05:55:19,920 --> 05:55:20,920
test BP func and as you can see I can
8420
05:55:23,040 --> 05:55:24,040
actually implement this over here and we
8421
05:55:25,020 --> 05:55:26,020
also got our input parameter so we can
8422
05:55:27,180 --> 05:55:28,180
just go ahead and print a string we can
8423
05:55:29,760 --> 05:55:30,760
either call this through blueprint or we
8424
05:55:32,100 --> 05:55:33,100
could even call this through C plus plus
8425
05:55:33,480 --> 05:55:34,480
let me show you guys by calling it
8426
05:55:35,160 --> 05:55:36,160
through C plus plus so I'll do it on
8427
05:55:37,378 --> 05:55:38,378
begin play
8428
05:55:38,780 --> 05:55:39,780
so what was a function called again test
8429
05:55:42,058 --> 05:55:43,058
BP func
8430
05:55:43,740 --> 05:55:44,740
and you would see that this is actually
8431
05:55:46,500 --> 05:55:47,500
implemented so let's type in 100 for
8432
05:55:48,718 --> 05:55:49,718
example
8433
05:55:49,680 --> 05:55:50,680
and this will work and in the meantime
8434
05:55:52,500 --> 05:55:53,500
now I would like to show you guys one
8435
05:55:55,200 --> 05:55:56,200
more thing that you can do I just wanted
8436
05:55:57,058 --> 05:55:58,058
to show you guys that yes you can
8437
05:55:58,920 --> 05:55:59,920
actually do this you can actually
8438
05:56:00,600 --> 05:56:01,600
implement it in Blueprint
8439
05:56:02,740 --> 05:56:03,740
[Music]
8440
05:56:07,558 --> 05:56:08,558
but there is a possibility that you have
8441
05:56:09,600 --> 05:56:10,600
some C plus code but then you also have
8442
05:56:12,540 --> 05:56:13,540
some blueprint code which you want to be
8443
05:56:14,280 --> 05:56:15,280
executed so in that case what you would
8444
05:56:17,280 --> 05:56:18,280
do is you would use another type known
8445
05:56:19,860 --> 05:56:20,860
as blueprint native event so we'll just
8446
05:56:23,040 --> 05:56:24,040
copy over this function
8447
05:56:25,620 --> 05:56:26,620
and let's call this one test BP native
8448
05:56:29,580 --> 05:56:30,580
funk and let's just have something else
8449
05:56:32,280 --> 05:56:33,280
for example let's say we'll have a float
8450
05:56:35,340 --> 05:56:36,340
and for this actually what you need to
8451
05:56:38,218 --> 05:56:39,218
do is you need to have another function
8452
05:56:41,780 --> 05:56:42,780
called The implementation of this
8453
05:56:44,760 --> 05:56:45,760
function
8454
05:56:45,780 --> 05:56:46,780
so that is going to be what you define
8455
05:56:48,000 --> 05:56:49,000
in C plus plus and this is going to be
8456
05:56:50,700 --> 05:56:51,700
our function name in Blueprint so in
8457
05:56:53,040 --> 05:56:54,040
order to explain what I mean instead of
8458
05:56:54,780 --> 05:56:55,780
implementable type in Native
8459
05:56:58,020 --> 05:56:59,020
now if you compile this you'll actually
8460
05:56:59,940 --> 05:57:00,940
get an error so what you're supposed to
8461
05:57:01,980 --> 05:57:02,980
do is not create a definition however
8462
05:57:05,160 --> 05:57:06,160
you are supposed to create an
8463
05:57:07,020 --> 05:57:08,020
implementation for this so the way you
8464
05:57:08,940 --> 05:57:09,940
do it is you just copy over the
8465
05:57:10,320 --> 05:57:11,320
signature and instead of the same
8466
05:57:13,020 --> 05:57:14,020
function name you type in underscore
8467
05:57:15,058 --> 05:57:16,058
implementation
8468
05:57:18,360 --> 05:57:19,360
whoops
8469
05:57:19,860 --> 05:57:20,860
implementation
8470
05:57:22,378 --> 05:57:23,378
so what you can do now is for the
8471
05:57:24,660 --> 05:57:25,660
implementation you can go ahead and
8472
05:57:26,100 --> 05:57:27,100
create the definition
8473
05:57:27,840 --> 05:57:28,840
head into your definition and we can go
8474
05:57:30,480 --> 05:57:31,480
ahead and print something so let's say
8475
05:57:32,820 --> 05:57:33,820
we go ahead and print
8476
05:57:35,700 --> 05:57:36,700
for example let's just say
8477
05:57:38,340 --> 05:57:39,340
C plus plus implementation
8478
05:57:42,180 --> 05:57:43,180
called
8479
05:57:45,298 --> 05:57:46,298
and we can close that in
8480
05:57:47,700 --> 05:57:48,700
and for a blueprint implementation we
8481
05:57:50,040 --> 05:57:51,040
can set that up in Blueprint no issues
8482
05:57:53,820 --> 05:57:54,820
so that should be it now you can go
8483
05:57:56,100 --> 05:57:57,100
ahead and actually compile this once
8484
05:57:57,660 --> 05:57:58,660
again
8485
05:58:00,240 --> 05:58:01,240
so apologies I just made a few typos
8486
05:58:02,940 --> 05:58:03,940
over here so
8487
05:58:05,280 --> 05:58:06,280
so let me just copy Implement over here
8488
05:58:11,218 --> 05:58:12,218
so implementation
8489
05:58:13,920 --> 05:58:14,920
and do the same in the CPP file as well
8490
05:58:17,280 --> 05:58:18,280
so underscore implementation and now you
8491
05:58:20,040 --> 05:58:21,040
should have no problems
8492
05:58:25,020 --> 05:58:26,020
so if we head into a BP character
8493
05:58:27,540 --> 05:58:28,540
and we can go ahead and override both of
8494
05:58:30,600 --> 05:58:31,600
them so test bpfunk we can go ahead and
8495
05:58:34,378 --> 05:58:35,378
print it actually uh this is our
8496
05:58:36,600 --> 05:58:37,600
blueprint implementation and we called
8497
05:58:38,458 --> 05:58:39,458
it from C plus plus so okay we'll just
8498
05:58:41,160 --> 05:58:42,160
go ahead and print it we are calling it
8499
05:58:43,200 --> 05:58:44,200
from C plus plus so what should be
8500
05:58:45,660 --> 05:58:46,660
expected is 100 is going to be printed
8501
05:58:48,180 --> 05:58:49,180
even the native event you can call it
8502
05:58:50,580 --> 05:58:51,580
from C plus plus I'll just do it over
8503
05:58:52,080 --> 05:58:53,080
here
8504
05:58:53,040 --> 05:58:54,040
so first of all let me Implement that in
8505
05:58:55,320 --> 05:58:56,320
Blueprint so
8506
05:58:57,000 --> 05:58:58,000
Implement that go ahead and just print
8507
05:59:00,000 --> 05:59:01,000
that
8508
05:59:01,680 --> 05:59:02,680
that shouldn't be that hard and just
8509
05:59:04,680 --> 05:59:05,680
grab in our begin play here
8510
05:59:07,160 --> 05:59:08,160
and instead of okay let's just spawn
8511
05:59:10,080 --> 05:59:11,080
this let's keep all of this logic
8512
05:59:12,600 --> 05:59:13,600
and we can go ahead and since we made it
8513
05:59:14,760 --> 05:59:15,760
blueprint callable
8514
05:59:16,378 --> 05:59:17,378
whatever this was and we'll just take in
8515
05:59:19,740 --> 05:59:20,740
some random value
8516
05:59:22,558 --> 05:59:23,558
now if I compile and if I go ahead and
8517
05:59:24,660 --> 05:59:25,660
press play as you can see we get 100 as
8518
05:59:28,138 --> 05:59:29,138
well as our four two three four three
8519
05:59:31,620 --> 05:59:32,620
printed
8520
05:59:33,000 --> 05:59:34,000
now your obvious question is why didn't
8521
05:59:36,000 --> 05:59:37,000
the C plus plus implementation get
8522
05:59:38,160 --> 05:59:39,160
called so if we if I actually go ahead
8523
05:59:40,260 --> 05:59:41,260
and delete this and if I were to press
8524
05:59:42,180 --> 05:59:43,180
play now we would see our C plus plus
8525
05:59:43,920 --> 05:59:44,920
implementation is called but that's not
8526
05:59:47,760 --> 05:59:48,760
really that useful isn't it unless you
8527
05:59:50,820 --> 05:59:51,820
just have some sort of a default
8528
05:59:52,320 --> 05:59:53,320
implementation
8529
05:59:53,760 --> 05:59:54,760
so what you actually need to do in order
8530
05:59:55,860 --> 05:59:56,860
to get the C plus plus version called is
8531
05:59:58,080 --> 05:59:59,080
right click on the Node and type in add
8532
06:00:01,200 --> 06:00:02,200
call to parent function
8533
06:00:03,180 --> 06:00:04,180
now it is going to call the C plus
8534
06:00:05,820 --> 06:00:06,820
version
8535
06:00:07,138 --> 06:00:08,138
now if I go ahead and press play
8536
06:00:09,540 --> 06:00:10,540
as you can see
8537
06:00:11,280 --> 06:00:12,280
it calls the C plus C plus plus
8538
06:00:13,740 --> 06:00:14,740
implementation the blueprint
8539
06:00:15,540 --> 06:00:16,540
implementation as well along with it so
8540
06:00:18,480 --> 06:00:19,480
that is basically how it works
8541
06:00:21,000 --> 06:00:22,000
now if I if you were to do this as you
8542
06:00:23,760 --> 06:00:24,760
can see we call the C plus function
8543
06:00:26,160 --> 06:00:27,160
along with the parameters of course as
8544
06:00:28,500 --> 06:00:29,500
well as the blueprint function what you
8545
06:00:30,840 --> 06:00:31,840
are calling here is actually the
8546
06:00:32,340 --> 06:00:33,340
blueprint function if it does not find
8547
06:00:34,740 --> 06:00:35,740
an implementation it is going to use the
8548
06:00:36,780 --> 06:00:37,780
parent class version of the function
8549
06:00:38,280 --> 06:00:39,280
remember that foreign
8550
06:00:46,458 --> 06:00:47,458
discussed everything which was
8551
06:00:48,718 --> 06:00:49,718
foundational in order to actually start
8552
06:00:50,940 --> 06:00:51,940
developing in C plus plus however we do
8553
06:00:53,700 --> 06:00:54,700
lack a little bit of knowledge regarding
8554
06:00:56,280 --> 06:00:57,280
you know the implementation of various
8555
06:00:58,500 --> 06:00:59,500
data structures in unreal now apart from
8556
06:01:01,260 --> 06:01:02,260
just using normal variables you would
8557
06:01:03,180 --> 06:01:04,180
use arrays and Maps there are others
8558
06:01:05,760 --> 06:01:06,760
such as sets linked lists and stuff but
8559
06:01:08,458 --> 06:01:09,458
for games you would honestly just use
8560
06:01:11,100 --> 06:01:12,100
arrays and Maps most of the time
8561
06:01:14,700 --> 06:01:15,700
so in order to implement arrays in
8562
06:01:17,638 --> 06:01:18,638
unreal so you don't use a static array I
8563
06:01:20,160 --> 06:01:21,160
mean value could but you don't use
8564
06:01:21,900 --> 06:01:22,900
static arrays uh you don't really use
8565
06:01:25,620 --> 06:01:26,620
the STD Vector as well you could use a
8566
06:01:28,200 --> 06:01:29,200
3D Vector but you can't expose them to
8567
06:01:30,298 --> 06:01:31,298
blueprint and stuff or you would have to
8568
06:01:32,160 --> 06:01:33,160
write your own wrapper class now if you
8569
06:01:34,320 --> 06:01:35,320
guys don't know what I'm talking about
8570
06:01:35,700 --> 06:01:36,700
I'm basically referring to the standard
8571
06:01:37,860 --> 06:01:38,860
template library in C plus plus
8572
06:01:40,320 --> 06:01:41,320
but in unreal instead of STD Vector we
8573
06:01:44,040 --> 06:01:45,040
actually have
8574
06:01:45,420 --> 06:01:46,420
another type known as template array or
8575
06:01:49,080 --> 06:01:50,080
tra so the way you create that so let's
8576
06:01:51,660 --> 06:01:52,660
create a variable in C plus plus let's
8577
06:01:53,820 --> 06:01:54,820
do that in the public section we're just
8578
06:01:55,558 --> 06:01:56,558
doing it for demonstration so I'll just
8579
06:01:58,200 --> 06:01:59,200
make a U property
8580
06:02:00,540 --> 06:02:01,540
and make this one blueprint read write
8581
06:02:05,280 --> 06:02:06,280
and add it anywhere
8582
06:02:07,620 --> 06:02:08,620
so edit
8583
06:02:09,120 --> 06:02:10,120
anywhere
8584
06:02:10,500 --> 06:02:11,500
and over here what we can do is instead
8585
06:02:13,378 --> 06:02:14,378
let's say we have an array of integers
8586
06:02:15,058 --> 06:02:16,058
so the way you do it is you type in t
8587
06:02:17,580 --> 06:02:18,580
array and as a template argument you
8588
06:02:20,760 --> 06:02:21,760
would give the type as integer and let's
8589
06:02:23,400 --> 06:02:24,400
just call this our end array
8590
06:02:26,820 --> 06:02:27,820
all right now template array is actually
8591
06:02:30,058 --> 06:02:31,058
internally
8592
06:02:31,980 --> 06:02:32,980
something like your STD Vector so if I
8593
06:02:34,260 --> 06:02:35,260
actually Ctrl click on this this is
8594
06:02:35,760 --> 06:02:36,760
actually a class which implements it
8595
06:02:39,000 --> 06:02:40,000
and the methods which are associated
8596
06:02:41,400 --> 06:02:42,400
with this are pretty simple we will go
8597
06:02:43,680 --> 06:02:44,680
ahead and check all of this
8598
06:02:46,500 --> 06:02:47,500
so similar to the STD vector class in
8599
06:02:50,400 --> 06:02:51,400
standard C plus plus tra has a bunch of
8600
06:02:54,058 --> 06:02:55,058
functions which gives us info about
8601
06:02:56,760 --> 06:02:57,760
various things so let's actually set
8602
06:02:59,760 --> 06:03:00,760
some stuff up so in order to initialize
8603
06:03:02,340 --> 06:03:03,340
this array so what we do basically we
8604
06:03:05,520 --> 06:03:06,520
can do it in the Constructor or right
8605
06:03:07,260 --> 06:03:08,260
here we'll do it in the Constructor just
8606
06:03:08,940 --> 06:03:09,940
to keep things clean so we'll call R and
8607
06:03:12,420 --> 06:03:13,420
array equals
8608
06:03:14,520 --> 06:03:15,520
and within curly braces we can just give
8609
06:03:16,920 --> 06:03:17,920
some values so I'll just initialize it
8610
06:03:19,320 --> 06:03:20,320
with some random values
8611
06:03:21,240 --> 06:03:22,240
all right so now let's go ahead and look
8612
06:03:24,180 --> 06:03:25,180
at how to add stuff to this so similar
8613
06:03:27,900 --> 06:03:28,900
to add and in place we have methods for
8614
06:03:31,320 --> 06:03:32,320
that over here as well so we can type in
8615
06:03:33,540 --> 06:03:34,540
R int array
8616
06:03:35,340 --> 06:03:36,340
Dot add and now we can go ahead and add
8617
06:03:40,558 --> 06:03:41,558
an item so let's say for example I want
8618
06:03:42,780 --> 06:03:43,780
to add 12. so our fifth element here
8619
06:03:45,540 --> 06:03:46,540
that is at index 4 is going to become
8620
06:03:48,180 --> 06:03:49,180
12. and this array is going to be
8621
06:03:51,120 --> 06:03:52,120
resized since it is similar to an STD
8622
06:03:54,660 --> 06:03:55,660
vector
8623
06:03:55,860 --> 06:03:56,860
now similarly also have M plus so
8624
06:03:58,680 --> 06:03:59,680
constructing an element in place
8625
06:04:00,298 --> 06:04:01,298
basically
8626
06:04:02,400 --> 06:04:03,400
dot m Plus
8627
06:04:04,798 --> 06:04:05,798
this is like your M plus back function
8628
06:04:07,260 --> 06:04:08,260
in STD vector
8629
06:04:10,320 --> 06:04:11,320
so I'll just add in some random element
8630
06:04:13,138 --> 06:04:14,138
over there now our array is going to be
8631
06:04:15,718 --> 06:04:16,718
23 6 43 64 12 and 4. now what if I
8632
06:04:20,820 --> 06:04:21,820
wanted to remove something so I can type
8633
06:04:23,218 --> 06:04:24,218
in R int array and I can remove either
8634
06:04:26,580 --> 06:04:27,580
at index so dot remove I can either
8635
06:04:30,240 --> 06:04:31,240
remove an element by using the remove
8636
06:04:32,218 --> 06:04:33,218
function so let's say I wanted to remove
8637
06:04:34,558 --> 06:04:35,558
23 I'm gonna remove 23.
8638
06:04:38,040 --> 06:04:39,040
and R and array
8639
06:04:40,740 --> 06:04:41,740
whoops
8640
06:04:42,120 --> 06:04:43,120
R and array
8641
06:04:45,620 --> 06:04:46,620
dot remove at
8642
06:04:48,120 --> 06:04:49,120
is going to let us remove something at a
8643
06:04:50,520 --> 06:04:51,520
given index so let's say I choose zero
8644
06:04:52,680 --> 06:04:53,680
so now it's going to remove 6 because we
8645
06:04:55,378 --> 06:04:56,378
already removed 22 so 6 is our first
8646
06:04:57,600 --> 06:04:58,600
index so 6 is going to be removed
8647
06:05:00,780 --> 06:05:01,780
all right so we did all of these but now
8648
06:05:05,760 --> 06:05:06,760
what if we wanted to reserve some memory
8649
06:05:08,040 --> 06:05:09,040
for our array so what if you didn't want
8650
06:05:10,440 --> 06:05:11,440
it to resize and search for memory so
8651
06:05:12,780 --> 06:05:13,780
even those functions are available so
8652
06:05:14,820 --> 06:05:15,820
let's call The Reserve function before
8653
06:05:16,378 --> 06:05:17,378
all of this so our end array
8654
06:05:19,260 --> 06:05:20,260
dot Reserve whoops Reserve
8655
06:05:23,458 --> 06:05:24,458
and we can as we can see we have four
8656
06:05:27,360 --> 06:05:28,360
elements five six
8657
06:05:29,940 --> 06:05:30,940
and we remove two so we have to so we
8658
06:05:33,660 --> 06:05:34,660
can reserve for but at Max we have six
8659
06:05:35,940 --> 06:05:36,940
elements so let's Reserve six
8660
06:05:39,718 --> 06:05:40,718
so we can call that and stuff
8661
06:05:43,138 --> 06:05:44,138
so these are the most common ones that
8662
06:05:45,298 --> 06:05:46,298
you'll use I won't really use all the
8663
06:05:47,940 --> 06:05:48,940
other methods but again you can just
8664
06:05:49,558 --> 06:05:50,558
refer the documentation if you really
8665
06:05:51,420 --> 06:05:52,420
need it
8666
06:05:52,860 --> 06:05:53,860
now we can go ahead and iterate through
8667
06:05:55,558 --> 06:05:56,558
this array through a range based for
8668
06:05:57,240 --> 06:05:58,240
Loop just like how you can with any of
8669
06:05:59,878 --> 06:06:00,878
the STL data structure so you can go
8670
06:06:03,420 --> 06:06:04,420
ahead and do for Loop
8671
06:06:06,240 --> 06:06:07,240
Auto
8672
06:06:07,980 --> 06:06:08,980
we can just call this one element
8673
06:06:11,340 --> 06:06:12,340
and we can pass in the array just like
8674
06:06:13,680 --> 06:06:14,680
how you would pass an STD Vector so R
8675
06:06:16,138 --> 06:06:17,138
and array
8676
06:06:18,058 --> 06:06:19,058
and what we can do is we can go ahead
8677
06:06:20,040 --> 06:06:21,040
and print it out by calling the print
8678
06:06:22,138 --> 06:06:23,138
string function so you Kismet system
8679
06:06:23,940 --> 06:06:24,940
Library print string you know that drill
8680
06:06:26,820 --> 06:06:27,820
by now so
8681
06:06:29,340 --> 06:06:30,340
now in order to print an integer you
8682
06:06:33,298 --> 06:06:34,298
actually use this function which is a
8683
06:06:35,400 --> 06:06:36,400
static member of the F string class so F
8684
06:06:38,340 --> 06:06:39,340
string from int is what you use
8685
06:06:42,480 --> 06:06:43,480
and you can go ahead and type in Le here
8686
06:06:46,620 --> 06:06:47,620
now remember if you wanted to print a
8687
06:06:49,200 --> 06:06:50,200
float you would use this function known
8688
06:06:50,940 --> 06:06:51,940
as sanitize float now it's going to cast
8689
06:06:54,058 --> 06:06:55,058
it implicitly anyway so even float works
8690
06:06:56,580 --> 06:06:57,580
for this
8691
06:06:57,780 --> 06:06:58,780
and you also have other functions for
8692
06:07:00,540 --> 06:07:01,540
converting between various data types
8693
06:07:03,360 --> 06:07:04,360
you could again have a look at either
8694
06:07:05,458 --> 06:07:06,458
the F string class or you could go ahead
8695
06:07:07,860 --> 06:07:08,860
and just search it up on the
8696
06:07:10,680 --> 06:07:11,680
documentation so if I actually head in
8697
06:07:12,420 --> 06:07:13,420
over here so we have our sanitized plot
8698
06:07:15,900 --> 06:07:16,900
here we have two hex blob from hex blob
8699
06:07:20,120 --> 06:07:21,120
we have we have various functions
8700
06:07:22,558 --> 06:07:23,558
basically so we have from int as you can
8701
06:07:25,138 --> 06:07:26,138
see you can go through this class
8702
06:07:27,840 --> 06:07:28,840
see the return type and look at what the
8703
06:07:31,500 --> 06:07:32,500
function does and then you can go ahead
8704
06:07:33,780 --> 06:07:34,780
and implement it accordingly
8705
06:07:36,180 --> 06:07:37,180
so now I'm in the editor if I open up my
8706
06:07:39,298 --> 06:07:40,298
BP character and if I actually head back
8707
06:07:42,360 --> 06:07:43,360
over here we had made this blueprint
8708
06:07:44,040 --> 06:07:45,040
read write so we should be able to
8709
06:07:45,540 --> 06:07:46,540
access our
8710
06:07:47,160 --> 06:07:48,160
and array so if I just type in our int
8711
06:07:50,520 --> 06:07:51,520
array so as you can see we get it just
8712
06:07:53,160 --> 06:07:54,160
like any other blueprint variable and
8713
06:07:55,798 --> 06:07:56,798
since we initialized it in a Constructor
8714
06:07:57,780 --> 06:07:58,780
we already have certain values now in
8715
06:08:00,660 --> 06:08:01,660
begin play if we go ahead and iterate
8716
06:08:03,120 --> 06:08:04,120
through this
8717
06:08:04,320 --> 06:08:05,320
so I'll just do that we'll uh not call
8718
06:08:06,718 --> 06:08:07,718
this function anymore now we have an
8719
06:08:08,580 --> 06:08:09,580
idea of what that is
8720
06:08:10,500 --> 06:08:11,500
so we have already set it up actually so
8721
06:08:13,260 --> 06:08:14,260
we we have done it over here so we're
8722
06:08:15,840 --> 06:08:16,840
printing stuff
8723
06:08:17,400 --> 06:08:18,400
in our begin playing C plus plus so we
8724
06:08:19,680 --> 06:08:20,680
don't have to set it up actually so if I
8725
06:08:21,900 --> 06:08:22,900
go ahead and press play as you can see
8726
06:08:23,520 --> 06:08:24,520
we have 4 12 64 43 in reverse order that
8727
06:08:27,958 --> 06:08:28,958
is 43 64 12 and 4. and let's actually
8728
06:08:31,260 --> 06:08:32,260
walk through the logic so we have 23 6
8729
06:08:34,740 --> 06:08:35,740
43 64. and we went ahead and added 12
8730
06:08:39,480 --> 06:08:40,480
and 4 so 12 and 4 should be our last
8731
06:08:42,480 --> 06:08:43,480
elements
8732
06:08:43,620 --> 06:08:44,620
and we remove 23
8733
06:08:45,660 --> 06:08:46,660
and we removed six so our RS should be
8734
06:08:48,540 --> 06:08:49,540
43 64 12 and 4. and if we go ahead and
8735
06:08:53,280 --> 06:08:54,280
look at our logic here and our output so
8736
06:08:56,218 --> 06:08:57,218
we see that we get 43 64 12 and 4. so
8737
06:09:00,900 --> 06:09:01,900
this is basically how you use the tra
8738
06:09:03,120 --> 06:09:04,120
class functions so this is exactly the
8739
06:09:06,420 --> 06:09:07,420
same as your STD Vector but there are a
8740
06:09:09,180 --> 06:09:10,180
couple differences in the function names
8741
06:09:10,860 --> 06:09:11,860
and most importantly from a readability
8742
06:09:13,680 --> 06:09:14,680
perspective all of these functions use
8743
06:09:16,020 --> 06:09:17,020
Pascal case so it's readable compared to
8744
06:09:19,440 --> 06:09:20,440
the standard C plus plus stuff which
8745
06:09:21,958 --> 06:09:22,958
uses underscores which is not really
8746
06:09:24,120 --> 06:09:25,120
that readable
8747
06:09:26,100 --> 06:09:27,100
so this is how we would it return array
8748
06:09:28,440 --> 06:09:29,440
obviously you could use a full length
8749
06:09:30,120 --> 06:09:31,120
iterator but there is no actual purpose
8750
06:09:32,638 --> 06:09:33,638
to do it as per my experience
8751
06:09:35,520 --> 06:09:36,520
anyways let's head into the next part
8752
06:09:38,040 --> 06:09:39,040
now and take a look at how else we can
8753
06:09:40,740 --> 06:09:41,740
iterate through this through your
8754
06:09:42,480 --> 06:09:43,480
standard C style for Loop so I won't be
8755
06:09:45,540 --> 06:09:46,540
actually showing you guys the output
8756
06:09:46,798 --> 06:09:47,798
since it's obvious that it's going to
8757
06:09:48,780 --> 06:09:49,780
work so you just do something like for
8758
06:09:51,840 --> 06:09:52,840
INT I equals 0
8759
06:09:53,878 --> 06:09:54,878
I less than where now this is where we
8760
06:09:56,820 --> 06:09:57,820
talk about another method in this class
8761
06:09:58,378 --> 06:09:59,378
so we do I less than
8762
06:10:00,420 --> 06:10:01,420
R and array dot num this is similar to
8763
06:10:04,320 --> 06:10:05,320
the size function in the standard
8764
06:10:06,660 --> 06:10:07,660
template libraries STD vector
8765
06:10:09,780 --> 06:10:10,780
and we can do I plus plus so we can just
8766
06:10:13,620 --> 06:10:14,620
increment I go to I plus plus or I plus
8767
06:10:16,500 --> 06:10:17,500
equals 1. now instead of Ali since this
8768
06:10:19,260 --> 06:10:20,260
is not a range base for Loop we can get
8769
06:10:21,180 --> 06:10:22,180
our array
8770
06:10:22,878 --> 06:10:23,878
and we can get the ith element
8771
06:10:26,400 --> 06:10:27,400
now this is going to work exactly the
8772
06:10:28,558 --> 06:10:29,558
same
8773
06:10:30,250 --> 06:10:31,250
[Music]
8774
06:10:34,680 --> 06:10:35,680
apart from RS the other data structure
8775
06:10:37,740 --> 06:10:38,740
that you would use in a game is going to
8776
06:10:40,200 --> 06:10:41,200
be Maps well there are linked lists and
8777
06:10:42,540 --> 06:10:43,540
other data structures which you really
8778
06:10:44,580 --> 06:10:45,580
won't use that very much in games
8779
06:10:47,160 --> 06:10:48,160
even maps to be honest you just use it
8780
06:10:49,740 --> 06:10:50,740
maybe a couple of times in your entire
8781
06:10:51,540 --> 06:10:52,540
project
8782
06:10:52,440 --> 06:10:53,440
but anyways in order to create a map in
8783
06:10:55,500 --> 06:10:56,500
unreal basically you you use the type T
8784
06:10:59,400 --> 06:11:00,400
map
8785
06:11:00,298 --> 06:11:01,298
so if I just copy of the U property
8786
06:11:02,580 --> 06:11:03,580
macro and in the next line you can go
8787
06:11:04,920 --> 06:11:05,920
ahead and create a map
8788
06:11:06,420 --> 06:11:07,420
and if you guys know about Maps
8789
06:11:08,820 --> 06:11:09,820
basically it's just a key value pair so
8790
06:11:11,580 --> 06:11:12,580
for example you can have two strings as
8791
06:11:13,980 --> 06:11:14,980
key and value and you could have
8792
06:11:15,298 --> 06:11:16,298
something like a username password key
8793
06:11:17,040 --> 06:11:18,040
value pair something like that so let's
8794
06:11:19,378 --> 06:11:20,378
just create a simple one let's say we
8795
06:11:22,320 --> 06:11:23,320
map a string to a float
8796
06:11:25,878 --> 06:11:26,878
so it's case sensitive obviously
8797
06:11:29,458 --> 06:11:30,458
and we can call this one R map
8798
06:11:33,420 --> 06:11:34,420
now you can't just initialize a map like
8799
06:11:36,058 --> 06:11:37,058
how you would initialize an array so you
8800
06:11:38,940 --> 06:11:39,940
would have to call the add or the MPS
8801
06:11:40,980 --> 06:11:41,980
function multiple times that's just how
8802
06:11:43,378 --> 06:11:44,378
you would do it
8803
06:11:44,580 --> 06:11:45,580
so our in Array or rather R map dot add
8804
06:11:49,920 --> 06:11:50,920
and what we can do is we can pass in the
8805
06:11:52,980 --> 06:11:53,980
string and the float so let's say pi and
8806
06:11:56,820 --> 06:11:57,820
3.14
8807
06:11:59,160 --> 06:12:00,160
then we can go ahead and call add once
8808
06:12:01,620 --> 06:12:02,620
again
8809
06:12:03,000 --> 06:12:04,000
so we'll just go ahead and do all of
8810
06:12:04,798 --> 06:12:05,798
this in our begin play
8811
06:12:10,500 --> 06:12:11,500
so let's just find some other number
8812
06:12:12,718 --> 06:12:13,718
let's say num1 for example let's just
8813
06:12:15,240 --> 06:12:16,240
grab in a random value
8814
06:12:20,218 --> 06:12:21,218
now once that's done
8815
06:12:22,260 --> 06:12:23,260
you have other methods but you aren't
8816
06:12:25,620 --> 06:12:26,620
really going to be using them for
8817
06:12:27,180 --> 06:12:28,180
anything but I'll just show you guys how
8818
06:12:29,218 --> 06:12:30,218
to iterate through this and how to
8819
06:12:31,500 --> 06:12:32,500
retrieve the key and the value so that's
8820
06:12:34,200 --> 06:12:35,200
what you'll be using this most for
8821
06:12:36,718 --> 06:12:37,718
now let's say I wanted to access an
8822
06:12:38,700 --> 06:12:39,700
element though you could do something
8823
06:12:40,320 --> 06:12:41,320
like this so let's just print out uh
8824
06:12:43,860 --> 06:12:44,860
what the index num1 will contain
8825
06:12:47,580 --> 06:12:48,580
so copy this over
8826
06:12:49,320 --> 06:12:50,320
and instead of R and array of I what we
8827
06:12:52,798 --> 06:12:53,798
can do is we can get our map
8828
06:12:56,878 --> 06:12:57,878
our map
8829
06:12:58,320 --> 06:12:59,320
of
8830
06:12:59,700 --> 06:13:00,700
num1
8831
06:13:01,320 --> 06:13:02,320
basically num1 is the key here and
8832
06:13:05,600 --> 06:13:06,600
basically by doing this you're getting
8833
06:13:07,860 --> 06:13:08,860
the value of it
8834
06:13:09,718 --> 06:13:10,718
so in our case we mapped num1 to 43.4543
8835
06:13:15,958 --> 06:13:16,958
and if you want to iterate through this
8836
06:13:18,000 --> 06:13:19,000
we can use a range best for Loop here as
8837
06:13:19,920 --> 06:13:20,920
well
8838
06:13:21,600 --> 06:13:22,600
so we could just say Auto element
8839
06:13:25,920 --> 06:13:26,920
and we can pass in our map
8840
06:13:30,480 --> 06:13:31,480
and what we can do is we can get the
8841
06:13:32,760 --> 06:13:33,760
element so we'll print this so we'll
8842
06:13:34,920 --> 06:13:35,920
copy the code over once again
8843
06:13:37,798 --> 06:13:38,798
so we'll print both the key and the
8844
06:13:39,900 --> 06:13:40,900
value so let's just create a string
8845
06:13:41,878 --> 06:13:42,878
variable temporarily
8846
06:13:44,400 --> 06:13:45,400
and the way you get the key of this so
8847
06:13:47,600 --> 06:13:48,600
each element in this map is going to be
8848
06:13:50,520 --> 06:13:51,520
a key value pair
8849
06:13:51,900 --> 06:13:52,900
so Le is going to be a key value pair
8850
06:13:54,958 --> 06:13:55,958
what we can do is we can do Dot key in
8851
06:13:58,440 --> 06:13:59,440
order to get the key
8852
06:14:00,900 --> 06:14:01,900
and if we want the value we can go ahead
8853
06:14:03,780 --> 06:14:04,780
and do Le dot value the way we'll do
8854
06:14:06,420 --> 06:14:07,420
that here is we'll just append the
8855
06:14:08,040 --> 06:14:09,040
string so basically we'll concatenate
8856
06:14:09,660 --> 06:14:10,660
the two strings so what you can do is
8857
06:14:11,638 --> 06:14:12,638
temp dot append
8858
06:14:13,500 --> 06:14:14,500
and let's just put a call on Just for
8859
06:14:16,260 --> 06:14:17,260
visual purposes
8860
06:14:18,298 --> 06:14:19,298
and we can do temp dot append and since
8861
06:14:21,900 --> 06:14:22,900
our value is going to be a float we can
8862
06:14:24,900 --> 06:14:25,900
do F string
8863
06:14:26,638 --> 06:14:27,638
sanitize float and we can go ahead and
8864
06:14:30,000 --> 06:14:31,000
get arm
8865
06:14:31,320 --> 06:14:32,320
value so Le dot value
8866
06:14:33,900 --> 06:14:34,900
that is going to be a float
8867
06:14:35,940 --> 06:14:36,940
now we can go ahead and rather than
8868
06:14:37,860 --> 06:14:38,860
printing this we can go ahead and print
8869
06:14:39,958 --> 06:14:40,958
in temp
8870
06:14:41,340 --> 06:14:42,340
so we also learned how to concatenate
8871
06:14:43,620 --> 06:14:44,620
strings on the way
8872
06:14:46,020 --> 06:14:47,020
so this is how you would iterate through
8873
06:14:47,820 --> 06:14:48,820
this this is how you would get a key of
8874
06:14:50,458 --> 06:14:51,458
a given element in the map and this is
8875
06:14:52,860 --> 06:14:53,860
how you get the value
8876
06:14:54,420 --> 06:14:55,420
now remember
8877
06:14:55,860 --> 06:14:56,860
you cannot have two keys of the same
8878
06:14:58,558 --> 06:14:59,558
value so let's say I actually create
8879
06:15:00,718 --> 06:15:01,718
another uh element with the key num1
8880
06:15:04,378 --> 06:15:05,378
it's going to throw an exception you
8881
06:15:06,718 --> 06:15:07,718
can't actually do that so now we'll
8882
06:15:09,000 --> 06:15:10,000
actually stop printing our array now
8883
06:15:11,280 --> 06:15:12,280
that we are done with that
8884
06:15:12,718 --> 06:15:13,718
so if I go ahead and run a debugger now
8885
06:15:16,680 --> 06:15:17,680
since everything is set up now if I go
8886
06:15:18,718 --> 06:15:19,718
ahead and press play
8887
06:15:19,920 --> 06:15:20,920
you would see that we get Pi 3.14 and
8888
06:15:26,660 --> 06:15:27,660
num143.4543 and as you can see we also
8889
06:15:29,940 --> 06:15:30,940
get our four three dot four five four
8890
06:15:33,298 --> 06:15:34,298
three uh that printed first
8891
06:15:37,020 --> 06:15:38,020
because we had printed our map
8892
06:15:40,378 --> 06:15:41,378
of num1 so basically
8893
06:15:43,440 --> 06:15:44,440
the key here is num1 and we basically
8894
06:15:46,080 --> 06:15:47,080
asked for the corresponding value it is
8895
06:15:48,840 --> 06:15:49,840
just as if you asked for R int array of
8896
06:15:52,500 --> 06:15:53,500
one it's pretty much something like that
8897
06:15:55,500 --> 06:15:56,500
so basically instead of the index you
8898
06:15:59,100 --> 06:16:00,100
would pass in the key that's basically
8899
06:16:01,020 --> 06:16:02,020
how you use this operator here
8900
06:16:03,600 --> 06:16:04,600
now this is basically how you iterate
8901
06:16:06,000 --> 06:16:07,000
through it now you could you know do
8902
06:16:10,020 --> 06:16:11,020
many other things with the map
8903
06:16:11,940 --> 06:16:12,940
but for the most part you'd just be
8904
06:16:14,160 --> 06:16:15,160
using it to store key value pairs
8905
06:16:16,860 --> 06:16:17,860
generally it's useful for having a track
8906
06:16:19,798 --> 06:16:20,798
of you know game users and stuff like
8907
06:16:21,718 --> 06:16:22,718
that they're really very odd audios
8908
06:16:24,540 --> 06:16:25,540
cases for maps you wouldn't really use
8909
06:16:26,878 --> 06:16:27,878
it that often so I'll leave this over
8910
06:16:29,340 --> 06:16:30,340
here
8911
06:16:31,370 --> 06:16:32,370
[Music]
8912
06:16:36,000 --> 06:16:37,000
now when it comes to designing your game
8913
06:16:38,420 --> 06:16:39,420
once you're actually aware about all the
8914
06:16:41,760 --> 06:16:42,760
things that we just discussed over here
8915
06:16:43,440 --> 06:16:44,440
up until Maps in order to actually
8916
06:16:46,558 --> 06:16:47,558
Implement them in an appropriate and
8917
06:16:49,260 --> 06:16:50,260
efficient manner you would use the
8918
06:16:51,718 --> 06:16:52,718
classes which the engine provides us
8919
06:16:54,480 --> 06:16:55,480
so we'll be going through some of the
8920
06:16:56,878 --> 06:16:57,878
most important ones which will be used
8921
06:16:58,740 --> 06:16:59,740
in all of the games and there are other
8922
06:17:01,920 --> 06:17:02,920
derived classes of it the ones which I
8923
06:17:04,320 --> 06:17:05,320
showed you guys in the flowchart
8924
06:17:06,718 --> 06:17:07,718
previously when I showed the inheritance
8925
06:17:09,298 --> 06:17:10,298
hierarchy those are the ones that we
8926
06:17:11,820 --> 06:17:12,820
will be discussing in detail there are
8927
06:17:14,458 --> 06:17:15,458
other classes we'll just be brushing
8928
06:17:16,500 --> 06:17:17,500
through few with whichever are important
8929
06:17:19,638 --> 06:17:20,638
but if they are not we are going to be
8930
06:17:22,500 --> 06:17:23,500
just skipping through them but if we
8931
06:17:24,660 --> 06:17:25,660
ever use them in the last part of the
8932
06:17:26,760 --> 06:17:27,760
course
8933
06:17:27,660 --> 06:17:28,660
we'll be having a look at them in depth
8934
06:17:29,820 --> 06:17:30,820
once again
8935
06:17:30,780 --> 06:17:31,780
so now let's start talking about actors
8936
06:17:33,420 --> 06:17:34,420
now at this beginning of this video I
8937
06:17:37,260 --> 06:17:38,260
actually talked a little bit about
8938
06:17:38,940 --> 06:17:39,940
actors basically anything that can be
8939
06:17:41,580 --> 06:17:42,580
placed in the level is an actor so that
8940
06:17:44,218 --> 06:17:45,218
definition still holds good but it is
8941
06:17:46,860 --> 06:17:47,860
incomplete there is another thing which
8942
06:17:49,440 --> 06:17:50,440
an actor can do and that is it can tick
8943
06:17:52,558 --> 06:17:53,558
now you guys have probably seen the tick
8944
06:17:55,558 --> 06:17:56,558
function so let's open up an actor
8945
06:17:57,420 --> 06:17:58,420
actually let's create one because all of
8946
06:17:59,820 --> 06:18:00,820
these have their own base classes so
8947
06:18:02,040 --> 06:18:03,040
let's create a pure actor in Blueprint
8948
06:18:03,958 --> 06:18:04,958
we'll do one in C plus plus as well
8949
06:18:05,700 --> 06:18:06,700
pretty soon
8950
06:18:06,900 --> 06:18:07,900
or actually we probably have it so let's
8951
06:18:09,180 --> 06:18:10,180
call this one BP underscore a let's say
8952
06:18:14,340 --> 06:18:15,340
I just created this for the sake of it
8953
06:18:16,680 --> 06:18:17,680
now if I were to actually have a look
8954
06:18:19,680 --> 06:18:20,680
over here
8955
06:18:20,760 --> 06:18:21,760
you would see that you have three tabs
8956
06:18:23,820 --> 06:18:24,820
and the event graph is where you worked
8957
06:18:26,100 --> 06:18:27,100
on for the most part but we haven't
8958
06:18:28,200 --> 06:18:29,200
actually gone in depth into all of these
8959
06:18:31,558 --> 06:18:32,558
little details so first let's actually
8960
06:18:34,620 --> 06:18:35,620
go from the top so what we have here is
8961
06:18:37,798 --> 06:18:38,798
the class settings and most of the times
8962
06:18:40,378 --> 06:18:41,378
you'll just use it to implement an
8963
06:18:42,180 --> 06:18:43,180
interface or change its base class but
8964
06:18:45,958 --> 06:18:46,958
other than that you aren't going to be
8965
06:18:47,458 --> 06:18:48,458
using it now under class defaults you
8966
06:18:50,160 --> 06:18:51,160
have a bunch of things which actually
8967
06:18:51,840 --> 06:18:52,840
Define what an actor actually can do now
8968
06:18:55,200 --> 06:18:56,200
if you were to look at actor tick you
8969
06:18:57,900 --> 06:18:58,900
have several options start with tick
8970
06:18:59,760 --> 06:19:00,760
enabled tick interval and you also have
8971
06:19:03,058 --> 06:19:04,058
several other things now we did talk
8972
06:19:04,558 --> 06:19:05,558
about this one so I'll I'll not be
8973
06:19:06,840 --> 06:19:07,840
talking about that
8974
06:19:08,340 --> 06:19:09,340
but anyways all of these are
8975
06:19:10,440 --> 06:19:11,440
self-explanatory and one thing which you
8976
06:19:13,080 --> 06:19:14,080
won't see in any other type of blueprint
8977
06:19:14,878 --> 06:19:15,878
other than actors is the replication tab
8978
06:19:17,878 --> 06:19:18,878
ly if you check this replicates tab this
8979
06:19:22,378 --> 06:19:23,378
actor will be eligible to be used in
8980
06:19:24,718 --> 06:19:25,718
multiplayer what I mean by that is that
8981
06:19:27,660 --> 06:19:28,660
when you spawn this on the server which
8982
06:19:31,020 --> 06:19:32,020
we will get to when we talk about
8983
06:19:32,400 --> 06:19:33,400
multiplayer basically all your other
8984
06:19:34,740 --> 06:19:35,740
clients can see too by clients I am
8985
06:19:36,780 --> 06:19:37,780
referring to players in this Con context
8986
06:19:39,600 --> 06:19:40,600
and we have settings regarding that
8987
06:19:42,480 --> 06:19:43,480
now these are just the flags these are
8988
06:19:45,240 --> 06:19:46,240
pretty self-explanatory hidden in game
8989
06:19:47,218 --> 06:19:48,218
and visible stuff like that
8990
06:19:49,860 --> 06:19:50,860
and under the Collision tab these are
8991
06:19:52,138 --> 06:19:53,138
things which we again talked about
8992
06:19:54,540 --> 06:19:55,540
but there are a couple more things which
8993
06:19:56,638 --> 06:19:57,638
an actor provides us the first one is
8994
06:19:59,760 --> 06:20:00,760
your damage now if let's say you have
8995
06:20:04,200 --> 06:20:05,200
you wanted this actor to be destroyed so
8996
06:20:06,780 --> 06:20:07,780
let's actually do that
8997
06:20:08,280 --> 06:20:09,280
let's go ahead and create an object so
8998
06:20:12,840 --> 06:20:13,840
let's add in a model here so let's say
8999
06:20:15,180 --> 06:20:16,180
we add in a sphere
9000
06:20:17,040 --> 06:20:18,040
I don't know uh maybe simulate physics
9001
06:20:21,240 --> 06:20:22,240
on this or let's let's leave it as is
9002
06:20:24,660 --> 06:20:25,660
what we can do is unreal actually
9003
06:20:27,180 --> 06:20:28,180
provides us with default logic to apply
9004
06:20:29,940 --> 06:20:30,940
damage to this so if I type in
9005
06:20:32,820 --> 06:20:33,820
event damage
9006
06:20:34,980 --> 06:20:35,980
you see we get three of these nodes
9007
06:20:37,558 --> 06:20:38,558
Point damage radial damage and any
9008
06:20:40,260 --> 06:20:41,260
damage so any damage is going to refer
9009
06:20:42,958 --> 06:20:43,958
to all types of Damages Point damage is
9010
06:20:45,780 --> 06:20:46,780
going to be your damage through a line
9011
06:20:47,820 --> 06:20:48,820
trace or something generally radial
9012
06:20:50,458 --> 06:20:51,458
damage is going to be something where
9013
06:20:52,798 --> 06:20:53,798
you know you damage this actor through
9014
06:20:54,660 --> 06:20:55,660
grenade or something like that so you
9015
06:20:57,480 --> 06:20:58,480
would have you know a distance and stuff
9016
06:21:00,240 --> 06:21:01,240
like that so if I just press this so you
9017
06:21:03,718 --> 06:21:04,718
have your origin so that's going to be
9018
06:21:05,638 --> 06:21:06,638
where your grenade landed for example
9019
06:21:08,218 --> 06:21:09,218
so it need not be a grenade could be
9020
06:21:09,958 --> 06:21:10,958
anything else just give an example so
9021
06:21:12,600 --> 06:21:13,600
from that point uh if as you go further
9022
06:21:15,958 --> 06:21:16,958
away your damage is going to decrease
9023
06:21:17,878 --> 06:21:18,878
stuff like that so let's just do event
9024
06:21:19,980 --> 06:21:20,980
any any damage so any damage
9025
06:21:24,058 --> 06:21:25,058
what we can do is over here we can go
9026
06:21:27,360 --> 06:21:28,360
ahead and simply print this out rather
9027
06:21:31,500 --> 06:21:32,500
just to demonstrate that that this
9028
06:21:33,480 --> 06:21:34,480
actually works now by default unreal
9029
06:21:36,120 --> 06:21:37,120
does not give you any health variable
9030
06:21:37,620 --> 06:21:38,620
you got to do that yourself and one
9031
06:21:40,320 --> 06:21:41,320
thing you might have noticed is this
9032
06:21:41,940 --> 06:21:42,940
little icon over here at the top right
9033
06:21:44,040 --> 06:21:45,040
hand side of any damage basically that
9034
06:21:47,760 --> 06:21:48,760
property is called blueprint Authority
9035
06:21:50,400 --> 06:21:51,400
only what it means is that you can only
9036
06:21:53,340 --> 06:21:54,340
call this on the server so you cannot
9037
06:21:56,700 --> 06:21:57,700
call this on the clients obviously you
9038
06:21:59,580 --> 06:22:00,580
don't want your players to be handling
9039
06:22:01,440 --> 06:22:02,440
the damage and stuff but anyways let's
9040
06:22:04,080 --> 06:22:05,080
actually go ahead and work on this logic
9041
06:22:06,718 --> 06:22:07,718
so when we left click we do the line
9042
06:22:08,760 --> 06:22:09,760
Trace thingy so let's bring up the line
9043
06:22:11,760 --> 06:22:12,760
Trace logic once again
9044
06:22:14,218 --> 06:22:15,218
so what we can do is we can line Trace
9045
06:22:17,280 --> 06:22:18,280
by Channel
9046
06:22:20,040 --> 06:22:21,040
and we get our camera manager get player
9047
06:22:24,420 --> 06:22:25,420
camera manager
9048
06:22:26,580 --> 06:22:27,580
get the after location
9049
06:22:29,638 --> 06:22:30,638
this is some stuff which we've already
9050
06:22:31,320 --> 06:22:32,320
done then we get the forward vector
9051
06:22:35,218 --> 06:22:36,218
and we multiply this by a certain value
9052
06:22:39,480 --> 06:22:40,480
so let's just convert this to a float
9053
06:22:43,320 --> 06:22:44,320
and let's multiply this by let's say 50
9054
06:22:46,080 --> 06:22:47,080
000. we are going to add this
9055
06:22:49,740 --> 06:22:50,740
together
9056
06:22:51,000 --> 06:22:52,000
and we can plug that into end and the
9057
06:22:53,760 --> 06:22:54,760
start
9058
06:22:55,500 --> 06:22:56,500
and from our output we can go ahead and
9059
06:22:59,760 --> 06:23:00,760
call apply damage
9060
06:23:02,040 --> 06:23:03,040
so there are multiple nodes apply damage
9061
06:23:04,138 --> 06:23:05,138
apply Point damage and apply radial
9062
06:23:06,058 --> 06:23:07,058
damage will do apply Point damage you
9063
06:23:08,340 --> 06:23:09,340
could just do apply damage
9064
06:23:10,378 --> 06:23:11,378
and base damage let's just give it a
9065
06:23:12,660 --> 06:23:13,660
value of 30. or just to keep things a
9066
06:23:16,020 --> 06:23:17,020
little more interesting so Random float
9067
06:23:17,940 --> 06:23:18,940
in range
9068
06:23:19,740 --> 06:23:20,740
so let's just say anything between 20
9069
06:23:22,378 --> 06:23:23,378
and 50 Maybe
9070
06:23:24,180 --> 06:23:25,180
so it's just going to select a random
9071
06:23:25,798 --> 06:23:26,798
number
9072
06:23:26,638 --> 06:23:27,638
and damage doctor is going to be the hit
9073
06:23:28,980 --> 06:23:29,980
actor obviously and damage causer is
9074
06:23:31,680 --> 06:23:32,680
going to be self
9075
06:23:33,180 --> 06:23:34,180
damage type is something we won't be
9076
06:23:35,100 --> 06:23:36,100
talking about and hit info we could just
9077
06:23:37,378 --> 06:23:38,378
pass in this whole hit result
9078
06:23:39,480 --> 06:23:40,480
so what we can do is instead of doing
9079
06:23:41,878 --> 06:23:42,878
this we can recombine this
9080
06:23:44,760 --> 06:23:45,760
pass this in here
9081
06:23:46,500 --> 06:23:47,500
and we can go ahead and break this
9082
06:23:48,360 --> 06:23:49,360
separately
9083
06:23:49,798 --> 06:23:50,798
so type in Brick
9084
06:23:51,900 --> 06:23:52,900
and pass the hit actor once again to the
9085
06:23:54,240 --> 06:23:55,240
damage actor
9086
06:23:55,620 --> 06:23:56,620
and we can collapse this as is hit from
9087
06:23:59,400 --> 06:24:00,400
Direction basically uh that is going to
9088
06:24:03,058 --> 06:24:04,058
be something which isn't really going to
9089
06:24:05,878 --> 06:24:06,878
affect your damage
9090
06:24:08,340 --> 06:24:09,340
but once you know the damage doctor's
9091
06:24:13,378 --> 06:24:14,378
location you can actually find the
9092
06:24:17,580 --> 06:24:18,580
direction towards it basically so what
9093
06:24:20,280 --> 06:24:21,280
we can do is you can do something like
9094
06:24:21,958 --> 06:24:22,958
this
9095
06:24:22,798 --> 06:24:23,798
so basically use this node called find
9096
06:24:25,378 --> 06:24:26,378
unit Direction so unit Direction
9097
06:24:29,520 --> 06:24:30,520
so get unit Direction
9098
06:24:31,558 --> 06:24:32,558
so it's going to be from our start to
9099
06:24:34,558 --> 06:24:35,558
our location and this is going to be our
9100
06:24:36,958 --> 06:24:37,958
hit from Direction
9101
06:24:39,240 --> 06:24:40,240
so basically uh this is a position
9102
06:24:41,820 --> 06:24:42,820
vector and this is a position Vector as
9103
06:24:44,280 --> 06:24:45,280
well so we can subtract it to get a
9104
06:24:47,160 --> 06:24:48,160
vector joining those two points
9105
06:24:49,260 --> 06:24:50,260
basically and now it should compile
9106
06:24:52,558 --> 06:24:53,558
if you really don't want to use this you
9107
06:24:54,840 --> 06:24:55,840
can go ahead and split this and this is
9108
06:24:57,000 --> 06:24:58,000
going to work as well it's just going to
9109
06:24:58,620 --> 06:24:59,620
construct a vector in place
9110
06:25:01,138 --> 06:25:02,138
so we'll recombine that and use that
9111
06:25:03,958 --> 06:25:04,958
and if I go ahead and press play
9112
06:25:05,940 --> 06:25:06,940
nothing's gonna happen but if I actually
9113
06:25:08,400 --> 06:25:09,400
drag our BPA here
9114
06:25:12,540 --> 06:25:13,540
and if I go ahead and press play
9115
06:25:16,740 --> 06:25:17,740
so as you can see
9116
06:25:19,260 --> 06:25:20,260
we are applying some random amount of
9117
06:25:21,360 --> 06:25:22,360
damage
9118
06:25:22,558 --> 06:25:23,558
so not sure why the lag exists
9119
06:25:26,280 --> 06:25:27,280
but anyways
9120
06:25:28,798 --> 06:25:29,798
now once that's done the next thing that
9121
06:25:31,620 --> 06:25:32,620
an actor provides us and also just one
9122
06:25:34,920 --> 06:25:35,920
one more note here so now we are talking
9123
06:25:37,558 --> 06:25:38,558
about the blueprint version of this
9124
06:25:39,420 --> 06:25:40,420
we'll also look at C plus plus stuff a
9125
06:25:41,940 --> 06:25:42,940
bit bit later there are a few things
9126
06:25:44,280 --> 06:25:45,280
that I would like to go over in C plus
9127
06:25:46,020 --> 06:25:47,020
plus as well so the next thing is hit
9128
06:25:49,200 --> 06:25:50,200
events now remember we had done the
9129
06:25:52,138 --> 06:25:53,138
overlap for a character so somewhere
9130
06:25:54,780 --> 06:25:55,780
over here so similar to that you also
9131
06:25:56,820 --> 06:25:57,820
have hit events so you just type in
9132
06:25:58,798 --> 06:25:59,798
event hit
9133
06:26:00,540 --> 06:26:01,540
and this is how we set up hit events you
9134
06:26:02,820 --> 06:26:03,820
also have hit events for each individual
9135
06:26:05,218 --> 06:26:06,218
component so if I click on the sphere if
9136
06:26:08,040 --> 06:26:09,040
I scroll down I can actually do on
9137
06:26:09,840 --> 06:26:10,840
component hit as well that works too
9138
06:26:13,138 --> 06:26:14,138
now other is going to be the actor which
9139
06:26:16,700 --> 06:26:17,700
actually hit this
9140
06:26:20,120 --> 06:26:21,120
and other component is basically the
9141
06:26:23,458 --> 06:26:24,458
component of the other actor which hit
9142
06:26:25,320 --> 06:26:26,320
it my component is going to be the
9143
06:26:28,080 --> 06:26:29,080
component in this sector which actually
9144
06:26:30,058 --> 06:26:31,058
hit the other actor
9145
06:26:31,860 --> 06:26:32,860
and hit location is the hit location of
9146
06:26:34,080 --> 06:26:35,080
course and we also get a hit result so
9147
06:26:37,620 --> 06:26:38,620
way too much for what you need so that's
9148
06:26:39,900 --> 06:26:40,900
generally the reason why when I actually
9149
06:26:42,000 --> 06:26:43,000
work on these things I I just create an
9150
06:26:44,520 --> 06:26:45,520
interface myself
9151
06:26:46,080 --> 06:26:47,080
because generally you really don't
9152
06:26:48,240 --> 06:26:49,240
require all of these things in order for
9153
06:26:50,878 --> 06:26:51,878
your damage logic to work
9154
06:26:52,920 --> 06:26:53,920
anyways I'll show you guys how this is
9155
06:26:55,200 --> 06:26:56,200
gonna work so if I just go ahead and
9156
06:26:56,878 --> 06:26:57,878
print this
9157
06:26:58,020 --> 06:26:59,020
and one handy node here is you can
9158
06:27:01,138 --> 06:27:02,138
actually get this and if you can type in
9159
06:27:03,298 --> 06:27:04,298
get display name
9160
06:27:04,860 --> 06:27:05,860
and you're going to get
9161
06:27:07,020 --> 06:27:08,020
the display name of the object basically
9162
06:27:09,360 --> 06:27:10,360
if my character bumps into this so let
9163
06:27:11,820 --> 06:27:12,820
me do that real quick okay I can't it's
9164
06:27:15,420 --> 06:27:16,420
too high so let's bring that down
9165
06:27:19,620 --> 06:27:20,620
so if I actually bump into this as you
9166
06:27:21,660 --> 06:27:22,660
can see you get BP character the reason
9167
06:27:24,780 --> 06:27:25,780
it's printing it so many times is
9168
06:27:26,820 --> 06:27:27,820
because we are in contact with it for
9169
06:27:29,100 --> 06:27:30,100
quite some time
9170
06:27:30,360 --> 06:27:31,360
so when we are in contact and we are
9171
06:27:32,700 --> 06:27:33,700
sliding on it each frame it counts a new
9172
06:27:36,298 --> 06:27:37,298
hit basically that's the reason it's
9173
06:27:38,100 --> 06:27:39,100
happening all right so the next thing
9174
06:27:40,260 --> 06:27:41,260
that I would like to touch upon when it
9175
06:27:42,120 --> 06:27:43,120
comes to actors is the construction
9176
06:27:43,680 --> 06:27:44,680
script so this is similar to your
9177
06:27:46,138 --> 06:27:47,138
default Constructor in C plus plus now
9178
06:27:48,660 --> 06:27:49,660
there is a way to actually uh get an
9179
06:27:51,480 --> 06:27:52,480
equivalent of a parameterized
9180
06:27:53,280 --> 06:27:54,280
Constructor I will get to that both in
9181
06:27:55,740 --> 06:27:56,740
Blueprint and C plus plus but first
9182
06:27:58,138 --> 06:27:59,138
let's work with this so let's say I drag
9183
06:28:00,120 --> 06:28:01,120
this in now every time I update this
9184
06:28:03,180 --> 06:28:04,180
actor the construction script is
9185
06:28:05,878 --> 06:28:06,878
actually called so let me just show you
9186
06:28:08,700 --> 06:28:09,700
guys so if I just go ahead and print
9187
06:28:10,200 --> 06:28:11,200
string
9188
06:28:11,700 --> 06:28:12,700
and if I go ahead and move this actually
9189
06:28:13,440 --> 06:28:14,440
so first let me compile that
9190
06:28:16,080 --> 06:28:17,080
save it and now if I head back as you
9191
06:28:19,200 --> 06:28:20,200
can see every time I move it it actually
9192
06:28:21,120 --> 06:28:22,120
prints hello
9193
06:28:22,558 --> 06:28:23,558
basically every time you spawn this
9194
06:28:25,558 --> 06:28:26,558
actor or you update this actor in the
9195
06:28:28,080 --> 06:28:29,080
level this construction script is called
9196
06:28:30,420 --> 06:28:31,420
at runtime it's only going to be called
9197
06:28:33,298 --> 06:28:34,298
when you actually spawn it but over here
9198
06:28:36,840 --> 06:28:37,840
in the editor whenever you move it it's
9199
06:28:38,878 --> 06:28:39,878
going to be called each time there's
9200
06:28:40,378 --> 06:28:41,378
actually an option somewhere in the
9201
06:28:41,940 --> 06:28:42,940
class settings
9202
06:28:43,138 --> 06:28:44,138
so run construction script on drag so
9203
06:28:46,138 --> 06:28:47,138
you can disable that if you don't want
9204
06:28:48,600 --> 06:28:49,600
that to happen so it's it's only going
9205
06:28:51,298 --> 06:28:52,298
to call it once you finish placing it
9206
06:28:54,660 --> 06:28:55,660
I'll just leave it as is
9207
06:28:56,878 --> 06:28:57,878
now if you want a parameterized
9208
06:28:58,920 --> 06:28:59,920
Constructor
9209
06:29:00,180 --> 06:29:01,180
basically let's say you wanted to set a
9210
06:29:02,340 --> 06:29:03,340
variable so let's call this
9211
06:29:04,860 --> 06:29:05,860
uh I don't know maybe some float
9212
06:29:07,320 --> 06:29:08,320
variable
9213
06:29:08,820 --> 06:29:09,820
and we'll make this of type float now if
9214
06:29:11,940 --> 06:29:12,940
you want to actually set the value of
9215
06:29:14,340 --> 06:29:15,340
this outside like a parameterized
9216
06:29:16,200 --> 06:29:17,200
Constructor
9217
06:29:17,280 --> 06:29:18,280
first select this variable
9218
06:29:19,680 --> 06:29:20,680
and head into
9219
06:29:21,660 --> 06:29:22,660
this option right there select instance
9220
06:29:24,540 --> 06:29:25,540
editable and expose on spawn
9221
06:29:27,240 --> 06:29:28,240
now what you've essentially done is your
9222
06:29:29,280 --> 06:29:30,280
basically exposed this when you actually
9223
06:29:32,458 --> 06:29:33,458
call the spawn act a function
9224
06:29:35,160 --> 06:29:36,160
so if I just head into my character and
9225
06:29:37,138 --> 06:29:38,138
spawn this on begin play so I'll just
9226
06:29:39,298 --> 06:29:40,298
leave this BP pickup and let me just do
9227
06:29:42,058 --> 06:29:43,058
this actor instead so BP underscore a
9228
06:29:46,378 --> 06:29:47,378
now Health points is not a parameter so
9229
06:29:49,320 --> 06:29:50,320
you can alt click that to delete the pin
9230
06:29:51,480 --> 06:29:52,480
now as you can see
9231
06:29:53,700 --> 06:29:54,700
we can select some float
9232
06:29:56,700 --> 06:29:57,700
so I can set this to whatever I want
9233
06:29:59,940 --> 06:30:00,940
now this is something which we touched
9234
06:30:02,638 --> 06:30:03,638
upon
9235
06:30:03,840 --> 06:30:04,840
however there is an equivalent of this
9236
06:30:06,780 --> 06:30:07,780
in C plus plus as well
9237
06:30:09,120 --> 06:30:10,120
but it is a little more complicated than
9238
06:30:11,760 --> 06:30:12,760
this
9239
06:30:12,958 --> 06:30:13,958
so if we actually head into our Visual
9240
06:30:15,480 --> 06:30:16,480
Studio solution
9241
06:30:18,298 --> 06:30:19,298
all right so now that we are in C plus
9242
06:30:20,638 --> 06:30:21,638
plus now let's actually test it out with
9243
06:30:23,638 --> 06:30:24,638
our CPP underscore actor so let's go
9244
06:30:27,480 --> 06:30:28,480
ahead and spawn this from our character
9245
06:30:30,420 --> 06:30:31,420
or if we have anything else we could try
9246
06:30:32,940 --> 06:30:33,940
that as well so our interaction actor
9247
06:30:35,218 --> 06:30:36,218
maybe if we could try that so we can
9248
06:30:38,040 --> 06:30:39,040
spawn our interaction actor
9249
06:30:40,860 --> 06:30:41,860
now if we go ahead and head in here
9250
06:30:45,600 --> 06:30:46,600
inside our character's header file
9251
06:30:49,798 --> 06:30:50,798
so we can go ahead and include that as
9252
06:30:51,840 --> 06:30:52,840
well so hash include
9253
06:30:54,780 --> 06:30:55,780
and we can go ahead and include CPP
9254
06:30:57,480 --> 06:30:58,480
interactionactor.h
9255
06:31:01,020 --> 06:31:02,020
now let's actually create a function or
9256
06:31:03,000 --> 06:31:04,000
we can do it on begin play so head into
9257
06:31:05,160 --> 06:31:06,160
begin play
9258
06:31:07,860 --> 06:31:08,860
now after we are done with this or we
9259
06:31:09,900 --> 06:31:10,900
can actually just remove this logic we
9260
06:31:11,760 --> 06:31:12,760
aren't really using this
9261
06:31:13,500 --> 06:31:14,500
the way you spawn actors in C plus plus
9262
06:31:15,718 --> 06:31:16,718
is by calling the spawn actor function
9263
06:31:18,298 --> 06:31:19,298
from world
9264
06:31:20,100 --> 06:31:21,100
so in order to get your world you call
9265
06:31:21,900 --> 06:31:22,900
this function known as get word
9266
06:31:25,760 --> 06:31:26,760
and from here you can go ahead and call
9267
06:31:28,680 --> 06:31:29,680
spawn actor
9268
06:31:30,840 --> 06:31:31,840
and this actually takes in a template
9269
06:31:33,540 --> 06:31:34,540
argument
9270
06:31:34,500 --> 06:31:35,500
and this is going to be the type which
9271
06:31:37,500 --> 06:31:38,500
this spawn actor function will return
9272
06:31:40,500 --> 06:31:41,500
so it is going to be acpp interaction
9273
06:31:43,320 --> 06:31:44,320
actor
9274
06:31:44,638 --> 06:31:45,638
and I could just spawn it like that it's
9275
06:31:46,740 --> 06:31:47,740
going to take in all the default
9276
06:31:48,120 --> 06:31:49,120
parameters you can actually set up
9277
06:31:49,680 --> 06:31:50,680
subclasses and stuff so let's say
9278
06:31:51,958 --> 06:31:52,958
instead of CPP interaction actor you
9279
06:31:54,298 --> 06:31:55,298
want it to spawn some derived class of
9280
06:31:56,820 --> 06:31:57,820
it which is there in Blueprint you could
9281
06:31:58,860 --> 06:31:59,860
do that totally
9282
06:32:00,360 --> 06:32:01,360
so let's say I wanted to spawn BP
9283
06:32:03,058 --> 06:32:04,058
interaction actor and not CPP
9284
06:32:05,160 --> 06:32:06,160
interaction actor so we can actually
9285
06:32:06,660 --> 06:32:07,660
test that theory actually
9286
06:32:09,480 --> 06:32:10,480
so BP
9287
06:32:11,660 --> 06:32:12,660
interaction actors pond
9288
06:32:15,298 --> 06:32:16,298
I mean the spelling doesn't really
9289
06:32:17,218 --> 06:32:18,218
matter here
9290
06:32:18,660 --> 06:32:19,660
so let's delete whatever's there in the
9291
06:32:21,180 --> 06:32:22,180
level so BP interaction actor
9292
06:32:24,600 --> 06:32:25,600
so interaction actor so I'll just go
9293
06:32:27,420 --> 06:32:28,420
ahead and delete that now if I press
9294
06:32:29,580 --> 06:32:30,580
play I'm not really getting that
9295
06:32:32,638 --> 06:32:33,638
so what I can do this is going to spawn
9296
06:32:35,040 --> 06:32:36,040
your CPP interaction actor
9297
06:32:37,740 --> 06:32:38,740
but if we actually have a variable here
9298
06:32:40,320 --> 06:32:41,320
which stores the exact class which we
9299
06:32:43,320 --> 06:32:44,320
are spawning so we can do that right
9300
06:32:45,298 --> 06:32:46,298
there so you property
9301
06:32:48,320 --> 06:32:49,320
make this one edit anywhere
9302
06:32:54,480 --> 06:32:55,480
and make this one blueprint read write
9303
06:32:56,700 --> 06:32:57,700
as well
9304
06:32:59,400 --> 06:33:00,400
now what we can do is we can go ahead
9305
06:33:01,558 --> 06:33:02,558
and pass this in so the type which you
9306
06:33:04,440 --> 06:33:05,440
use is T sub class of
9307
06:33:08,218 --> 06:33:09,218
and obviously we are looking for a
9308
06:33:10,680 --> 06:33:11,680
derived class of
9309
06:33:13,340 --> 06:33:14,340
acpp interaction actor so we'll just
9310
06:33:16,378 --> 06:33:17,378
copy that over
9311
06:33:18,480 --> 06:33:19,480
so this is going to be prefixed with an
9312
06:33:20,458 --> 06:33:21,458
a
9313
06:33:21,240 --> 06:33:22,240
and we'll call this one class to spawn
9314
06:33:24,420 --> 06:33:25,420
or rather we can call it actor to spawn
9315
06:33:28,378 --> 06:33:29,378
now this will be available to us in our
9316
06:33:30,360 --> 06:33:31,360
blueprint
9317
06:33:32,100 --> 06:33:33,100
now one thing to remember you have to
9318
06:33:33,840 --> 06:33:34,840
make sure it is actually valid
9319
06:33:36,298 --> 06:33:37,298
so if
9320
06:33:37,920 --> 06:33:38,920
r
9321
06:33:40,080 --> 06:33:41,080
reference is valid here so our subclass
9322
06:33:42,600 --> 06:33:43,600
is basically so if this class reference
9323
06:33:45,120 --> 06:33:46,120
so if actor to spawn is valid
9324
06:33:48,420 --> 06:33:49,420
only then we are actually going to be
9325
06:33:51,180 --> 06:33:52,180
spawning this actor
9326
06:33:53,218 --> 06:33:54,218
and over here in the arguments list you
9327
06:33:55,740 --> 06:33:56,740
can go ahead and pass this in
9328
06:33:58,020 --> 06:33:59,020
and paste this in
9329
06:33:59,760 --> 06:34:00,760
and you can also pass in a transform
9330
06:34:01,680 --> 06:34:02,680
optionally but I won't be doing that
9331
06:34:05,218 --> 06:34:06,218
now let's actually pass in some
9332
06:34:07,920 --> 06:34:08,920
parameters
9333
06:34:09,180 --> 06:34:10,180
so if you want to pass in a parameter
9334
06:34:11,340 --> 06:34:12,340
using your deferred spawn actor as I
9335
06:34:15,058 --> 06:34:16,058
would call it as the function is called
9336
06:34:17,878 --> 06:34:18,878
so we can actually do that with the same
9337
06:34:20,100 --> 06:34:21,100
thing
9338
06:34:21,120 --> 06:34:22,120
so let's create a variable here which we
9339
06:34:24,120 --> 06:34:25,120
would want to edit
9340
06:34:26,040 --> 06:34:27,040
so under the public section we can go
9341
06:34:28,620 --> 06:34:29,620
ahead and create a new property
9342
06:34:31,500 --> 06:34:32,500
we don't need this to be blueprint read
9343
06:34:33,780 --> 06:34:34,780
write or anything so we can call this
9344
06:34:35,458 --> 06:34:36,458
one in
9345
06:34:36,958 --> 06:34:37,958
some variable
9346
06:34:40,200 --> 06:34:41,200
and the way you would set default values
9347
06:34:42,120 --> 06:34:43,120
for this
9348
06:34:43,378 --> 06:34:44,378
is if I go ahead and write the function
9349
06:34:46,138 --> 06:34:47,138
again so this is how it's spawn an actor
9350
06:34:49,138 --> 06:34:50,138
here you would have what's going to be
9351
06:34:52,500 --> 06:34:53,500
returned so if I actually do Auto
9352
06:34:55,500 --> 06:34:56,500
temp equals
9353
06:34:58,260 --> 06:34:59,260
spawn actor interaction actor basically
9354
06:35:01,400 --> 06:35:02,400
this temp will be of type ACP
9355
06:35:04,680 --> 06:35:05,680
interaction actor pointer so pointer to
9356
06:35:07,200 --> 06:35:08,200
this point actor will be uh returned
9357
06:35:11,100 --> 06:35:12,100
now
9358
06:35:12,540 --> 06:35:13,540
what what we can do is we can spawn
9359
06:35:14,218 --> 06:35:15,218
another one actually so we'll just do
9360
06:35:16,620 --> 06:35:17,620
Auto
9361
06:35:17,820 --> 06:35:18,820
temp one equals
9362
06:35:20,280 --> 06:35:21,280
we can just go ahead and copy this
9363
06:35:23,780 --> 06:35:24,780
and instead of this we can do spawn
9364
06:35:26,700 --> 06:35:27,700
actor deferred
9365
06:35:30,480 --> 06:35:31,480
and just make sure to get the spelling
9366
06:35:32,340 --> 06:35:33,340
right so spawn actor
9367
06:35:35,700 --> 06:35:36,700
deferred so for this one we have to pass
9368
06:35:39,240 --> 06:35:40,240
in the transform so we can just uh write
9369
06:35:42,540 --> 06:35:43,540
a Constructor over here so F transform
9370
06:35:48,298 --> 06:35:49,298
and that should compile but once you
9371
06:35:51,360 --> 06:35:52,360
call this function the actor is actually
9372
06:35:53,100 --> 06:35:54,100
not spawned now since we have a pointer
9373
06:35:56,760 --> 06:35:57,760
to our actor we can go ahead and call
9374
06:35:59,340 --> 06:36:00,340
this function known as finished spawning
9375
06:36:02,878 --> 06:36:03,878
so if I type in Finish spawning this is
9376
06:36:06,840 --> 06:36:07,840
going to actually complete the spawning
9377
06:36:08,760 --> 06:36:09,760
process
9378
06:36:09,718 --> 06:36:10,718
now you can just again pass in the
9379
06:36:12,600 --> 06:36:13,600
default transform
9380
06:36:16,260 --> 06:36:17,260
so once this is done
9381
06:36:18,600 --> 06:36:19,600
our spawning would actually be complete
9382
06:36:21,180 --> 06:36:22,180
and in between this is where you can
9383
06:36:23,760 --> 06:36:24,760
actually set your variables
9384
06:36:26,458 --> 06:36:27,458
so you don't have a parameterized
9385
06:36:28,378 --> 06:36:29,378
Constructor but now we can go ahead and
9386
06:36:30,180 --> 06:36:31,180
set our some variables so some variable
9387
06:36:32,280 --> 06:36:33,280
equals 100.
9388
06:36:34,940 --> 06:36:35,940
obviously temp one
9389
06:36:37,980 --> 06:36:38,980
and now what we can do is in our
9390
06:36:40,680 --> 06:36:41,680
interaction actor we can go ahead and
9391
06:36:42,360 --> 06:36:43,360
just print it on begin play so you
9392
06:36:44,580 --> 06:36:45,580
Kismet system Library print string and
9393
06:36:48,180 --> 06:36:49,180
we can go ahead and
9394
06:36:53,700 --> 06:36:54,700
continue with this and go ahead and
9395
06:36:56,638 --> 06:36:57,638
print in
9396
06:36:57,958 --> 06:36:58,958
F string
9397
06:37:00,298 --> 06:37:01,298
from end
9398
06:37:01,980 --> 06:37:02,980
and we can pass in our value here so
9399
06:37:05,458 --> 06:37:06,458
some variable
9400
06:37:07,138 --> 06:37:08,138
is what we want
9401
06:37:11,458 --> 06:37:12,458
and that should be about it
9402
06:37:15,900 --> 06:37:16,900
now if we go ahead and run a debugger
9403
06:37:18,660 --> 06:37:19,660
here everything should work as expected
9404
06:37:20,878 --> 06:37:21,878
just make sure you close the editor
9405
06:37:23,218 --> 06:37:24,218
before you actually build it so
9406
06:37:27,900 --> 06:37:28,900
so now if we go ahead and press play we
9407
06:37:30,540 --> 06:37:31,540
shouldn't see any print strings
9408
06:37:32,638 --> 06:37:33,638
and this proves that our if check here
9409
06:37:35,700 --> 06:37:36,700
is actually working if we would have
9410
06:37:38,400 --> 06:37:39,400
removed this if check our engine would
9411
06:37:40,620 --> 06:37:41,620
have crashed since this actor to spawn
9412
06:37:43,680 --> 06:37:44,680
class reference would be invalid anyways
9413
06:37:46,320 --> 06:37:47,320
we can set that since we have exposed it
9414
06:37:48,058 --> 06:37:49,058
to blueprint so in our character I
9415
06:37:50,638 --> 06:37:51,638
assume so this is in CPP character so
9416
06:37:53,878 --> 06:37:54,878
it's going to be inherited into BP
9417
06:37:55,798 --> 06:37:56,798
character
9418
06:37:56,878 --> 06:37:57,878
and under your class defaults over here
9419
06:38:01,080 --> 06:38:02,080
you should be able to find your variable
9420
06:38:06,780 --> 06:38:07,780
so CPP character under the third section
9421
06:38:09,600 --> 06:38:10,600
here actor to spawn and we can select
9422
06:38:12,180 --> 06:38:13,180
our BP interaction actor if I go ahead
9423
06:38:15,298 --> 06:38:16,298
and press play now as you can see we get
9424
06:38:17,760 --> 06:38:18,760
two prints along with one zero and one
9425
06:38:21,058 --> 06:38:22,058
hundred for our
9426
06:38:22,860 --> 06:38:23,860
Pond actors now the first ones are 0
9427
06:38:25,798 --> 06:38:26,798
because in our first Pawn actor function
9428
06:38:27,900 --> 06:38:28,900
we actually didn't set any of the values
9429
06:38:30,780 --> 06:38:31,780
so this was our class X Pawn actor
9430
06:38:34,320 --> 06:38:35,320
and in the second one we actually use
9431
06:38:36,780 --> 06:38:37,780
the Deferred spawn actor which let us
9432
06:38:40,320 --> 06:38:41,320
set the default values before calling
9433
06:38:42,780 --> 06:38:43,780
the construction script
9434
06:38:44,520 --> 06:38:45,520
so this is basically how we would
9435
06:38:46,320 --> 06:38:47,320
simulate the parameterized Constructor
9436
06:38:48,360 --> 06:38:49,360
in Unreal Engine in both blueprint as
9437
06:38:52,138 --> 06:38:53,138
well as C plus plus
9438
06:38:54,340 --> 06:38:55,340
[Music]
9439
06:38:58,620 --> 06:38:59,620
now the next class that I would like to
9440
06:39:01,740 --> 06:39:02,740
mention here is going to be the
9441
06:39:03,780 --> 06:39:04,780
character class and we have used that
9442
06:39:06,360 --> 06:39:07,360
quite a bit so if we just open up our BP
9443
06:39:08,820 --> 06:39:09,820
character for example which is a
9444
06:39:10,558 --> 06:39:11,558
character class so we have inherited
9445
06:39:12,958 --> 06:39:13,958
from CPP character just to keep things
9446
06:39:15,180 --> 06:39:16,180
clean and just create a new character
9447
06:39:16,860 --> 06:39:17,860
here
9448
06:39:17,580 --> 06:39:18,580
and let let this just be called new
9449
06:39:20,160 --> 06:39:21,160
character Maybe
9450
06:39:22,980 --> 06:39:23,980
now open it up now if I were to just
9451
06:39:26,400 --> 06:39:27,400
look at the parent class it says
9452
06:39:28,020 --> 06:39:29,020
character
9453
06:39:29,718 --> 06:39:30,718
and character is actually a derived
9454
06:39:33,298 --> 06:39:34,298
class of Pawn so basically every
9455
06:39:36,120 --> 06:39:37,120
character is a pawn and pawn is a
9456
06:39:39,958 --> 06:39:40,958
derived class of actors so when I'm
9457
06:39:42,480 --> 06:39:43,480
talking about characters I am
9458
06:39:44,218 --> 06:39:45,218
collectively referring to both pawns and
9459
06:39:47,100 --> 06:39:48,100
characters basically
9460
06:39:49,020 --> 06:39:50,020
every character is going to be a pawn
9461
06:39:51,420 --> 06:39:52,420
now
9462
06:39:53,100 --> 06:39:54,100
the reason why I especially wanted to
9463
06:39:55,500 --> 06:39:56,500
mention this even though this is
9464
06:39:57,240 --> 06:39:58,240
technically just a derived class of
9465
06:39:59,040 --> 06:40:00,040
factor and probably probably many other
9466
06:40:01,440 --> 06:40:02,440
classes which I'll mention further are
9467
06:40:03,360 --> 06:40:04,360
derived class of factors is due to this
9468
06:40:06,298 --> 06:40:07,298
character movement component now this
9469
06:40:08,760 --> 06:40:09,760
allows you to do various things now if
9470
06:40:11,340 --> 06:40:12,340
you were to just go ahead and look into
9471
06:40:14,100 --> 06:40:15,100
these parameters
9472
06:40:15,718 --> 06:40:16,718
you can actually have a pretty basic
9473
06:40:17,700 --> 06:40:18,700
idea on what you can do at the beginning
9474
06:40:19,260 --> 06:40:20,260
of the course if you remember I had
9475
06:40:22,080 --> 06:40:23,080
mentioned that you can actually use
9476
06:40:24,240 --> 06:40:25,240
functions to modify almost any of these
9477
06:40:28,020 --> 06:40:29,020
values not all but most of these values
9478
06:40:30,420 --> 06:40:31,420
at runtime so for example now let's just
9479
06:40:33,900 --> 06:40:34,900
take our BP character for example and
9480
06:40:36,480 --> 06:40:37,480
let's go ahead and press play and we
9481
06:40:38,100 --> 06:40:39,100
know that we're using this
9482
06:40:40,218 --> 06:40:41,218
so we are walking forward but what if
9483
06:40:44,218 --> 06:40:45,218
this feels a little bit too fast for you
9484
06:40:46,860 --> 06:40:47,860
now this is where our character movement
9485
06:40:49,500 --> 06:40:50,500
component is going to help us
9486
06:40:51,780 --> 06:40:52,780
so the maximum speed of this character
9487
06:40:54,900 --> 06:40:55,900
is actually set by a variable inside
9488
06:40:56,940 --> 06:40:57,940
here so if I just drag this in and if I
9489
06:40:59,638 --> 06:41:00,638
type in set max
9490
06:41:02,580 --> 06:41:03,580
walk speed
9491
06:41:04,558 --> 06:41:05,558
as you can see we are able to set some
9492
06:41:07,138 --> 06:41:08,138
value over here so I'll just do this on
9493
06:41:09,480 --> 06:41:10,480
begin play you could do it somewhere
9494
06:41:11,040 --> 06:41:12,040
else as well
9495
06:41:12,180 --> 06:41:13,180
but let's say we wanted him to go only
9496
06:41:14,878 --> 06:41:15,878
at 500 default is 600 by the way
9497
06:41:18,180 --> 06:41:19,180
now if I go ahead and press play you see
9498
06:41:20,520 --> 06:41:21,520
that he moves a little bit more slowly
9499
06:41:22,860 --> 06:41:23,860
now if you feel this is a now one more
9500
06:41:26,520 --> 06:41:27,520
thing is that the animation will also
9501
06:41:28,080 --> 06:41:29,080
slow down along with his speed so that's
9502
06:41:30,240 --> 06:41:31,240
not something which you should really be
9503
06:41:31,740 --> 06:41:32,740
seeing in this example
9504
06:41:33,420 --> 06:41:34,420
so we are moving slower let's say we
9505
06:41:35,638 --> 06:41:36,638
wanted him to move a little more fast so
9506
06:41:37,860 --> 06:41:38,860
let's say we have 1000
9507
06:41:39,718 --> 06:41:40,718
we can go ahead and set the speed and
9508
06:41:42,298 --> 06:41:43,298
now we walk much much faster
9509
06:41:44,760 --> 06:41:45,760
so stuff like this
9510
06:41:46,700 --> 06:41:47,700
and one more useful thing which the
9511
06:41:49,740 --> 06:41:50,740
character movement component provides us
9512
06:41:51,360 --> 06:41:52,360
is movement modes so if I just type in
9513
06:41:53,940 --> 06:41:54,940
movement mode
9514
06:41:55,558 --> 06:41:56,558
and get movement mode you can actually
9515
06:41:58,080 --> 06:41:59,080
see this is an enumeration we can just
9516
06:41:59,760 --> 06:42:00,760
do switch to see what are the
9517
06:42:01,260 --> 06:42:02,260
enumerators here as you can see we have
9518
06:42:03,840 --> 06:42:04,840
walking nav mesh walking which is for AI
9519
06:42:06,540 --> 06:42:07,540
basically falling
9520
06:42:08,638 --> 06:42:09,638
swimming flying and Custom
9521
06:42:12,120 --> 06:42:13,120
now there are various things you could
9522
06:42:14,100 --> 06:42:15,100
even do with this uh apart from
9523
06:42:16,500 --> 06:42:17,500
switching between them you can actually
9524
06:42:17,878 --> 06:42:18,878
set the movement mode
9525
06:42:20,458 --> 06:42:21,458
so for example if I just change this to
9526
06:42:23,760 --> 06:42:24,760
Flying for example
9527
06:42:26,940 --> 06:42:27,940
and if I go ahead and press play
9528
06:42:30,958 --> 06:42:31,958
now you will notice that this behaves a
9529
06:42:33,240 --> 06:42:34,240
little bit differently now if the
9530
06:42:36,058 --> 06:42:37,058
movement mode is flying
9531
06:42:37,920 --> 06:42:38,920
if I go further
9532
06:42:40,200 --> 06:42:41,200
as you would see
9533
06:42:42,240 --> 06:42:43,240
he's actually floating in the air
9534
06:42:44,638 --> 06:42:45,638
so when you actually set this movement
9535
06:42:46,980 --> 06:42:47,980
mode to Flying basically it also allows
9536
06:42:49,558 --> 06:42:50,558
you to take vertical movement input so
9537
06:42:52,378 --> 06:42:53,378
apart from your move forward and
9538
06:42:54,660 --> 06:42:55,660
backward you could also do up and down
9539
06:42:56,280 --> 06:42:57,280
so let me actually do that so where we
9540
06:42:58,740 --> 06:42:59,740
have our add movement input instead of
9541
06:43:01,440 --> 06:43:02,440
forward if I do up Vector so get actor
9542
06:43:05,100 --> 06:43:06,100
up Vector
9543
06:43:07,378 --> 06:43:08,378
if I just do something like this and if
9544
06:43:10,320 --> 06:43:11,320
I go ahead and hit W as you can see we
9545
06:43:12,240 --> 06:43:13,240
can actually go up and down as well
9546
06:43:16,200 --> 06:43:17,200
so this is something cool which you
9547
06:43:17,878 --> 06:43:18,878
could do and there are a few functions
9548
06:43:19,920 --> 06:43:20,920
which I would specifically like to talk
9549
06:43:21,840 --> 06:43:22,840
about right now and one of them is
9550
06:43:24,540 --> 06:43:25,540
launch character launch character so
9551
06:43:27,540 --> 06:43:28,540
let's say I wanted to implement a jump
9552
06:43:29,218 --> 06:43:30,218
pad or something so let's just do it
9553
06:43:31,558 --> 06:43:32,558
after a delay so
9554
06:43:34,138 --> 06:43:35,138
delay of about 2 seconds
9555
06:43:37,260 --> 06:43:38,260
and we can go ahead and give something
9556
06:43:40,020 --> 06:43:41,020
for the launch velocity let's just give
9557
06:43:41,940 --> 06:43:42,940
10 000 Maybe
9558
06:43:44,100 --> 06:43:45,100
now if I go ahead and press play
9559
06:43:47,280 --> 06:43:48,280
as you can see
9560
06:43:49,138 --> 06:43:50,138
we were launched in the air I mean I
9561
06:43:51,420 --> 06:43:52,420
just gave a really high value for the
9562
06:43:53,218 --> 06:43:54,218
launch velocity let's say we give
9563
06:43:55,860 --> 06:43:56,860
something like 3000 Maybe
9564
06:43:58,320 --> 06:43:59,320
if I go ahead and press play
9565
06:44:01,080 --> 06:44:02,080
as you can see we are launched in the
9566
06:44:03,058 --> 06:44:04,058
air so if you had something like a jump
9567
06:44:05,520 --> 06:44:06,520
pad or something which you wanted to
9568
06:44:07,080 --> 06:44:08,080
implement this is a really cool way to
9569
06:44:09,540 --> 06:44:10,540
do this and the best part about all this
9570
06:44:12,058 --> 06:44:13,058
is this is actually networked by default
9571
06:44:14,340 --> 06:44:15,340
most of this logic if you just run on
9572
06:44:17,160 --> 06:44:18,160
the server is just going to run well for
9573
06:44:20,340 --> 06:44:21,340
multiplayer as well
9574
06:44:22,200 --> 06:44:23,200
so that's one thing so launch character
9575
06:44:24,958 --> 06:44:25,958
and stuff like that there are actually
9576
06:44:27,058 --> 06:44:28,058
many other functions which
9577
06:44:29,760 --> 06:44:30,760
you would have access to one way to
9578
06:44:32,218 --> 06:44:33,218
actually take advantage of the context
9579
06:44:34,320 --> 06:44:35,320
sensitive menu is if you just drag off
9580
06:44:36,480 --> 06:44:37,480
of self
9581
06:44:37,760 --> 06:44:38,760
and if you can just head into character
9582
06:44:42,660 --> 06:44:43,660
you can actually look into various
9583
06:44:45,718 --> 06:44:46,718
functions over here
9584
06:44:47,160 --> 06:44:48,160
this is what I find useful you can act
9585
06:44:49,920 --> 06:44:50,920
apart from launch character few more
9586
06:44:52,138 --> 06:44:53,138
functions which I would like to go over
9587
06:44:53,458 --> 06:44:54,458
or Crouch
9588
06:44:55,200 --> 06:44:56,200
so if you set your movement mode to
9589
06:44:57,240 --> 06:44:58,240
crouch
9590
06:44:58,138 --> 06:44:59,138
and make sure you have you can Crouch so
9591
06:45:01,680 --> 06:45:02,680
there should be an option somewhere here
9592
06:45:03,180 --> 06:45:04,180
so Crouch
9593
06:45:05,340 --> 06:45:06,340
should be under character movement can
9594
06:45:07,378 --> 06:45:08,378
Crouch make sure that is true
9595
06:45:09,540 --> 06:45:10,540
otherwise it's not gonna work make sure
9596
06:45:11,280 --> 06:45:12,280
this is true and if you go ahead and hit
9597
06:45:13,378 --> 06:45:14,378
Crouch
9598
06:45:14,700 --> 06:45:15,700
and one thing that I would like to show
9599
06:45:16,320 --> 06:45:17,320
you guys is by setting this hidden in
9600
06:45:20,100 --> 06:45:21,100
game to false so let this be visible in
9601
06:45:22,558 --> 06:45:23,558
the game
9602
06:45:24,120 --> 06:45:25,120
now if I go ahead and take a look at
9603
06:45:27,240 --> 06:45:28,240
this
9604
06:45:29,040 --> 06:45:30,040
as you can see everything seems normal
9605
06:45:31,440 --> 06:45:32,440
here
9606
06:45:32,700 --> 06:45:33,700
let's actually just disable some of this
9607
06:45:35,638 --> 06:45:36,638
logic
9608
06:45:38,340 --> 06:45:39,340
all right so I'll go ahead and Crouch
9609
06:45:43,080 --> 06:45:44,080
so if I go ahead and Crouch as you can
9610
06:45:45,900 --> 06:45:46,900
see
9611
06:45:46,680 --> 06:45:47,680
our
9612
06:45:48,480 --> 06:45:49,480
capsule whatever we had is actually
9613
06:45:50,940 --> 06:45:51,940
shrunk
9614
06:45:53,100 --> 06:45:54,100
this is basically our Collision now so
9615
06:45:56,160 --> 06:45:57,160
let's say you couldn't pass under some
9616
06:45:58,138 --> 06:45:59,138
things now you can actually so I'll just
9617
06:46:00,958 --> 06:46:01,958
drag this a little bit below average
9618
06:46:03,958 --> 06:46:04,958
character height
9619
06:46:05,280 --> 06:46:06,280
so let's say about this much
9620
06:46:08,400 --> 06:46:09,400
and our walking speed is also very less
9621
06:46:10,980 --> 06:46:11,980
even though we set it to thousand
9622
06:46:12,480 --> 06:46:13,480
manually now as you can see our
9623
06:46:14,520 --> 06:46:15,520
Collision is only up to the capsule you
9624
06:46:16,798 --> 06:46:17,798
can change the height by the way
9625
06:46:18,958 --> 06:46:19,958
so if I just type in Crouch I should
9626
06:46:22,138 --> 06:46:23,138
find Crouch half height you can actually
9627
06:46:23,760 --> 06:46:24,760
increase that no issues with that and as
9628
06:46:26,280 --> 06:46:27,280
you can see now this has a separate Max
9629
06:46:28,320 --> 06:46:29,320
walk speed so stuff like this is already
9630
06:46:31,620 --> 06:46:32,620
implemented for you in the engine now
9631
06:46:34,200 --> 06:46:35,200
all you have to do if you really want to
9632
06:46:36,780 --> 06:46:37,780
learn more is just browse through this
9633
06:46:39,298 --> 06:46:40,298
list just look at something which might
9634
06:46:41,820 --> 06:46:42,820
be useful so let's say you're doing
9635
06:46:43,138 --> 06:46:44,138
multiplayer but have a look at this now
9636
06:46:45,660 --> 06:46:46,660
this is not something which would really
9637
06:46:48,058 --> 06:46:49,058
be that helpful to be honest
9638
06:46:50,100 --> 06:46:51,100
but there may be a few settings which
9639
06:46:52,798 --> 06:46:53,798
you might actually find helpful
9640
06:46:56,400 --> 06:46:57,400
now there are many many more things
9641
06:46:59,400 --> 06:47:00,400
which you can do and if you aren't able
9642
06:47:02,280 --> 06:47:03,280
to actually write a certain mechanic
9643
06:47:05,400 --> 06:47:06,400
using these nine out of 10 times you're
9644
06:47:08,760 --> 06:47:09,760
just doing it wrong it's just one out of
9645
06:47:11,820 --> 06:47:12,820
maybe 10 20 times that
9646
06:47:15,058 --> 06:47:16,058
the engine is actually deficient of
9647
06:47:17,280 --> 06:47:18,280
features
9648
06:47:18,180 --> 06:47:19,180
so just like this you could go ahead and
9649
06:47:20,940 --> 06:47:21,940
explore this for yourself all of those
9650
06:47:23,280 --> 06:47:24,280
parameters which we saw in Blueprint are
9651
06:47:26,458 --> 06:47:27,458
also accessible in C plus plus there is
9652
06:47:28,558 --> 06:47:29,558
nothing special really so for example
9653
06:47:31,260 --> 06:47:32,260
let's say I wanted to crouch so I can
9654
06:47:34,200 --> 06:47:35,200
just type in Crouch as you can see the
9655
06:47:37,500 --> 06:47:38,500
method Crouch exists here as well
9656
06:47:40,020 --> 06:47:41,020
ah not only that if I want to access my
9657
06:47:43,680 --> 06:47:44,680
character movement based functionality
9658
06:47:45,540 --> 06:47:46,540
there is actually a get function for it
9659
06:47:47,400 --> 06:47:48,400
so get character movement is the
9660
06:47:49,920 --> 06:47:50,920
function name
9661
06:47:51,000 --> 06:47:52,000
so this is going to return a U character
9662
06:47:53,878 --> 06:47:54,878
movement component pointer so once we
9663
06:47:56,760 --> 06:47:57,760
actually have access to that so let's
9664
06:47:58,740 --> 06:47:59,740
say Auto Temp 2 equals okay it's in a
9665
06:48:02,638 --> 06:48:03,638
different scope so we can reuse temp
9666
06:48:05,040 --> 06:48:06,040
so Auto Temp equals
9667
06:48:07,740 --> 06:48:08,740
get character movement and now we can
9668
06:48:10,378 --> 06:48:11,378
use this variable in order to just call
9669
06:48:12,780 --> 06:48:13,780
our regular functions so for example if
9670
06:48:15,360 --> 06:48:16,360
we want to change a movement mode so we
9671
06:48:17,458 --> 06:48:18,458
can type in
9672
06:48:19,378 --> 06:48:20,378
whatever the function was over here
9673
06:48:22,620 --> 06:48:23,620
so movement mode
9674
06:48:26,820 --> 06:48:27,820
so set movement mode was the function
9675
06:48:28,680 --> 06:48:29,680
name
9676
06:48:32,700 --> 06:48:33,700
set movement mode
9677
06:48:37,200 --> 06:48:38,200
now clearly it's not happy with us using
9678
06:48:40,138 --> 06:48:41,138
this type but fix for this pointer to
9679
06:48:43,200 --> 06:48:44,200
incomplete class type so the simple fix
9680
06:48:46,020 --> 06:48:47,020
for this is to just look up the
9681
06:48:47,458 --> 06:48:48,458
documentation for the header here we
9682
06:48:49,440 --> 06:48:50,440
don't have the character movement
9683
06:48:50,820 --> 06:48:51,820
component header file so we'll just
9684
06:48:53,638 --> 06:48:54,638
paste that in our dot h
9685
06:48:55,500 --> 06:48:56,500
and now if you go ahead and look at this
9686
06:48:58,260 --> 06:48:59,260
this should work and now we get the
9687
06:49:00,540 --> 06:49:01,540
options for the parameters
9688
06:49:03,058 --> 06:49:04,058
so for this let's actually type in
9689
06:49:06,718 --> 06:49:07,718
e movement mode
9690
06:49:13,080 --> 06:49:14,080
and we have move flying for example
9691
06:49:17,100 --> 06:49:18,100
and then new custom mode we can just set
9692
06:49:20,340 --> 06:49:21,340
this to zero
9693
06:49:22,260 --> 06:49:23,260
so like this you can set the movement
9694
06:49:24,540 --> 06:49:25,540
mode in C plus plus
9695
06:49:27,058 --> 06:49:28,058
so stuff like this is going to be
9696
06:49:29,700 --> 06:49:30,700
analogous to both blueprint as well as C
9697
06:49:31,920 --> 06:49:32,920
plus plus however note that some of
9698
06:49:34,740 --> 06:49:35,740
these headers aren't actually included
9699
06:49:36,958 --> 06:49:37,958
by default so make sure you just go
9700
06:49:39,360 --> 06:49:40,360
ahead and include them before you start
9701
06:49:40,798 --> 06:49:41,798
working with them
9702
06:49:43,190 --> 06:49:44,190
[Music]
9703
06:49:48,240 --> 06:49:49,240
so we are inside the BP player
9704
06:49:50,218 --> 06:49:51,218
controller class
9705
06:49:51,500 --> 06:49:52,500
and we have dealt with this before but
9706
06:49:54,958 --> 06:49:55,958
going a little bit more deeper player
9707
06:49:57,240 --> 06:49:58,240
controllers or controllers in general
9708
06:49:59,100 --> 06:50:00,100
are designed to handle input
9709
06:50:02,760 --> 06:50:03,760
so if we actually bring in an input
9710
06:50:05,458 --> 06:50:06,458
binding so for example I just type in w
9711
06:50:07,558 --> 06:50:08,558
on the keyboard
9712
06:50:09,600 --> 06:50:10,600
so what's going to happen is
9713
06:50:12,958 --> 06:50:13,958
this input will actually be taken over
9714
06:50:15,718 --> 06:50:16,718
our input bindings which we set up in a
9715
06:50:18,600 --> 06:50:19,600
character so if I just print a string
9716
06:50:20,700 --> 06:50:21,700
we'll actually not move instead we'll be
9717
06:50:23,458 --> 06:50:24,458
printing hello
9718
06:50:24,840 --> 06:50:25,840
so that's one thing to note other than
9719
06:50:27,240 --> 06:50:28,240
that the mouse interface has several
9720
06:50:30,180 --> 06:50:31,180
important functions such as show mouse
9721
06:50:32,940 --> 06:50:33,940
cursor enable click events enable mouse
9722
06:50:35,638 --> 06:50:36,638
over events and stuff like that all
9723
06:50:37,558 --> 06:50:38,558
these are self-explanatory one thing to
9724
06:50:40,378 --> 06:50:41,378
note is that your Pawn or your character
9725
06:50:42,900 --> 06:50:43,900
obviously is going to be possessed by a
9726
06:50:46,200 --> 06:50:47,200
player controller and without apply
9727
06:50:48,478 --> 06:50:49,478
controller you can not actually control
9728
06:50:50,638 --> 06:50:51,638
your character and all of these are
9729
06:50:53,878 --> 06:50:54,878
actually set inside your game mode
9730
06:50:56,340 --> 06:50:57,340
so which black controller class you use
9731
06:50:59,040 --> 06:51:00,040
is decided by your game mode class which
9732
06:51:01,620 --> 06:51:02,620
we will talk about soon game mode game
9733
06:51:03,540 --> 06:51:04,540
State player State and play controller
9734
06:51:05,580 --> 06:51:06,580
all of these work in conjunction a
9735
06:51:07,860 --> 06:51:08,860
player controller is going to possess a
9736
06:51:09,780 --> 06:51:10,780
pawn which you can control
9737
06:51:11,760 --> 06:51:12,760
now once that said there are a few other
9738
06:51:14,400 --> 06:51:15,400
functions which are important here such
9739
06:51:16,440 --> 06:51:17,440
as set input mode game only which will
9740
06:51:19,740 --> 06:51:20,740
take your game input basically and when
9741
06:51:23,040 --> 06:51:24,040
you have set input mode game and UI only
9742
06:51:26,580 --> 06:51:27,580
so in that case you are going to be able
9743
06:51:29,638 --> 06:51:30,638
to interact with widgets as well as take
9744
06:51:32,638 --> 06:51:33,638
player input in the game
9745
06:51:35,340 --> 06:51:36,340
similarly UI only is going to disable
9746
06:51:37,978 --> 06:51:38,978
your keyboard input entirely so stuff
9747
06:51:40,620 --> 06:51:41,620
like that functionality regarding input
9748
06:51:42,718 --> 06:51:43,718
is available in your player controller
9749
06:51:46,140 --> 06:51:47,140
[Music]
9750
06:51:51,180 --> 06:51:52,180
despite using all of the above mentioned
9751
06:51:54,420 --> 06:51:55,420
classes it is technically impossible to
9752
06:51:57,780 --> 06:51:58,780
set up a well playable game
9753
06:52:00,000 --> 06:52:01,000
so we have a few more classes which
9754
06:52:02,700 --> 06:52:03,700
actually set up the whole framework to
9755
06:52:05,760 --> 06:52:06,760
actually start developing the game logic
9756
06:52:08,760 --> 06:52:09,760
itself
9757
06:52:09,780 --> 06:52:10,780
and those are game mode game State and
9758
06:52:13,920 --> 06:52:14,920
the player State now the play State
9759
06:52:15,540 --> 06:52:16,540
isn't that important but the game mode
9760
06:52:17,820 --> 06:52:18,820
and game state will provide you with all
9761
06:52:20,100 --> 06:52:21,100
the functionality that you need in order
9762
06:52:22,260 --> 06:52:23,260
for your gameplay logic to work so we
9763
06:52:24,840 --> 06:52:25,840
have already created a game mode
9764
06:52:26,820 --> 06:52:27,820
know that every level will have one game
9765
06:52:29,160 --> 06:52:30,160
mode and you have to set that
9766
06:52:31,500 --> 06:52:32,500
and the important part here is
9767
06:52:34,798 --> 06:52:35,798
these classes this can be set over here
9768
06:52:38,160 --> 06:52:39,160
in the world settings
9769
06:52:40,440 --> 06:52:41,440
and upon class is as as expected BP
9770
06:52:44,520 --> 06:52:45,520
character however this can be changed at
9771
06:52:47,040 --> 06:52:48,040
runtime in the sense you can possess a
9772
06:52:49,740 --> 06:52:50,740
different Pawn the default is going to
9773
06:52:51,780 --> 06:52:52,780
remain the same but you can call the
9774
06:52:53,760 --> 06:52:54,760
possess function on your play controller
9775
06:52:55,620 --> 06:52:56,620
so let me actually show that so let's
9776
06:52:57,840 --> 06:52:58,840
say I'm on new character right now
9777
06:53:02,638 --> 06:53:03,638
so now I can't move or do anything
9778
06:53:04,458 --> 06:53:05,458
however if I head into my game mode
9779
06:53:11,280 --> 06:53:12,280
and let's say after begin play
9780
06:53:14,400 --> 06:53:15,400
I just give a delay of few seconds
9781
06:53:18,298 --> 06:53:19,298
so delay and I give let's say three
9782
06:53:21,540 --> 06:53:22,540
seconds or two seconds
9783
06:53:23,580 --> 06:53:24,580
and I get my player controller
9784
06:53:26,218 --> 06:53:27,218
now note this is a single player game so
9785
06:53:28,320 --> 06:53:29,320
this works otherwise anything that you
9786
06:53:30,958 --> 06:53:31,958
do will be with respect to the server
9787
06:53:33,540 --> 06:53:34,540
game mode in a multiplayer game will
9788
06:53:35,878 --> 06:53:36,878
only exist on the server that's one
9789
06:53:38,040 --> 06:53:39,040
thing to note
9790
06:53:39,718 --> 06:53:40,718
so from here we can type in possess
9791
06:53:43,740 --> 06:53:44,740
and what we can do is we can just spawn
9792
06:53:45,780 --> 06:53:46,780
a character so where our player start is
9793
06:53:48,540 --> 06:53:49,540
you can just copy this over let's say
9794
06:53:51,900 --> 06:53:52,900
or you can have a Target Point instead
9795
06:53:55,320 --> 06:53:56,320
so just type in Target point
9796
06:53:58,558 --> 06:53:59,558
drag this in
9797
06:54:00,900 --> 06:54:01,900
and get the location
9798
06:54:04,080 --> 06:54:05,080
so we have something like 10
9799
06:54:06,958 --> 06:54:07,958
negative 11420
9800
06:54:10,860 --> 06:54:11,860
so head into the game mode class
9801
06:54:15,840 --> 06:54:16,840
for an actor
9802
06:54:19,558 --> 06:54:20,558
select BP character for example
9803
06:54:23,638 --> 06:54:24,638
so BP underscore character and for the
9804
06:54:27,360 --> 06:54:28,360
transform
9805
06:54:28,680 --> 06:54:29,680
negative 11 420
9806
06:54:33,420 --> 06:54:34,420
and we'll do 350 for the Z
9807
06:54:38,520 --> 06:54:39,520
and for the pawn this is going to be the
9808
06:54:41,700 --> 06:54:42,700
pawn which we will possess
9809
06:54:44,280 --> 06:54:45,280
now if I go ahead and press play wait
9810
06:54:47,040 --> 06:54:48,040
for two seconds and as you can see we
9811
06:54:50,580 --> 06:54:51,580
have possessed our BP character
9812
06:54:53,280 --> 06:54:54,280
so stuff like this you can easily set up
9813
06:54:57,180 --> 06:54:58,180
in
9814
06:54:58,620 --> 06:54:59,620
your game mode so anything such as this
9815
06:55:03,058 --> 06:55:04,058
which is handled on the server is done
9816
06:55:05,940 --> 06:55:06,940
in the game mode but the game mode isn't
9817
06:55:08,820 --> 06:55:09,820
really limited to this
9818
06:55:10,680 --> 06:55:11,680
the game mode has several functions such
9819
06:55:13,500 --> 06:55:14,500
as post login
9820
06:55:16,080 --> 06:55:17,080
and you also have other things such as
9821
06:55:21,900 --> 06:55:22,900
on
9822
06:55:24,000 --> 06:55:25,000
log out
9823
06:55:27,600 --> 06:55:28,600
so this is basically when you join the
9824
06:55:30,540 --> 06:55:31,540
game in a multiplayer game this is
9825
06:55:33,120 --> 06:55:34,120
basically when you leave the game or you
9826
06:55:36,000 --> 06:55:37,000
disconnect
9827
06:55:37,138 --> 06:55:38,138
so you'll still have all the references
9828
06:55:40,320 --> 06:55:41,320
available to you
9829
06:55:42,780 --> 06:55:43,780
so that's where you'll use the game mode
9830
06:55:46,320 --> 06:55:47,320
foreign
9831
06:55:57,540 --> 06:55:58,540
however let's say you wanted to store
9832
06:55:59,520 --> 06:56:00,520
something like a timer now the timer has
9833
06:56:02,340 --> 06:56:03,340
to be in sync with everyone
9834
06:56:04,558 --> 06:56:05,558
so obviously it has to be on the server
9835
06:56:07,138 --> 06:56:08,138
but all your other players must be able
9836
06:56:09,600 --> 06:56:10,600
to read it at least so in that case you
9837
06:56:12,900 --> 06:56:13,900
use a class known as game state which
9838
06:56:15,660 --> 06:56:16,660
does the exact same thing
9839
06:56:17,700 --> 06:56:18,700
so if I just type in game state
9840
06:56:22,260 --> 06:56:23,260
I'm going to use Game State base game
9841
06:56:24,058 --> 06:56:25,058
state is basically game State based with
9842
06:56:25,978 --> 06:56:26,978
a few extra functions
9843
06:56:28,080 --> 06:56:29,080
so let's call this one DP underscore
9844
06:56:31,020 --> 06:56:32,020
gamestate oops BP
9845
06:56:34,680 --> 06:56:35,680
game state
9846
06:56:36,540 --> 06:56:37,540
open it up
9847
06:56:38,040 --> 06:56:39,040
and ignore the viewport and stuff
9848
06:56:39,958 --> 06:56:40,958
doesn't really matter
9849
06:56:41,700 --> 06:56:42,700
and once you have this
9850
06:56:43,680 --> 06:56:44,680
over here we can have something like a
9851
06:56:45,900 --> 06:56:46,900
match timer so I'll create a new
9852
06:56:47,638 --> 06:56:48,638
variable and call this one timer
9853
06:56:50,160 --> 06:56:51,160
so I'll make the subtype integer
9854
06:56:53,638 --> 06:56:54,638
over here we can go ahead and start the
9855
06:56:55,798 --> 06:56:56,798
timer so set timer by function name
9856
06:56:59,218 --> 06:57:00,218
we can go ahead and create a simple
9857
06:57:00,900 --> 06:57:01,900
custom event here so custom event and we
9858
06:57:04,620 --> 06:57:05,620
can go ahead and call this one for
9859
06:57:06,478 --> 06:57:07,478
example timer increment
9860
06:57:11,458 --> 06:57:12,458
you can copy the name paste that in we
9861
06:57:14,940 --> 06:57:15,940
want it to run every one second we want
9862
06:57:17,280 --> 06:57:18,280
it to be looping and it has to run till
9863
06:57:19,680 --> 06:57:20,680
the end of the game
9864
06:57:21,600 --> 06:57:22,600
so we can do timer plus plus
9865
06:57:26,940 --> 06:57:27,940
now this uh value of timer over here can
9866
06:57:31,500 --> 06:57:32,500
be read by
9867
06:57:32,878 --> 06:57:33,878
your widgets and stuff like that so
9868
06:57:35,280 --> 06:57:36,280
there's actually a function which you
9869
06:57:36,600 --> 06:57:37,600
can use for this so let's do that in our
9870
06:57:39,360 --> 06:57:40,360
widget
9871
06:57:40,440 --> 06:57:41,440
head into your UI
9872
06:57:43,200 --> 06:57:44,200
HUD BP HUD
9873
06:57:45,958 --> 06:57:46,958
and where we have our stuff set up
9874
06:57:49,740 --> 06:57:50,740
so let's actually revert our character
9875
06:57:52,860 --> 06:57:53,860
settings so change the character to BP
9876
06:57:56,638 --> 06:57:57,638
character
9877
06:57:58,138 --> 06:57:59,138
and over here for the spawn actor as
9878
06:58:00,420 --> 06:58:01,420
well we'll remove that for now
9879
06:58:03,298 --> 06:58:04,298
for now we'll forget about it
9880
06:58:06,000 --> 06:58:07,000
over here where we actually create our
9881
06:58:08,940 --> 06:58:09,940
HUD this is where we have our reference
9882
06:58:11,940 --> 06:58:12,940
so what we can do is we can actually
9883
06:58:13,440 --> 06:58:14,440
create some more text here so we can
9884
06:58:15,540 --> 06:58:16,540
type in timer so whoops you can type in
9885
06:58:18,780 --> 06:58:19,780
text
9886
06:58:21,120 --> 06:58:22,120
drag in some text here
9887
06:58:23,280 --> 06:58:24,280
maybe just increase the font a bit
9888
06:58:27,298 --> 06:58:28,298
and we can go ahead and have
9889
06:58:30,660 --> 06:58:31,660
has to be light
9890
06:58:32,700 --> 06:58:33,700
anchor it to the top right hand side
9891
06:58:36,000 --> 06:58:37,000
and instead of this we can go ahead and
9892
06:58:39,180 --> 06:58:40,180
set this to be whatever the timer is
9893
06:58:42,420 --> 06:58:43,420
so in our game state every time this
9894
06:58:44,760 --> 06:58:45,760
happens we have to update it
9895
06:58:47,638 --> 06:58:48,638
so what we can do is we can get our
9896
06:58:49,920 --> 06:58:50,920
player controller here we don't have a
9897
06:58:52,260 --> 06:58:53,260
reference to it currently so get player
9898
06:58:55,740 --> 06:58:56,740
controller
9899
06:58:57,298 --> 06:58:58,298
we'd have to cast it to our BP player
9900
06:58:59,820 --> 06:59:00,820
controller cross to BP player controller
9901
06:59:04,440 --> 06:59:05,440
now we can do this on begin play
9902
06:59:07,798 --> 06:59:08,798
and we can store a reference in a
9903
06:59:10,260 --> 06:59:11,260
multiply again this is not going to work
9904
06:59:11,878 --> 06:59:12,878
obviously
9905
06:59:13,138 --> 06:59:14,138
so promote this to variable and type in
9906
06:59:15,860 --> 06:59:16,860
pcrf maybe
9907
06:59:18,058 --> 06:59:19,058
for play controller f
9908
06:59:20,340 --> 06:59:21,340
you can go ahead and update
9909
06:59:23,820 --> 06:59:24,820
okay we have a update Health function we
9910
06:59:26,820 --> 06:59:27,820
can create an update timer function so
9911
06:59:29,580 --> 06:59:30,580
custom event
9912
06:59:31,860 --> 06:59:32,860
update timer
9913
06:59:33,780 --> 06:59:34,780
and this should work as is so give
9914
06:59:37,978 --> 06:59:38,978
the timer value to this
9915
06:59:40,500 --> 06:59:41,500
so type in timer
9916
06:59:43,440 --> 06:59:44,440
get a reference to your HUD
9917
06:59:46,260 --> 06:59:47,260
make sure this is variable and we'll
9918
06:59:48,958 --> 06:59:49,958
call this one timer text
9919
06:59:52,798 --> 06:59:53,798
make sure you compile this
9920
06:59:54,718 --> 06:59:55,718
so
9921
06:59:56,040 --> 06:59:57,040
timer text
9922
06:59:58,620 --> 06:59:59,620
set text
9923
07:00:00,360 --> 07:00:01,360
and we can set this to be whatever this
9924
07:00:03,240 --> 07:00:04,240
timer reads obviously you can use format
9925
07:00:06,120 --> 07:00:07,120
text and you can make this show minutes
9926
07:00:08,458 --> 07:00:09,458
seconds and stuff like that
9927
07:00:11,040 --> 07:00:12,040
so we have our timer so we can do format
9928
07:00:14,040 --> 07:00:15,040
text
9929
07:00:16,200 --> 07:00:17,200
so format text
9930
07:00:18,240 --> 07:00:19,240
we can have minutes
9931
07:00:23,280 --> 07:00:24,280
colon seconds
9932
07:00:27,120 --> 07:00:28,120
something like this
9933
07:00:30,180 --> 07:00:31,180
so make this
9934
07:00:32,638 --> 07:00:33,638
in curly braces
9935
07:00:35,718 --> 07:00:36,718
and our timer by 60 is going to be our
9936
07:00:40,200 --> 07:00:41,200
minutes
9937
07:00:42,740 --> 07:00:43,740
and our timer mod 60 is going to be
9938
07:00:47,638 --> 07:00:48,638
seconds
9939
07:00:49,798 --> 07:00:50,798
however we also have one more parameter
9940
07:00:52,798 --> 07:00:53,798
which we need to take care of is if this
9941
07:00:57,240 --> 07:00:58,240
value is less than 10 we want to append
9942
07:00:59,280 --> 07:01:00,280
a 0 at the start
9943
07:01:01,500 --> 07:01:02,500
so divide so rather convert this to a
9944
07:01:04,978 --> 07:01:05,978
string first
9945
07:01:07,200 --> 07:01:08,200
so
9946
07:01:09,240 --> 07:01:10,240
to string
9947
07:01:12,058 --> 07:01:13,058
and once we have the string we can check
9948
07:01:15,240 --> 07:01:16,240
if this is actually less than 10
9949
07:01:20,878 --> 07:01:21,878
and if it is less than 10
9950
07:01:26,040 --> 07:01:27,040
you can use a select instead so select
9951
07:01:31,378 --> 07:01:32,378
so if it is true and if it's false
9952
07:01:34,260 --> 07:01:35,260
we need separate things
9953
07:01:37,920 --> 07:01:38,920
so if this is going to be greater than
9954
07:01:41,700 --> 07:01:42,700
10 which means this is going to be false
9955
07:01:44,458 --> 07:01:45,458
so we directly want to print that out
9956
07:01:47,160 --> 07:01:48,160
but let's say this is less than 10 we
9957
07:01:49,978 --> 07:01:50,978
want to append a 0 here so append
9958
07:01:54,240 --> 07:01:55,240
type in 0 and then we want to print the
9959
07:01:57,180 --> 07:01:58,180
seconds
9960
07:01:58,320 --> 07:01:59,320
so some simple logic like this
9961
07:02:01,320 --> 07:02:02,320
now we can go ahead and test this out
9962
07:02:04,680 --> 07:02:05,680
and if you were to look at the top right
9963
07:02:06,958 --> 07:02:07,958
hand corner it does not update because
9964
07:02:08,878 --> 07:02:09,878
we have to set the game State as well
9965
07:02:11,458 --> 07:02:12,458
so if I just select BP underscore game
9966
07:02:13,680 --> 07:02:14,680
State over here
9967
07:02:15,420 --> 07:02:16,420
and if I go ahead and press play
9968
07:02:18,058 --> 07:02:19,058
this should technically work but it's
9969
07:02:21,120 --> 07:02:22,120
not
9970
07:02:22,080 --> 07:02:23,080
so let's have a look
9971
07:02:24,120 --> 07:02:25,120
under our BP games that we have our
9972
07:02:27,360 --> 07:02:28,360
black controller and we are actually not
9973
07:02:28,920 --> 07:02:29,920
calling the update function so update
9974
07:02:30,780 --> 07:02:31,780
timer
9975
07:02:32,100 --> 07:02:33,100
now this function should work as normal
9976
07:02:34,620 --> 07:02:35,620
so the timer is going to be the value
9977
07:02:37,260 --> 07:02:38,260
which we get over here
9978
07:02:39,058 --> 07:02:40,058
and on begin play we can just set the
9979
07:02:41,700 --> 07:02:42,700
timer to zero so we'll just call the
9980
07:02:43,378 --> 07:02:44,378
update timer function once
9981
07:02:45,360 --> 07:02:46,360
I go ahead and press play
9982
07:02:47,520 --> 07:02:48,520
as you can see our timer works and it
9983
07:02:50,520 --> 07:02:51,520
increments every second
9984
07:02:52,680 --> 07:02:53,680
and if we just give it a little bit of
9985
07:02:54,958 --> 07:02:55,958
time so we have a runtime error here
9986
07:02:57,180 --> 07:02:58,180
we'll take care of that
9987
07:02:58,920 --> 07:02:59,920
so it says assessment trying to read
9988
07:03:01,680 --> 07:03:02,680
property HUD
9989
07:03:03,958 --> 07:03:04,958
this so this error is in apply
9990
07:03:06,000 --> 07:03:07,000
controller the reason is uh when the
9991
07:03:08,638 --> 07:03:09,638
game state is actually created the
9992
07:03:10,558 --> 07:03:11,558
player controller isn't actually yet
9993
07:03:12,478 --> 07:03:13,478
created
9994
07:03:13,798 --> 07:03:14,798
so that's the reason why or rather the
9995
07:03:17,218 --> 07:03:18,218
player controller is created too but the
9996
07:03:19,320 --> 07:03:20,320
HUD does not get created
9997
07:03:21,420 --> 07:03:22,420
so once this begin place called our
9998
07:03:23,878 --> 07:03:24,878
heart is created so a simple fix for
9999
07:03:26,160 --> 07:03:27,160
this is to get a validated get
10000
07:03:29,638 --> 07:03:30,638
and if it is valid we are going to set
10001
07:03:32,280 --> 07:03:33,280
this text and we shouldn't get any
10002
07:03:33,958 --> 07:03:34,958
errors now
10003
07:03:36,900 --> 07:03:37,900
anyways as soon as we create this HUD we
10004
07:03:40,138 --> 07:03:41,138
can go ahead and update the timer
10005
07:03:42,958 --> 07:03:43,958
oops update time
10006
07:03:46,080 --> 07:03:47,080
and we can set it to zero
10007
07:03:48,420 --> 07:03:49,420
for a timer variable we can actually set
10008
07:03:50,458 --> 07:03:51,458
it to some higher value right now so
10009
07:03:52,798 --> 07:03:53,798
that we go ahead and test out the
10010
07:03:55,080 --> 07:03:56,080
minutes part of it so let's just set
10011
07:03:57,180 --> 07:03:58,180
this to something 65 it should start at
10012
07:03:59,340 --> 07:04:00,340
one minute and five seconds
10013
07:04:01,620 --> 07:04:02,620
so one minute and six seconds seven
10014
07:04:04,260 --> 07:04:05,260
eight nine ten and our logic works
10015
07:04:08,040 --> 07:04:09,040
properly so for stuff like this you
10016
07:04:10,378 --> 07:04:11,378
would use the game state
10017
07:04:12,420 --> 07:04:13,420
now the game mode is going to drive the
10018
07:04:14,820 --> 07:04:15,820
actual logic itself behind your game
10019
07:04:17,638 --> 07:04:18,638
functionality
10020
07:04:19,138 --> 07:04:20,138
but let's say you wanted to access all
10021
07:04:21,780 --> 07:04:22,780
the players information
10022
07:04:23,458 --> 07:04:24,458
you would do that through the player
10023
07:04:25,260 --> 07:04:26,260
State class
10024
07:04:26,878 --> 07:04:27,878
so I'll just be vague about it and if
10025
07:04:29,280 --> 07:04:30,280
you right click in your game State and
10026
07:04:30,660 --> 07:04:31,660
type get layer array
10027
07:04:33,420 --> 07:04:34,420
you can actually get an array of player
10028
07:04:35,820 --> 07:04:36,820
States so you can actually Loop through
10029
07:04:37,978 --> 07:04:38,978
this in fact
10030
07:04:39,360 --> 07:04:40,360
and we can get stuff like the player
10031
07:04:42,058 --> 07:04:43,058
name so get player name
10032
07:04:44,520 --> 07:04:45,520
and for multiplayer games you can get
10033
07:04:46,740 --> 07:04:47,740
the unique net ID
10034
07:04:50,040 --> 07:04:51,040
so for these things basically any
10035
07:04:53,878 --> 07:04:54,878
details which all players need to have
10036
07:04:56,160 --> 07:04:57,160
access of at all points of time those
10037
07:04:58,920 --> 07:04:59,920
are the things which your player state
10038
07:05:01,200 --> 07:05:02,200
will hold
10039
07:05:02,340 --> 07:05:03,340
so that's about it basically and one
10040
07:05:05,458 --> 07:05:06,458
last class that we have left to talk
10041
07:05:07,320 --> 07:05:08,320
about which is important is going to be
10042
07:05:09,718 --> 07:05:10,718
our game instance then we can head into
10043
07:05:12,540 --> 07:05:13,540
more advanced stuff and we can have an
10044
07:05:14,760 --> 07:05:15,760
example project created
10045
07:05:17,270 --> 07:05:18,270
[Music]
10046
07:05:22,020 --> 07:05:23,020
unlike all the other classes which we
10047
07:05:24,478 --> 07:05:25,478
spoke about till now the game instance
10048
07:05:26,280 --> 07:05:27,280
is kind of special
10049
07:05:28,080 --> 07:05:29,080
the game instance behaves very
10050
07:05:30,478 --> 07:05:31,478
differently compared to all of these
10051
07:05:32,218 --> 07:05:33,218
classes so if I actually just open up my
10052
07:05:34,920 --> 07:05:35,920
game mode for example so I will open up
10053
07:05:36,840 --> 07:05:37,840
the main menu first things first maps
10054
07:05:39,120 --> 07:05:40,120
and our main menu level
10055
07:05:41,280 --> 07:05:42,280
and now in my uh game mode
10056
07:05:45,900 --> 07:05:46,900
I'll just go ahead and print stuff so
10057
07:05:49,080 --> 07:05:50,080
I'll just print
10058
07:05:51,298 --> 07:05:52,298
host login
10059
07:05:53,160 --> 07:05:54,160
and I'll just type in log out maybe
10060
07:05:58,080 --> 07:05:59,080
so log out
10061
07:06:00,240 --> 07:06:01,240
and we can also have
10062
07:06:02,458 --> 07:06:03,458
event destroyed
10063
07:06:05,040 --> 07:06:06,040
event end play
10064
07:06:08,400 --> 07:06:09,400
so we'll just go ahead and print stuff
10065
07:06:10,020 --> 07:06:11,020
over here as well
10066
07:06:11,900 --> 07:06:12,900
so destroyed
10067
07:06:16,260 --> 07:06:17,260
I'm just doing this in the game mode but
10068
07:06:18,240 --> 07:06:19,240
this could be in any other class
10069
07:06:20,520 --> 07:06:21,520
and this is going to be end play
10070
07:06:24,478 --> 07:06:25,478
all right so if I go ahead and press
10071
07:06:27,058 --> 07:06:28,058
play right now and if I go ahead and
10072
07:06:29,280 --> 07:06:30,280
press play as you can see our post login
10073
07:06:31,558 --> 07:06:32,558
was called
10074
07:06:32,760 --> 07:06:33,760
and as soon as I close it or rather I
10075
07:06:36,360 --> 07:06:37,360
should switch levels because
10076
07:06:38,340 --> 07:06:39,340
if I close the game the logic isn't
10077
07:06:40,798 --> 07:06:41,798
really going to be executed so I'll just
10078
07:06:42,660 --> 07:06:43,660
type in open
10079
07:06:45,478 --> 07:06:46,478
main menu level
10080
07:06:47,340 --> 07:06:48,340
as you can see our logout function was
10081
07:06:49,680 --> 07:06:50,680
called
10082
07:06:51,478 --> 07:06:52,478
so what I'm trying to say here is that
10083
07:06:55,320 --> 07:06:56,320
this game mode class will not persist
10084
07:06:58,138 --> 07:06:59,138
between levels
10085
07:07:00,180 --> 07:07:01,180
so once you log out this game mode
10086
07:07:03,120 --> 07:07:04,120
reference whatever we have is not going
10087
07:07:05,700 --> 07:07:06,700
to persist
10088
07:07:07,080 --> 07:07:08,080
now forget about the game mode reference
10089
07:07:09,718 --> 07:07:10,718
you can't even access it from anywhere
10090
07:07:12,958 --> 07:07:13,958
else so let me actually show you guys
10091
07:07:15,058 --> 07:07:16,058
using the game instance the special
10092
07:07:17,520 --> 07:07:18,520
thing about the game instance is that
10093
07:07:19,500 --> 07:07:20,500
when you switch levels
10094
07:07:21,360 --> 07:07:22,360
your game instance will still remain the
10095
07:07:23,760 --> 07:07:24,760
same when you open up the game an
10096
07:07:26,160 --> 07:07:27,160
instance of the game instance is created
10097
07:07:29,160 --> 07:07:30,160
so basically an object of type game
10098
07:07:31,440 --> 07:07:32,440
instance is instantiated and that is
10099
07:07:33,660 --> 07:07:34,660
going to remain the same so go to
10100
07:07:36,000 --> 07:07:37,000
blueprint Class Type in game instance
10101
07:07:40,740 --> 07:07:41,740
and over here we can name this our game
10102
07:07:44,458 --> 07:07:45,458
instance our rgi
10103
07:07:46,860 --> 07:07:47,860
anything you want
10104
07:07:48,660 --> 07:07:49,660
you could put a BP underscore you can
10105
07:07:50,820 --> 07:07:51,820
have a C plus plus class as well but I
10106
07:07:53,280 --> 07:07:54,280
don't really find the point in having a
10107
07:07:55,080 --> 07:07:56,080
base class for this one
10108
07:07:56,580 --> 07:07:57,580
now instead of begin play we'll actually
10109
07:07:58,620 --> 07:07:59,620
find events such as event in it
10110
07:08:02,100 --> 07:08:03,100
so this is when
10111
07:08:03,900 --> 07:08:04,900
your game actually starts so if I go
10112
07:08:06,840 --> 07:08:07,840
ahead and print this out if I type in
10113
07:08:09,360 --> 07:08:10,360
init
10114
07:08:11,400 --> 07:08:12,400
and if I head into my project settings
10115
07:08:14,878 --> 07:08:15,878
type in game instance I can actually
10116
07:08:18,000 --> 07:08:19,000
change this to bprgi
10117
07:08:21,660 --> 07:08:22,660
if I press play and if I press play
10118
07:08:24,660 --> 07:08:25,660
again
10119
07:08:25,860 --> 07:08:26,860
or rather I'll head into the level and
10120
07:08:27,900 --> 07:08:28,900
do it
10121
07:08:29,458 --> 07:08:30,458
if I press play you'll notice that
10122
07:08:33,660 --> 07:08:34,660
init isn't even printed here in the
10123
07:08:35,760 --> 07:08:36,760
console
10124
07:08:37,020 --> 07:08:38,020
but it was printed way before everything
10125
07:08:39,718 --> 07:08:40,718
else that's why it's way down at the
10126
07:08:41,878 --> 07:08:42,878
bottom over there the reason is even
10127
07:08:44,280 --> 07:08:45,280
before the viewport was properly spawned
10128
07:08:46,860 --> 07:08:47,860
and even before it started logging stuff
10129
07:08:50,040 --> 07:08:51,040
the event in it was actually called so
10130
07:08:51,958 --> 07:08:52,958
the event and it basically refers to
10131
07:08:54,000 --> 07:08:55,000
when you start the game not when you
10132
07:08:56,520 --> 07:08:57,520
open up a level or not when you create
10133
07:08:58,978 --> 07:08:59,978
something else
10134
07:09:01,080 --> 07:09:02,080
now one thing which I want to show you
10135
07:09:03,180 --> 07:09:04,180
guys is I'll head into blueprint head
10136
07:09:06,420 --> 07:09:07,420
into our game instance I'm going to go
10137
07:09:09,120 --> 07:09:10,120
ahead and call the get game mode
10138
07:09:10,500 --> 07:09:11,500
function
10139
07:09:12,240 --> 07:09:13,240
and I'll go ahead and promote this to a
10140
07:09:14,580 --> 07:09:15,580
variable
10141
07:09:15,540 --> 07:09:16,540
and let's not name it it's fine
10142
07:09:18,540 --> 07:09:19,540
and then what I want to do
10143
07:09:20,638 --> 07:09:21,638
is after a while
10144
07:09:24,240 --> 07:09:25,240
so let's say I switch from one level to
10145
07:09:27,058 --> 07:09:28,058
the other now I'm going to go from this
10146
07:09:28,978 --> 07:09:29,978
level to the main menu level
10147
07:09:31,138 --> 07:09:32,138
so I'll head into main menu level
10148
07:09:34,860 --> 07:09:35,860
and in the level blueprint here I'll
10149
07:09:37,320 --> 07:09:38,320
just access the game instance get game
10150
07:09:39,718 --> 07:09:40,718
instance
10151
07:09:42,180 --> 07:09:43,180
and we can cast it to bprji this can
10152
07:09:45,420 --> 07:09:46,420
always be a pure cast because it will
10153
07:09:47,160 --> 07:09:48,160
never fail
10154
07:09:49,680 --> 07:09:50,680
and over here get
10155
07:09:52,978 --> 07:09:53,978
whatever the variable was called I think
10156
07:09:54,958 --> 07:09:55,958
it was called new variable zero
10157
07:09:57,900 --> 07:09:58,900
and we can go ahead and right click and
10158
07:09:59,760 --> 07:10:00,760
convert this to a validated get
10159
07:10:03,478 --> 07:10:04,478
we can go ahead and print it
10160
07:10:05,760 --> 07:10:06,760
and we can say not valid
10161
07:10:10,798 --> 07:10:11,798
and this is going to be if it is valid
10162
07:10:13,680 --> 07:10:14,680
so valid
10163
07:10:17,100 --> 07:10:18,100
so if I go ahead and I'll actually leave
10164
07:10:20,160 --> 07:10:21,160
a bit of a delay here
10165
07:10:23,218 --> 07:10:24,218
oops delay
10166
07:10:25,680 --> 07:10:26,680
let's say about a second not more than
10167
07:10:28,320 --> 07:10:29,320
that
10168
07:10:31,260 --> 07:10:32,260
so if I go ahead and head into my level
10169
07:10:33,840 --> 07:10:34,840
again and if I press play
10170
07:10:36,478 --> 07:10:37,478
as you can see everything works normally
10171
07:10:39,058 --> 07:10:40,058
but I'm going to go ahead and type in
10172
07:10:40,978 --> 07:10:41,978
open main menu level
10173
07:10:43,740 --> 07:10:44,740
and as you can see I get not valid
10174
07:10:46,860 --> 07:10:47,860
so what this exactly means is that our
10175
07:10:49,500 --> 07:10:50,500
game mode object
10176
07:10:51,780 --> 07:10:52,780
which was created when we loaded the
10177
07:10:54,900 --> 07:10:55,900
level because game mode objects are
10178
07:10:57,120 --> 07:10:58,120
specific to a given level as soon as we
10179
07:10:59,700 --> 07:11:00,700
change the level
10180
07:11:00,958 --> 07:11:01,958
our BP game mode object was destroyed
10181
07:11:03,718 --> 07:11:04,718
and whatever game mode we had over here
10182
07:11:06,180 --> 07:11:07,180
in our main menu level so this is none
10183
07:11:08,280 --> 07:11:09,280
so it's just going to take game mode
10184
07:11:09,780 --> 07:11:10,780
base
10185
07:11:10,798 --> 07:11:11,798
so that object was created
10186
07:11:13,920 --> 07:11:14,920
however our game instance was still the
10187
07:11:16,500 --> 07:11:17,500
same so if I actually store a reference
10188
07:11:19,260 --> 07:11:20,260
to the game instance somewhere else that
10189
07:11:21,900 --> 07:11:22,900
is still going to be completely valid
10190
07:11:24,180 --> 07:11:25,180
throughout our game
10191
07:11:26,100 --> 07:11:27,100
so anything that is persistent between
10192
07:11:28,260 --> 07:11:29,260
levels you would have it set in the game
10193
07:11:31,020 --> 07:11:32,020
instance generally you would handle save
10194
07:11:33,840 --> 07:11:34,840
games and stuff like that through the
10195
07:11:35,700 --> 07:11:36,700
game instance because even if a player
10196
07:11:39,000 --> 07:11:40,000
exits a level your save game logic and
10197
07:11:41,340 --> 07:11:42,340
stuff should be able to work
10198
07:11:43,500 --> 07:11:44,500
and stuff like settings and all those
10199
07:11:46,740 --> 07:11:47,740
things are what you would put inside the
10200
07:11:48,660 --> 07:11:49,660
game instance anything related to file
10201
07:11:51,360 --> 07:11:52,360
handling will also be put in the game
10202
07:11:53,400 --> 07:11:54,400
instance
10203
07:11:54,540 --> 07:11:55,540
and many other things regarding
10204
07:11:56,400 --> 07:11:57,400
networking uh in general outside the
10205
07:11:59,520 --> 07:12:00,520
game is going to be in the game instance
10206
07:12:01,680 --> 07:12:02,680
for example a database
10207
07:12:03,958 --> 07:12:04,958
you could handle it through the other
10208
07:12:05,580 --> 07:12:06,580
classes as well but this is going to be
10209
07:12:07,860 --> 07:12:08,860
the safest way since this class is going
10210
07:12:10,200 --> 07:12:11,200
to have itself instantiated throughout
10211
07:12:12,718 --> 07:12:13,718
the program in in our case the game
10212
07:12:16,100 --> 07:12:17,100
and even when you actually exit the game
10213
07:12:19,440 --> 07:12:20,440
we have events shutdown rather than
10214
07:12:21,478 --> 07:12:22,478
event destroyed or event end play so if
10215
07:12:24,660 --> 07:12:25,660
I just type in print string
10216
07:12:27,120 --> 07:12:28,120
and if I just exit nothing's really
10217
07:12:29,878 --> 07:12:30,878
going to happen because the viewport is
10218
07:12:32,160 --> 07:12:33,160
already destroyed by the time the
10219
07:12:34,860 --> 07:12:35,860
shutdown is called
10220
07:12:37,378 --> 07:12:38,378
so stuff like that let's say you had to
10221
07:12:40,020 --> 07:12:41,020
close out some connections or something
10222
07:12:41,638 --> 07:12:42,638
you could do that through your event
10223
07:12:43,558 --> 07:12:44,558
shutdown let's say you have a database
10224
07:12:45,180 --> 07:12:46,180
or something like that just give give an
10225
07:12:47,700 --> 07:12:48,700
example
10226
07:12:48,718 --> 07:12:49,718
anything that's persistent between
10227
07:12:50,580 --> 07:12:51,580
levels you would use the game instance
10228
07:12:53,940 --> 07:12:54,940
and one thing which should be obvious by
10229
07:12:56,520 --> 07:12:57,520
now but I wanted to mention is each
10230
07:12:59,040 --> 07:13:00,040
player in a multiplayer game will have
10231
07:13:00,900 --> 07:13:01,900
his own game instance and you cannot put
10232
07:13:05,218 --> 07:13:06,218
in-game networking code in this you can
10233
07:13:07,500 --> 07:13:08,500
put networking code but whatever's
10234
07:13:09,840 --> 07:13:10,840
outside the game if you have any in-game
10235
07:13:12,180 --> 07:13:13,180
networking code you there is absolutely
10236
07:13:14,280 --> 07:13:15,280
no reason to use the game instance
10237
07:13:16,920 --> 07:13:17,920
there is no use of calling rpcs through
10238
07:13:21,058 --> 07:13:22,058
the game instance since one player's
10239
07:13:23,400 --> 07:13:24,400
game instance is in nowhere related to
10240
07:13:25,558 --> 07:13:26,558
the other players game instance so if I
10241
07:13:28,320 --> 07:13:29,320
actually start two instances of the game
10242
07:13:30,718 --> 07:13:31,718
let's say I have two players
10243
07:13:35,100 --> 07:13:36,100
even though they may be connected
10244
07:13:38,160 --> 07:13:39,160
your game instances will be different so
10245
07:13:42,600 --> 07:13:43,600
this player will have a different game
10246
07:13:44,218 --> 07:13:45,218
instance unlike the game State or the
10247
07:13:46,620 --> 07:13:47,620
game mode where it's going to be common
10248
07:13:48,360 --> 07:13:49,360
for one game so let's say two players
10249
07:13:52,978 --> 07:13:53,978
are connected both of them will have one
10250
07:13:54,958 --> 07:13:55,958
game modern game stat in common which
10251
07:13:56,700 --> 07:13:57,700
will be created on the server but in a
10252
07:13:59,100 --> 07:14:00,100
game like this game instances will not
10253
07:14:01,500 --> 07:14:02,500
be the same so I should have done listen
10254
07:14:03,958 --> 07:14:04,958
server or client so Standalone in
10255
07:14:07,500 --> 07:14:08,500
Standalone even game mode game State and
10256
07:14:09,420 --> 07:14:10,420
classes like that will be different
10257
07:14:10,620 --> 07:14:11,620
because in Standalone you are not
10258
07:14:12,780 --> 07:14:13,780
actually connected
10259
07:14:14,340 --> 07:14:15,340
but in any case your game instances are
10260
07:14:17,400 --> 07:14:18,400
never associated with each other
10261
07:14:20,120 --> 07:14:21,120
[Music]
10262
07:14:25,020 --> 07:14:26,020
so with all the knowledge that you have
10263
07:14:27,120 --> 07:14:28,120
now you should be able to create an
10264
07:14:28,860 --> 07:14:29,860
entirely complete single player game in
10265
07:14:32,218 --> 07:14:33,218
Unreal Engine 5. of course you will need
10266
07:14:34,440 --> 07:14:35,440
to refer the documentation at times at
10267
07:14:37,020 --> 07:14:38,020
times you will need to mess around with
10268
07:14:38,638 --> 07:14:39,638
stuff but this much of knowledge should
10269
07:14:41,100 --> 07:14:42,100
be enough for you to create a complete
10270
07:14:42,958 --> 07:14:43,958
Game completely functional game using
10271
07:14:45,958 --> 07:14:46,958
all of unreal score features however I
10272
07:14:50,040 --> 07:14:51,040
am aware that I didn't touch upon
10273
07:14:51,840 --> 07:14:52,840
particle effects and audio that sounds
10274
07:14:55,978 --> 07:14:56,978
uh we will take a look at that when we
10275
07:14:58,080 --> 07:14:59,080
actually create a practical game I am
10276
07:15:00,240 --> 07:15:01,240
not a VFX artist nor am a sound design
10277
07:15:03,260 --> 07:15:04,260
personally so that's the reason I didn't
10278
07:15:06,478 --> 07:15:07,478
touch over them but we will go over some
10279
07:15:08,820 --> 07:15:09,820
resources which you can use and I'll
10280
07:15:10,620 --> 07:15:11,620
just talk about what I do to actually
10281
07:15:12,478 --> 07:15:13,478
get hands on those resources
10282
07:15:15,180 --> 07:15:16,180
now that's done we can go ahead and
10283
07:15:18,360 --> 07:15:19,360
start talking about plugins until now we
10284
07:15:21,420 --> 07:15:22,420
just implemented plugins which were
10285
07:15:24,298 --> 07:15:25,298
there in the marketplace or if you have
10286
07:15:26,638 --> 07:15:27,638
a plugin from GitHub or something you
10287
07:15:28,740 --> 07:15:29,740
would download it and maybe just paste
10288
07:15:31,500 --> 07:15:32,500
it inside your project so if I had in
10289
07:15:33,900 --> 07:15:34,900
here you just create a plugins folder
10290
07:15:35,760 --> 07:15:36,760
and paste that in there that's simple
10291
07:15:38,580 --> 07:15:39,580
but what if you wanted to create your
10292
07:15:40,920 --> 07:15:41,920
own plugin if you wanted to do that and
10293
07:15:44,218 --> 07:15:45,218
this topic is very less discussed so not
10294
07:15:48,000 --> 07:15:49,000
many people actually talk about this
10295
07:15:49,620 --> 07:15:50,620
stuff so you're in luck because we are
10296
07:15:52,260 --> 07:15:53,260
talking about this in detail now
10297
07:15:54,900 --> 07:15:55,900
so head into plugins click on ADD and
10298
07:15:58,558 --> 07:15:59,558
you see many options now we won't be
10299
07:16:01,978 --> 07:16:02,978
worrying about the editor plugins those
10300
07:16:04,020 --> 07:16:05,020
are for more advanced users and if you
10301
07:16:06,058 --> 07:16:07,058
are in a state where you're creating
10302
07:16:07,260 --> 07:16:08,260
editor plugins I really don't know what
10303
07:16:09,900 --> 07:16:10,900
is the reason for you to watch this
10304
07:16:11,760 --> 07:16:12,760
course so we won't be touching upon this
10305
07:16:14,340 --> 07:16:15,340
we'll be looking at third party
10306
07:16:15,958 --> 07:16:16,958
libraries later on we'll be looking at
10307
07:16:18,600 --> 07:16:19,600
blank content only in Blueprint library
10308
07:16:20,520 --> 07:16:21,520
now blueprint library is
10309
07:16:22,458 --> 07:16:23,458
self-explanatory it'll just contain a
10310
07:16:24,660 --> 07:16:25,660
blueprint function Library let's say you
10311
07:16:27,180 --> 07:16:28,180
wanted some functions for a vector or
10312
07:16:29,520 --> 07:16:30,520
something maybe you are implementing
10313
07:16:31,080 --> 07:16:32,080
another data structure for which you
10314
07:16:32,820 --> 07:16:33,820
want functions
10315
07:16:34,080 --> 07:16:35,080
you could have a blueprint Library
10316
07:16:36,660 --> 07:16:37,660
and content only is basically the type
10317
07:16:39,478 --> 07:16:40,478
of plugin where you know you'd have
10318
07:16:40,978 --> 07:16:41,978
models and stuff like that without any
10319
07:16:42,958 --> 07:16:43,958
code basically
10320
07:16:44,280 --> 07:16:45,280
but the one which we'll be doing is
10321
07:16:46,558 --> 07:16:47,558
blank and just give an author name in my
10322
07:16:49,138 --> 07:16:50,138
case I'll give gaming and description
10323
07:16:51,420 --> 07:16:52,420
this is my first plugin
10324
07:16:54,780 --> 07:16:55,780
well it's not but just for the sake of
10325
07:16:57,180 --> 07:16:58,180
giving a description and let's call this
10326
07:16:59,520 --> 07:17:00,520
one
10327
07:17:00,298 --> 07:17:01,298
test plugin
10328
07:17:01,860 --> 07:17:02,860
and go ahead and create it
10329
07:17:06,360 --> 07:17:07,360
so the plugin has been created and we
10330
07:17:08,760 --> 07:17:09,760
have Visual Studio open however before
10331
07:17:10,920 --> 07:17:11,920
we actually start working on it I want
10332
07:17:13,020 --> 07:17:14,020
to touch upon one topic that is the
10333
07:17:16,080 --> 07:17:17,080
build.cs file basically everything you
10334
07:17:20,040 --> 07:17:21,040
have in the engine is divided into
10335
07:17:22,440 --> 07:17:23,440
modules so the core functionality of the
10336
07:17:25,440 --> 07:17:26,440
engine is like core choreo object and
10337
07:17:27,780 --> 07:17:28,780
engine
10338
07:17:28,558 --> 07:17:29,558
so now that you have actually created
10339
07:17:30,360 --> 07:17:31,360
your plugin your plugin as well will
10340
07:17:33,478 --> 07:17:34,478
have a build.cs file if actually open
10341
07:17:35,580 --> 07:17:36,580
the folder over there so plugins test
10342
07:17:37,680 --> 07:17:38,680
plugin and if I head into Source test
10343
07:17:41,520 --> 07:17:42,520
plugin I have a build.cs file here and I
10344
07:17:45,660 --> 07:17:46,660
have content binary stuff like that
10345
07:17:48,540 --> 07:17:49,540
so what this basically is is this plugin
10346
07:17:52,138 --> 07:17:53,138
itself is actually a modulant in itself
10347
07:17:54,958 --> 07:17:55,958
so if I want to use this plugin in C
10348
07:17:57,600 --> 07:17:58,600
plus plus let's say I should go ahead
10349
07:18:00,600 --> 07:18:01,600
and include that module so I can do that
10350
07:18:03,420 --> 07:18:04,420
by typing in a comma and we can type in
10351
07:18:06,478 --> 07:18:07,478
test plugin
10352
07:18:08,700 --> 07:18:09,700
this concept will be more clear once we
10353
07:18:11,100 --> 07:18:12,100
actually Implement a third-party
10354
07:18:12,780 --> 07:18:13,780
libraries when we Implement a
10355
07:18:15,120 --> 07:18:16,120
third-party Library you actually have a
10356
07:18:17,280 --> 07:18:18,280
separate module for the library as well
10357
07:18:19,378 --> 07:18:20,378
as your plugin as a whole basically a
10358
07:18:22,138 --> 07:18:23,138
plugin acts as a wrapper so that it can
10359
07:18:24,660 --> 07:18:25,660
interface with Unreal Engine
10360
07:18:27,360 --> 07:18:28,360
because unreal standard API does differ
10361
07:18:30,360 --> 07:18:31,360
a little bit compared to your standard C
10362
07:18:32,520 --> 07:18:33,520
plus plus what you do generally so you'd
10363
07:18:35,520 --> 07:18:36,520
use the plugin as sort of a wrapper to
10364
07:18:37,860 --> 07:18:38,860
you know interconvert types so let's say
10365
07:18:39,780 --> 07:18:40,780
you wanted to convert all the STD
10366
07:18:41,878 --> 07:18:42,878
strings into s f strings which is there
10367
07:18:44,400 --> 07:18:45,400
in unreal so stuff like that so you
10368
07:18:46,620 --> 07:18:47,620
would have the plugin as a wrapper and
10369
07:18:48,718 --> 07:18:49,718
you would interface that uh through the
10370
07:18:51,120 --> 07:18:52,120
plugin inside the engine
10371
07:18:54,000 --> 07:18:55,000
so let's actually take a look at our
10372
07:18:56,280 --> 07:18:57,280
plugin now now that we have a basic idea
10373
07:18:58,320 --> 07:18:59,320
of build.cs
10374
07:18:59,878 --> 07:19:00,878
in our editor we already have our test
10375
07:19:02,520 --> 07:19:03,520
plugin content folder open
10376
07:19:04,798 --> 07:19:05,798
we can work with this normally but
10377
07:19:07,320 --> 07:19:08,320
anything we created uh inside here will
10378
07:19:10,200 --> 07:19:11,200
be actually packaged inside our plugin
10379
07:19:13,260 --> 07:19:14,260
so for example let's create an actor
10380
07:19:16,080 --> 07:19:17,080
class so let's just call it some actor
10381
07:19:20,840 --> 07:19:21,840
and whoops
10382
07:19:23,580 --> 07:19:24,580
and we can make it do something let's
10383
07:19:25,440 --> 07:19:26,440
say
10384
07:19:27,900 --> 07:19:28,900
so for example let's say we have some
10385
07:19:31,138 --> 07:19:32,138
logic so
10386
07:19:33,718 --> 07:19:34,718
let's say every frame it just prints out
10387
07:19:35,940 --> 07:19:36,940
something obviously you would have some
10388
07:19:38,520 --> 07:19:39,520
more practical logic in here
10389
07:19:40,860 --> 07:19:41,860
so let me go ahead and type something so
10390
07:19:43,260 --> 07:19:44,260
let's say
10391
07:19:45,718 --> 07:19:46,718
our
10392
07:19:47,280 --> 07:19:48,280
actor is ticking
10393
07:19:51,540 --> 07:19:52,540
something like that
10394
07:19:53,878 --> 07:19:54,878
and we could go ahead and have C plus
10395
07:19:55,798 --> 07:19:56,798
plus classes as well
10396
07:19:57,600 --> 07:19:58,600
so over here under Tools you can create
10397
07:20:01,200 --> 07:20:02,200
new C plus class I'm just showing you
10398
07:20:03,600 --> 07:20:04,600
guys how to do it because we did go over
10399
07:20:05,940 --> 07:20:06,940
the blueprint itself so you know how to
10400
07:20:08,878 --> 07:20:09,878
work with blueprint
10401
07:20:10,320 --> 07:20:11,320
it's just that you're creating it inside
10402
07:20:12,660 --> 07:20:13,660
this directory and I'll show you guys
10403
07:20:14,760 --> 07:20:15,760
how to reuse it in another project
10404
07:20:17,638 --> 07:20:18,638
so head into tools new C plus plus class
10405
07:20:20,580 --> 07:20:21,580
just like how we would let's say you
10406
07:20:22,920 --> 07:20:23,920
wanted to create an interface
10407
07:20:25,320 --> 07:20:26,320
so I just took an example
10408
07:20:27,660 --> 07:20:28,660
and instead of my interface we can call
10409
07:20:30,420 --> 07:20:31,420
this one
10410
07:20:31,740 --> 07:20:32,740
R plugin interface
10411
07:20:36,860 --> 07:20:37,860
and instead of beginner course you can
10412
07:20:39,780 --> 07:20:40,780
type in test plugin because this is a
10413
07:20:42,840 --> 07:20:43,840
separate module in itself and now if I
10414
07:20:45,660 --> 07:20:46,660
go ahead and create the class
10415
07:20:47,760 --> 07:20:48,760
you would see that under our source or
10416
07:20:52,020 --> 07:20:53,020
rather under our plugins folder so I'll
10417
07:20:54,000 --> 07:20:55,000
just reload the solution under a plugins
10418
07:20:56,458 --> 07:20:57,458
folder under the source folder now you
10419
07:20:59,280 --> 07:21:00,280
should be able to see our interface
10420
07:21:01,920 --> 07:21:02,920
so now you can work with this just like
10421
07:21:04,320 --> 07:21:05,320
how we would
10422
07:21:06,840 --> 07:21:07,840
with another file
10423
07:21:09,058 --> 07:21:10,058
so this is how you would actually go
10424
07:21:11,160 --> 07:21:12,160
about doing it
10425
07:21:13,138 --> 07:21:14,138
so now if I just go ahead and close this
10426
07:21:15,798 --> 07:21:16,798
and rather I'll just close the editor
10427
07:21:19,500 --> 07:21:20,500
and remember guys make sure your plugin
10428
07:21:21,840 --> 07:21:22,840
is enabled here if you are not able to
10429
07:21:23,820 --> 07:21:24,820
see it in the editor make sure you
10430
07:21:25,500 --> 07:21:26,500
enable this
10431
07:21:27,600 --> 07:21:28,600
so what you can do is first of all let's
10432
07:21:30,540 --> 07:21:31,540
see if it actually builds successfully
10433
07:21:33,958 --> 07:21:34,958
so we'll just create a new function
10434
07:21:36,900 --> 07:21:37,900
so it's going to be a virtual function
10435
07:21:38,580 --> 07:21:39,580
because we want to override so virtual
10436
07:21:42,718 --> 07:21:43,718
void
10437
07:21:45,240 --> 07:21:46,240
test function
10438
07:21:49,020 --> 07:21:50,020
and we can go ahead and leave it as is
10439
07:21:52,200 --> 07:21:53,200
we don't really require a default
10440
07:21:54,420 --> 07:21:55,420
implementation but we will have one
10441
07:21:56,100 --> 07:21:57,100
anyways so right click quick actions and
10442
07:21:59,760 --> 07:22:00,760
create
10443
07:22:02,100 --> 07:22:03,100
a default implementation
10444
07:22:04,320 --> 07:22:05,320
and now we should be able to implement
10445
07:22:06,360 --> 07:22:07,360
this interface so let's make this a u
10446
07:22:08,160 --> 07:22:09,160
function so you function
10447
07:22:12,240 --> 07:22:13,240
your function
10448
07:22:14,160 --> 07:22:15,160
and just to make our job a little bit
10449
07:22:16,200 --> 07:22:17,200
easier we'll just make it a blueprint
10450
07:22:17,878 --> 07:22:18,878
implementable event
10451
07:22:21,840 --> 07:22:22,840
so that we can actually just give the
10452
07:22:24,180 --> 07:22:25,180
logic in Blueprint itself
10453
07:22:26,040 --> 07:22:27,040
so this works and now if I just go ahead
10454
07:22:29,520 --> 07:22:30,520
and build this you should see that both
10455
07:22:32,280 --> 07:22:33,280
this plugin as well as our whole project
10456
07:22:35,280 --> 07:22:36,280
will
10457
07:22:36,420 --> 07:22:37,420
be actually built so it says blueprint
10458
07:22:39,600 --> 07:22:40,600
implementable events in interfaces must
10459
07:22:42,000 --> 07:22:43,000
not be declared virtual let's just fix
10460
07:22:43,740 --> 07:22:44,740
that
10461
07:22:45,298 --> 07:22:46,298
and now it should build as is
10462
07:22:50,100 --> 07:22:51,100
just make sure you don't have a
10463
07:22:51,958 --> 07:22:52,958
definition here because it will look for
10464
07:22:54,420 --> 07:22:55,420
the definition in Blueprint
10465
07:23:01,920 --> 07:23:02,920
now let's say I wanted to use this in
10466
07:23:04,620 --> 07:23:05,620
another project this is how you would go
10467
07:23:06,298 --> 07:23:07,298
about doing this so open up your editor
10468
07:23:08,760 --> 07:23:09,760
head into the plugin section again and
10469
07:23:11,160 --> 07:23:12,160
where you have your plugin over here
10470
07:23:12,540 --> 07:23:13,540
under project other
10471
07:23:14,700 --> 07:23:15,700
click on package just select a random
10472
07:23:17,040 --> 07:23:18,040
folder I'll just select my documents for
10473
07:23:19,320 --> 07:23:20,320
example
10474
07:23:20,218 --> 07:23:21,218
and go ahead and package the plugin
10475
07:23:24,660 --> 07:23:25,660
it will take a little bit of time
10476
07:23:27,958 --> 07:23:28,958
but once that's done you should be able
10477
07:23:30,540 --> 07:23:31,540
to implement that in another project so
10478
07:23:33,600 --> 07:23:34,600
meanwhile while this is actually
10479
07:23:35,638 --> 07:23:36,638
compiling we can go ahead and create
10480
07:23:37,500 --> 07:23:38,500
another project so open up your epic
10481
07:23:39,298 --> 07:23:40,298
games launcher
10482
07:23:41,340 --> 07:23:42,340
so our packaging is actually complete
10483
07:23:43,740 --> 07:23:44,740
before the launcher loaded up so you can
10484
07:23:46,500 --> 07:23:47,500
actually check it in our documents
10485
07:23:48,298 --> 07:23:49,298
folder so head into test test plugin and
10486
07:23:51,900 --> 07:23:52,900
you should be able to use this in your
10487
07:23:53,940 --> 07:23:54,940
projects and I'll show you guys how to
10488
07:23:55,920 --> 07:23:56,920
do that
10489
07:23:56,940 --> 07:23:57,940
so just ignore that head into Library
10490
07:23:59,040 --> 07:24:00,040
let's actually just launch the engine as
10491
07:24:01,558 --> 07:24:02,558
is
10492
07:24:03,000 --> 07:24:04,000
and over here we can go ahead and just
10493
07:24:05,458 --> 07:24:06,458
create a new project
10494
07:24:07,138 --> 07:24:08,138
so we'll just create a blank project
10495
07:24:09,378 --> 07:24:10,378
blank with nothing I'll just create
10496
07:24:11,760 --> 07:24:12,760
blueprint
10497
07:24:13,280 --> 07:24:14,280
and for the project name
10498
07:24:16,080 --> 07:24:17,080
uh okay we do have a C plus plus class
10499
07:24:19,200 --> 07:24:20,200
so it might actually want to rebuild
10500
07:24:22,200 --> 07:24:23,200
stuff once again so anyways what we'll
10501
07:24:25,200 --> 07:24:26,200
do is we can
10502
07:24:27,240 --> 07:24:28,240
create a C plus plus project call this
10503
07:24:29,940 --> 07:24:30,940
one
10504
07:24:30,660 --> 07:24:31,660
plugin test
10505
07:24:33,840 --> 07:24:34,840
and we can go ahead and create it
10506
07:24:37,320 --> 07:24:38,320
so I'll show you guys how to implement
10507
07:24:38,940 --> 07:24:39,940
it both in Blueprint and C plus
10508
07:24:41,700 --> 07:24:42,700
anyways now that we are actually in the
10509
07:24:44,218 --> 07:24:45,218
process of creating it
10510
07:24:46,860 --> 07:24:47,860
so it should take a while but eventually
10511
07:24:49,500 --> 07:24:50,500
once the project is opened up
10512
07:24:51,900 --> 07:24:52,900
we should be able to import the plugin
10513
07:24:54,620 --> 07:24:55,620
just like that and I'll show you guys
10514
07:24:57,058 --> 07:24:58,058
what steps you need to take in order to
10515
07:24:59,700 --> 07:25:00,700
actually get this in the plugins list
10516
07:25:02,218 --> 07:25:03,218
now our project has been created so we
10517
07:25:04,978 --> 07:25:05,978
are in a blank level just we'll just go
10518
07:25:07,138 --> 07:25:08,138
ahead and create a new map and let's
10519
07:25:09,240 --> 07:25:10,240
just call this one some level
10520
07:25:12,780 --> 07:25:13,780
open it up
10521
07:25:14,400 --> 07:25:15,400
save it
10522
07:25:15,780 --> 07:25:16,780
and make this the default project
10523
07:25:18,420 --> 07:25:19,420
settings
10524
07:25:19,920 --> 07:25:20,920
maps and modes make this the default
10525
07:25:24,420 --> 07:25:25,420
so that should be good and if you open
10526
07:25:27,478 --> 07:25:28,478
up your Visual Studio which we will open
10527
07:25:29,520 --> 07:25:30,520
later we'll close this up
10528
07:25:31,558 --> 07:25:32,558
and close the editor as well and
10529
07:25:34,378 --> 07:25:35,378
beginner course will just minimize that
10530
07:25:36,058 --> 07:25:37,058
for now
10531
07:25:37,020 --> 07:25:38,020
if I head into my file explorer what I
10532
07:25:39,780 --> 07:25:40,780
can do is I can copy this over
10533
07:25:42,240 --> 07:25:43,240
and where I have my other project so I
10534
07:25:45,840 --> 07:25:46,840
believe I created it under unreal
10535
07:25:47,760 --> 07:25:48,760
project so plug and test
10536
07:25:49,920 --> 07:25:50,920
and what you want to do is you want to
10537
07:25:51,540 --> 07:25:52,540
create a new folder called plugins
10538
07:25:55,138 --> 07:25:56,138
and paste this over there
10539
07:25:58,020 --> 07:25:59,020
now what I want you guys to do is right
10540
07:26:00,780 --> 07:26:01,780
click generate Visual Studio project
10541
07:26:03,240 --> 07:26:04,240
files
10542
07:26:05,160 --> 07:26:06,160
so this is actually going to integrate
10543
07:26:07,378 --> 07:26:08,378
it and once you're done with that if you
10544
07:26:09,958 --> 07:26:10,958
want to use the plugin content in C plus
10545
07:26:13,100 --> 07:26:14,100
all you have to do is head into source
10546
07:26:16,740 --> 07:26:17,740
plug-in test and under plugin test
10547
07:26:20,280 --> 07:26:21,280
build.cs
10548
07:26:22,378 --> 07:26:23,378
we don't actually need to come here
10549
07:26:24,120 --> 07:26:25,120
actually this is for the plugin what's
10550
07:26:26,100 --> 07:26:27,100
the plugin using so what you have to do
10551
07:26:27,780 --> 07:26:28,780
is head into your plugin test rather I
10552
07:26:30,600 --> 07:26:31,600
mean the project head into Source plugin
10553
07:26:34,860 --> 07:26:35,860
test build.cs
10554
07:26:36,900 --> 07:26:37,900
and over here
10555
07:26:38,878 --> 07:26:39,878
so I meant I meant to come here so over
10556
07:26:42,180 --> 07:26:43,180
here what I want you guys to do is
10557
07:26:45,840 --> 07:26:46,840
where we have our modules I want you
10558
07:26:50,100 --> 07:26:51,100
guys to add test plugin
10559
07:26:54,000 --> 07:26:55,000
uh just don't get confused plug-in test
10560
07:26:56,280 --> 07:26:57,280
is our unreal project name and test
10561
07:26:58,200 --> 07:26:59,200
plugin is our plugin name
10562
07:27:00,298 --> 07:27:01,298
and now I'll show you guys how to
10563
07:27:02,340 --> 07:27:03,340
implement it so we can go ahead and
10564
07:27:04,138 --> 07:27:05,138
build this once again
10565
07:27:06,478 --> 07:27:07,478
so we'll close everything up
10566
07:27:08,638 --> 07:27:09,638
and we'll just generate the visual
10567
07:27:10,798 --> 07:27:11,798
studio project files once again
10568
07:27:13,320 --> 07:27:14,320
and we'll close our beginner course
10569
07:27:16,138 --> 07:27:17,138
we'll open it up and we'll just create
10570
07:27:17,820 --> 07:27:18,820
one C plus plus class and maybe a
10571
07:27:19,920 --> 07:27:20,920
blueprint class
10572
07:27:21,180 --> 07:27:22,180
so we'll do blueprint first since we are
10573
07:27:23,280 --> 07:27:24,280
opening the editor anyways
10574
07:27:25,200 --> 07:27:26,200
so we have some level and if we actually
10575
07:27:28,500 --> 07:27:29,500
go ahead and create something so let me
10576
07:27:31,680 --> 07:27:32,680
just create an actor if I head into all
10577
07:27:34,620 --> 07:27:35,620
classes
10578
07:27:35,878 --> 07:27:36,878
and if I type in
10579
07:27:38,040 --> 07:27:39,040
so I'm not sure what I called it so we
10580
07:27:40,378 --> 07:27:41,378
can head into plugins and check test
10581
07:27:42,058 --> 07:27:43,058
plugin content some actor so
10582
07:27:45,360 --> 07:27:46,360
some actor as you can see we get some
10583
07:27:47,878 --> 07:27:48,878
actor now if you're not getting this it
10584
07:27:50,760 --> 07:27:51,760
simply means that you haven't enabled it
10585
07:27:53,218 --> 07:27:54,218
in your plugins so under installed other
10586
07:27:55,740 --> 07:27:56,740
you should have test plugin
10587
07:27:57,958 --> 07:27:58,958
and you should have your author name and
10588
07:28:00,000 --> 07:28:01,000
stuff like that
10589
07:28:01,260 --> 07:28:02,260
so make sure you have this enabled over
10590
07:28:03,180 --> 07:28:04,180
here
10591
07:28:04,440 --> 07:28:05,440
and now if I go ahead and drag this in
10592
07:28:07,200 --> 07:28:08,200
the world and if I press play as you can
10593
07:28:09,360 --> 07:28:10,360
see our code which we had in our actor
10594
07:28:12,298 --> 07:28:13,298
is now working in the other project
10595
07:28:15,600 --> 07:28:16,600
similarly we can use the interface as
10596
07:28:17,820 --> 07:28:18,820
well
10597
07:28:18,718 --> 07:28:19,718
so over here under class settings
10598
07:28:20,458 --> 07:28:21,458
implemented interfaces we can go ahead
10599
07:28:23,340 --> 07:28:24,340
and look for our interface
10600
07:28:25,920 --> 07:28:26,920
I think we called it our plugin
10601
07:28:27,780 --> 07:28:28,780
interface
10602
07:28:29,040 --> 07:28:30,040
and we have our test function which we
10603
07:28:31,200 --> 07:28:32,200
can Implement and we can go ahead and
10604
07:28:34,080 --> 07:28:35,080
tell
10605
07:28:35,458 --> 07:28:36,458
something
10606
07:28:36,620 --> 07:28:37,620
so you could just say test function
10607
07:28:40,440 --> 07:28:41,440
called
10608
07:28:43,020 --> 07:28:44,020
in order to implement this however we
10609
07:28:45,900 --> 07:28:46,900
would require C plus plus since we
10610
07:28:48,900 --> 07:28:49,900
actually didn't make this blueprint
10611
07:28:50,760 --> 07:28:51,760
callable however we can still choose to
10612
07:28:53,520 --> 07:28:54,520
edit it in the source order so if I just
10613
07:28:55,620 --> 07:28:56,620
head into our source and if I actually
10614
07:29:00,120 --> 07:29:01,120
go ahead and edit the CPP file we can
10615
07:29:03,620 --> 07:29:04,620
actually rather in the plugins folder
10616
07:29:07,320 --> 07:29:08,320
test plugin if I head into the source
10617
07:29:09,718 --> 07:29:10,718
folder and edit the CPP file
10618
07:29:12,240 --> 07:29:13,240
or rather the dot hatch file and add the
10619
07:29:15,240 --> 07:29:16,240
blueprint callable specifier I would
10620
07:29:17,820 --> 07:29:18,820
still be able to you know use this over
10621
07:29:20,160 --> 07:29:21,160
here but anyways we will implement it in
10622
07:29:23,700 --> 07:29:24,700
some class which we create here so I'll
10623
07:29:26,100 --> 07:29:27,100
just go ahead and close Visual Studio
10624
07:29:27,718 --> 07:29:28,718
here and I'll go ahead and create
10625
07:29:32,520 --> 07:29:33,520
something so we can
10626
07:29:35,040 --> 07:29:36,040
create a new C plus class of type actor
10627
07:29:37,860 --> 07:29:38,860
we are able to implement this but we
10628
07:29:40,440 --> 07:29:41,440
can't call it that's the reason we're
10629
07:29:42,000 --> 07:29:43,000
actually doing it so we'll just call it
10630
07:29:43,978 --> 07:29:44,978
my actor for now
10631
07:29:45,478 --> 07:29:46,478
and go ahead and create it
10632
07:29:51,360 --> 07:29:52,360
so live coding should do its thing
10633
07:29:56,160 --> 07:29:57,160
so our file should in fact open up in a
10634
07:29:59,940 --> 07:30:00,940
new window right now
10635
07:30:02,878 --> 07:30:03,878
and go ahead
10636
07:30:04,798 --> 07:30:05,798
and just don't mind it opened up in a
10637
07:30:07,138 --> 07:30:08,138
separate window
10638
07:30:08,520 --> 07:30:09,520
and now we can feel free to go ahead and
10639
07:30:11,520 --> 07:30:12,520
include our interface
10640
07:30:13,680 --> 07:30:14,680
just gone ahead and reopened the
10641
07:30:15,718 --> 07:30:16,718
solution file here now inside my actor.h
10642
07:30:19,138 --> 07:30:20,138
since we included the module in the
10643
07:30:21,660 --> 07:30:22,660
build.cs file we should simply be able
10644
07:30:23,700 --> 07:30:24,700
to include r
10645
07:30:25,798 --> 07:30:26,798
plugin interface.h
10646
07:30:30,478 --> 07:30:31,478
now you should be simply able to inherit
10647
07:30:33,180 --> 07:30:34,180
the interface by using public I or my R
10648
07:30:37,978 --> 07:30:38,978
plugin interface and now we have
10649
07:30:40,440 --> 07:30:41,440
successfully inherited the interface now
10650
07:30:42,900 --> 07:30:43,900
the since this was a blueprint
10651
07:30:44,580 --> 07:30:45,580
implementable event you can just go
10652
07:30:46,680 --> 07:30:47,680
ahead and use it in Blueprint itself and
10653
07:30:49,020 --> 07:30:50,020
just to make things a bit convenient for
10654
07:30:50,760 --> 07:30:51,760
us we can head into our R plugin
10655
07:30:52,620 --> 07:30:53,620
interface.h file under the plugins
10656
07:30:54,478 --> 07:30:55,478
folder and we can add in the blueprint
10657
07:30:56,878 --> 07:30:57,878
callable flag
10658
07:30:58,200 --> 07:30:59,200
so now we can go ahead and actually call
10659
07:31:00,540 --> 07:31:01,540
it from the blueprint
10660
07:31:02,280 --> 07:31:03,280
so we can go ahead and run a debugger
10661
07:31:05,100 --> 07:31:06,100
now so this is how you implement it in C
10662
07:31:07,558 --> 07:31:08,558
plus plus
10663
07:31:09,958 --> 07:31:10,958
my main intention here was to show how
10664
07:31:12,298 --> 07:31:13,298
to include the header file rather than
10665
07:31:14,400 --> 07:31:15,400
using the interface that is something
10666
07:31:16,080 --> 07:31:17,080
which we already covered
10667
07:31:18,780 --> 07:31:19,780
so wait for the editor to load
10668
07:31:22,740 --> 07:31:23,740
and once the editor is loaded in what we
10669
07:31:25,200 --> 07:31:26,200
can do is we can go ahead and create a
10670
07:31:26,700 --> 07:31:27,700
new blueprint class and we can remove
10671
07:31:28,260 --> 07:31:29,260
this actor first of all otherwise it'll
10672
07:31:30,420 --> 07:31:31,420
keep printing our actor sticking
10673
07:31:32,940 --> 07:31:33,940
so go ahead
10674
07:31:34,558 --> 07:31:35,558
select actor we'll leave this at new
10675
07:31:37,080 --> 07:31:38,080
blueprint one add this
10676
07:31:39,000 --> 07:31:40,000
and under the parent class or we could
10677
07:31:41,340 --> 07:31:42,340
have done it over there itself
10678
07:31:43,558 --> 07:31:44,558
and select my actor
10679
07:31:46,860 --> 07:31:47,860
and now again we have our test function
10680
07:31:50,400 --> 07:31:51,400
and we can again go ahead and Implement
10681
07:31:52,378 --> 07:31:53,378
our event so we can go ahead and print
10682
07:31:54,718 --> 07:31:55,718
something let's say
10683
07:31:56,760 --> 07:31:57,760
test function called
10684
07:32:01,440 --> 07:32:02,440
or we could have gone ahead and
10685
07:32:03,360 --> 07:32:04,360
inherited uh my actor instead of some
10686
07:32:06,600 --> 07:32:07,600
actor here but then again you would have
10687
07:32:09,000 --> 07:32:10,000
to change some other stuff so we'll just
10688
07:32:11,040 --> 07:32:12,040
redo this
10689
07:32:12,298 --> 07:32:13,298
and now if I go ahead and press play
10690
07:32:14,040 --> 07:32:15,040
nothing's gonna happen headed to your
10691
07:32:15,660 --> 07:32:16,660
level blueprint and for example just go
10692
07:32:18,958 --> 07:32:19,958
ahead and get a reference to it and now
10693
07:32:21,958 --> 07:32:22,958
if I just call in test function
10694
07:32:25,020 --> 07:32:26,020
test function message this is what we
10695
07:32:27,420 --> 07:32:28,420
want
10696
07:32:29,218 --> 07:32:30,218
and now if I go ahead and press play you
10697
07:32:31,740 --> 07:32:32,740
see we get test function called
10698
07:32:34,020 --> 07:32:35,020
so this is basically how you do it guys
10699
07:32:36,600 --> 07:32:37,600
so this is basically how you would use a
10700
07:32:39,298 --> 07:32:40,298
plugin which you made and implement it
10701
07:32:42,180 --> 07:32:43,180
in another project and as you guys saw
10702
07:32:44,638 --> 07:32:45,638
you can absolutely feel free to edit the
10703
07:32:47,760 --> 07:32:48,760
plugin contents once you have pasted it
10704
07:32:50,100 --> 07:32:51,100
in this plugin folder
10705
07:32:52,740 --> 07:32:53,740
foreign
10706
07:33:00,200 --> 07:33:01,200
libraries now there is one thing to
10707
07:33:03,298 --> 07:33:04,298
understand before we actually head into
10708
07:33:05,340 --> 07:33:06,340
implementing them and that is that there
10709
07:33:08,218 --> 07:33:09,218
are differences between your standard C
10710
07:33:10,440 --> 07:33:11,440
plus plus API and the unreal C plus plus
10711
07:33:12,958 --> 07:33:13,958
API a very simple example would be the
10712
07:33:16,978 --> 07:33:17,978
difference between STD string and F
10713
07:33:19,620 --> 07:33:20,620
string so in unreal you use F string
10714
07:33:22,680 --> 07:33:23,680
whereas in standard C plus plus you
10715
07:33:24,958 --> 07:33:25,958
generally use STD string now
10716
07:33:27,558 --> 07:33:28,558
interconverting between them is really
10717
07:33:29,638 --> 07:33:30,638
easy so if you want to implement a third
10718
07:33:33,180 --> 07:33:34,180
party Library the way you would do it is
10719
07:33:36,000 --> 07:33:37,000
you would build your third party library
10720
07:33:38,340 --> 07:33:39,340
inside of a plugin so basically you
10721
07:33:40,798 --> 07:33:41,798
would put it in a separate folder and I
10722
07:33:42,718 --> 07:33:43,718
will show you guys the procedure so
10723
07:33:44,160 --> 07:33:45,160
nothing to worry about that
10724
07:33:45,860 --> 07:33:46,860
and the the unreal plugin which you will
10725
07:33:49,440 --> 07:33:50,440
create will act as a wrapper to kind of
10726
07:33:52,260 --> 07:33:53,260
you know interface between the standard
10727
07:33:54,420 --> 07:33:55,420
C plus plus and unreal C plus plus API
10728
07:33:57,780 --> 07:33:58,780
so the way you do it is again create
10729
07:34:00,780 --> 07:34:01,780
create a new plugin first
10730
07:34:02,820 --> 07:34:03,820
select this third party Library template
10731
07:34:05,280 --> 07:34:06,280
because
10732
07:34:07,080 --> 07:34:08,080
it has most of the important things that
10733
07:34:09,420 --> 07:34:10,420
you would need in order to actually set
10734
07:34:11,400 --> 07:34:12,400
it up so again I'll just put gaming for
10735
07:34:13,978 --> 07:34:14,978
the author and I'll just call it some
10736
07:34:17,100 --> 07:34:18,100
third party Library
10737
07:34:20,520 --> 07:34:21,520
Library plugin
10738
07:34:23,340 --> 07:34:24,340
and over here we can just call this one
10739
07:34:26,820 --> 07:34:27,820
TPL underscore Plugin or something like
10740
07:34:29,820 --> 07:34:30,820
that
10741
07:34:33,360 --> 07:34:34,360
so third party Library plugin so go
10742
07:34:36,058 --> 07:34:37,058
ahead and create it
10743
07:34:40,500 --> 07:34:41,500
so now this dialog box should appear
10744
07:34:43,200 --> 07:34:44,200
over here a rather message box and we'll
10745
07:34:45,478 --> 07:34:46,478
just click open or okay
10746
07:34:48,000 --> 07:34:49,000
so basically that was just some code
10747
07:34:50,760 --> 07:34:51,760
which was written in the example Library
10748
07:34:53,940 --> 07:34:54,940
now over here we shall not be using
10749
07:34:57,478 --> 07:34:58,478
their Library so they have actually
10750
07:34:59,820 --> 07:35:00,820
provided us with a library which we can
10751
07:35:01,860 --> 07:35:02,860
use as a reference so if I add into
10752
07:35:03,298 --> 07:35:04,298
plugins TPL plugin Source you see there
10753
07:35:06,840 --> 07:35:07,840
are two folders here now third part is
10754
07:35:09,058 --> 07:35:10,058
the folder where you'll have your third
10755
07:35:10,680 --> 07:35:11,680
party library and TPL plugin is the
10756
07:35:14,520 --> 07:35:15,520
folder where you would you know have
10757
07:35:16,620 --> 07:35:17,620
your plugin content
10758
07:35:19,020 --> 07:35:20,020
and anything uh under this folder would
10759
07:35:22,378 --> 07:35:23,378
be edited in your project solution file
10760
07:35:24,478 --> 07:35:25,478
and I'll show you guys what I mean
10761
07:35:27,420 --> 07:35:28,420
so right now heading to third party
10762
07:35:29,520 --> 07:35:30,520
third party
10763
07:35:31,040 --> 07:35:32,040
plug-in live plug-in Library so what we
10764
07:35:35,760 --> 07:35:36,760
can do is over here as you can see there
10765
07:35:39,180 --> 07:35:40,180
is an example Library
10766
07:35:41,580 --> 07:35:42,580
now whichever file says example Library
10767
07:35:45,440 --> 07:35:46,440
dot something that is basically your
10768
07:35:49,138 --> 07:35:50,138
actual third party Library so in order
10769
07:35:51,840 --> 07:35:52,840
to implement our own third party Library
10770
07:35:54,120 --> 07:35:55,120
we can go ahead and delete whatever they
10771
07:35:56,520 --> 07:35:57,520
have put over here
10772
07:35:58,200 --> 07:35:59,200
so we don't need any of this
10773
07:36:00,478 --> 07:36:01,478
so this is just an example and what they
10774
07:36:03,958 --> 07:36:04,958
have done is they've used a dll but I'll
10775
07:36:06,240 --> 07:36:07,240
be showing you guys how to implement a
10776
07:36:07,860 --> 07:36:08,860
static library and a dll separately so
10777
07:36:11,280 --> 07:36:12,280
we'll do a static one first so I'll just
10778
07:36:12,958 --> 07:36:13,958
go ahead and delete all of this
10779
07:36:15,240 --> 07:36:16,240
now what we are left with is a blank uh
10780
07:36:19,200 --> 07:36:20,200
folder with just the build.cs file so
10781
07:36:22,798 --> 07:36:23,798
what you want to do now is open up
10782
07:36:25,680 --> 07:36:26,680
visual studio
10783
07:36:29,878 --> 07:36:30,878
and over here you can go ahead and
10784
07:36:31,798 --> 07:36:32,798
create a new project
10785
07:36:33,420 --> 07:36:34,420
of type static Library
10786
07:36:35,940 --> 07:36:36,940
and click next
10787
07:36:37,558 --> 07:36:38,558
and we'll just call this
10788
07:36:40,440 --> 07:36:41,440
I don't know
10789
07:36:42,120 --> 07:36:43,120
test third party library or something
10790
07:36:46,978 --> 07:36:47,978
so test third party liability
10791
07:36:50,700 --> 07:36:51,700
so we'll create it under a g
10792
07:36:53,160 --> 07:36:54,160
repositories or rather we'll just select
10793
07:36:55,260 --> 07:36:56,260
our solution folder
10794
07:36:57,600 --> 07:36:58,600
so we'll go ahead and select our
10795
07:37:01,378 --> 07:37:02,378
beginner course
10796
07:37:03,058 --> 07:37:04,058
head into
10797
07:37:05,340 --> 07:37:06,340
the plugins folder PPL plugin Source
10798
07:37:08,400 --> 07:37:09,400
third party third part TPL plugin
10799
07:37:11,340 --> 07:37:12,340
Library select this folder and what we
10800
07:37:14,638 --> 07:37:15,638
can do here is we can check Place
10801
07:37:17,580 --> 07:37:18,580
solution and project in the same
10802
07:37:19,620 --> 07:37:20,620
directory so we would have all those
10803
07:37:21,840 --> 07:37:22,840
project files as they appeared in the
10804
07:37:24,120 --> 07:37:25,120
example so go ahead and press create
10805
07:37:28,378 --> 07:37:29,378
now you should see that our library is
10806
07:37:31,860 --> 07:37:32,860
actually created
10807
07:37:33,958 --> 07:37:34,958
so if I go ahead and open up
10808
07:37:37,558 --> 07:37:38,558
this folder over here
10809
07:37:39,900 --> 07:37:40,900
as you see this folder has been created
10810
07:37:43,680 --> 07:37:44,680
it's not necessary that you have it over
10811
07:37:46,740 --> 07:37:47,740
here
10812
07:37:47,878 --> 07:37:48,878
so you can just go ahead cut this and
10813
07:37:51,298 --> 07:37:52,298
paste this over here
10814
07:37:53,100 --> 07:37:54,100
and you can go ahead and delete this
10815
07:37:54,840 --> 07:37:55,840
folder
10816
07:37:56,040 --> 07:37:57,040
so it's open in visual studio so I'll
10817
07:37:58,680 --> 07:37:59,680
just close everything
10818
07:38:00,240 --> 07:38:01,240
so I'll just save it
10819
07:38:02,360 --> 07:38:03,360
so we can just cut this and paste it
10820
07:38:04,860 --> 07:38:05,860
over here so we shouldn't have opened
10821
07:38:07,378 --> 07:38:08,378
that so we'll just replace it as of now
10822
07:38:10,138 --> 07:38:11,138
nothing should happen
10823
07:38:12,058 --> 07:38:13,058
now once you're done with this we can
10824
07:38:14,520 --> 07:38:15,520
open up our build.cs file
10825
07:38:18,298 --> 07:38:19,298
and over here you would notice that we
10826
07:38:20,820 --> 07:38:21,820
have a bunch of stuff which you
10827
07:38:22,860 --> 07:38:23,860
seriously which I seriously don't expect
10828
07:38:25,558 --> 07:38:26,558
you to understand uh basically these are
10829
07:38:28,978 --> 07:38:29,978
for Linux and Mac so you can just go
10830
07:38:30,958 --> 07:38:31,958
ahead and delete this I'm not going to
10831
07:38:33,660 --> 07:38:34,660
be showing how to work with DOT so files
10832
07:38:36,180 --> 07:38:37,180
and stuff so I'm not really a Linux guy
10833
07:38:38,760 --> 07:38:39,760
so we'll just be working with our
10834
07:38:42,120 --> 07:38:43,120
Windows Library
10835
07:38:44,218 --> 07:38:45,218
so we'll not do the dll now so I'll just
10836
07:38:47,520 --> 07:38:48,520
comment this out
10837
07:38:49,378 --> 07:38:50,378
we'll do the dll a bit later and what
10838
07:38:52,558 --> 07:38:53,558
this is is this is basically our
10839
07:38:55,700 --> 07:38:56,700
library directory
10840
07:38:58,378 --> 07:38:59,378
and the library file itself
10841
07:39:00,958 --> 07:39:01,958
now example library.lib was the file
10842
07:39:04,440 --> 07:39:05,440
which they had created so whatever
10843
07:39:07,680 --> 07:39:08,680
example Library they had
10844
07:39:10,200 --> 07:39:11,200
that file was named example library.lib
10845
07:39:13,500 --> 07:39:14,500
but ours isn't yet here so we can just
10846
07:39:17,160 --> 07:39:18,160
go ahead and add in some sample code so
10847
07:39:19,080 --> 07:39:20,080
that we can actually create it
10848
07:39:21,360 --> 07:39:22,360
so head in here
10849
07:39:23,280 --> 07:39:24,280
change the configuration to release
10850
07:39:24,900 --> 07:39:25,900
first things first
10851
07:39:26,760 --> 07:39:27,760
and head into source files add a new
10852
07:39:30,660 --> 07:39:31,660
item
10853
07:39:33,120 --> 07:39:34,120
and over here you can go ahead and
10854
07:39:35,160 --> 07:39:36,160
create a DOT hatch file because we will
10855
07:39:37,320 --> 07:39:38,320
need some sort of a header to include it
10856
07:39:39,780 --> 07:39:40,780
so we can just type in test class we'll
10857
07:39:42,718 --> 07:39:43,718
just create a class
10858
07:39:44,340 --> 07:39:45,340
so testclass.h
10859
07:39:46,978 --> 07:39:47,978
maybe you can create some static method
10860
07:39:48,958 --> 07:39:49,958
inside
10861
07:39:51,558 --> 07:39:52,558
and over here uh we can actually move
10862
07:39:54,840 --> 07:39:55,840
this over to the header file section
10863
07:39:57,600 --> 07:39:58,600
right click on source file add new item
10864
07:40:00,718 --> 07:40:01,718
head of source CPP file and we can call
10865
07:40:03,600 --> 07:40:04,600
this one
10866
07:40:04,740 --> 07:40:05,740
testclass.cpp
10867
07:40:08,400 --> 07:40:09,400
and once both of these files are open
10868
07:40:11,040 --> 07:40:12,040
over here we can just start writing our
10869
07:40:13,378 --> 07:40:14,378
class so we can call this test class
10870
07:40:17,940 --> 07:40:18,940
and under the public section we can
10871
07:40:20,100 --> 07:40:21,100
simply have a method so under public
10872
07:40:23,160 --> 07:40:24,160
and under private we can have a string
10873
07:40:25,440 --> 07:40:26,440
variable so STD
10874
07:40:27,900 --> 07:40:28,900
string
10875
07:40:29,820 --> 07:40:30,820
and we need to include string obviously
10876
07:40:32,100 --> 07:40:33,100
so hash include
10877
07:40:34,020 --> 07:40:35,020
string
10878
07:40:38,580 --> 07:40:39,580
so we have our STD string we'll just
10879
07:40:41,160 --> 07:40:42,160
create a variable called
10880
07:40:44,340 --> 07:40:45,340
maybe test string
10881
07:40:48,120 --> 07:40:49,120
and we can write a Constructor here to
10882
07:40:50,340 --> 07:40:51,340
just initialize it so what we can do is
10883
07:40:53,400 --> 07:40:54,400
we can go ahead and create
10884
07:40:55,798 --> 07:40:56,798
test class
10885
07:40:59,218 --> 07:41:00,218
and write the definition for the
10886
07:41:01,080 --> 07:41:02,080
Constructor the reason I'm not doing it
10887
07:41:03,478 --> 07:41:04,478
in line over here is because I want to
10888
07:41:06,298 --> 07:41:07,298
show you guys that the lib file is
10889
07:41:08,100 --> 07:41:09,100
actually doing something so if we have
10890
07:41:10,080 --> 07:41:11,080
the definition right here so we wouldn't
10891
07:41:12,540 --> 07:41:13,540
really need the library file
10892
07:41:15,600 --> 07:41:16,600
now I can go ahead and create the
10893
07:41:17,878 --> 07:41:18,878
definition for it
10894
07:41:21,958 --> 07:41:22,958
and what we can do now is under this
10895
07:41:25,920 --> 07:41:26,920
we can go ahead and just
10896
07:41:28,260 --> 07:41:29,260
initialize our string so we can say test
10897
07:41:31,520 --> 07:41:32,520
string equals
10898
07:41:36,240 --> 07:41:37,240
this is some test string
10899
07:41:40,558 --> 07:41:41,558
doesn't really matter what you put in
10900
07:41:42,360 --> 07:41:43,360
there and we can just have a method so
10901
07:41:44,878 --> 07:41:45,878
we can have STD
10902
07:41:47,458 --> 07:41:48,458
string
10903
07:41:48,840 --> 07:41:49,840
get name maybe
10904
07:41:52,260 --> 07:41:53,260
now this is going to return that string
10905
07:41:55,260 --> 07:41:56,260
basically
10906
07:41:57,180 --> 07:41:58,180
so we can go ahead and test that so we
10907
07:42:00,058 --> 07:42:01,058
can go ahead and return test string
10908
07:42:03,900 --> 07:42:04,900
now this should be about it for this
10909
07:42:06,420 --> 07:42:07,420
so before you go ahead and build it just
10910
07:42:08,638 --> 07:42:09,638
set up this pch.h file and stuff so go
10911
07:42:12,420 --> 07:42:13,420
ahead over here instead of test class
10912
07:42:14,340 --> 07:42:15,340
dot head just include this pch.h
10913
07:42:18,180 --> 07:42:19,180
and what you would want to do is you
10914
07:42:19,920 --> 07:42:20,920
would want to come here and just include
10915
07:42:22,020 --> 07:42:23,020
your test class dot Edge over here so
10916
07:42:25,440 --> 07:42:26,440
now this should compile so if I go ahead
10917
07:42:27,840 --> 07:42:28,840
and press build
10918
07:42:29,160 --> 07:42:30,160
make sure it's in release configuration
10919
07:42:31,798 --> 07:42:32,798
and it should work so now if you were to
10920
07:42:34,680 --> 07:42:35,680
head into your TPL plugin Library folder
10921
07:42:37,500 --> 07:42:38,500
now under this x64 folder which has been
10922
07:42:40,620 --> 07:42:41,620
created you should find your dot lib
10923
07:42:42,660 --> 07:42:43,660
file don't worry about all these other
10924
07:42:44,458 --> 07:42:45,458
files just go ahead and copy this file
10925
07:42:46,558 --> 07:42:47,558
name which will be the same as your
10926
07:42:48,840 --> 07:42:49,840
library files name I mean your libraries
10927
07:42:51,958 --> 07:42:52,958
name
10928
07:42:52,978 --> 07:42:53,978
so test third partylibrary.lib that is
10929
07:42:56,218 --> 07:42:57,218
the file which we want to include
10930
07:42:59,040 --> 07:43:00,040
so now that we are done with this now we
10931
07:43:01,740 --> 07:43:02,740
should in theory be able to wrap this
10932
07:43:05,160 --> 07:43:06,160
using our TPL plugin now this is
10933
07:43:08,100 --> 07:43:09,100
actually the code for our unreal plugin
10934
07:43:11,160 --> 07:43:12,160
now inside this we'll actually be
10935
07:43:13,920 --> 07:43:14,920
writing some code in order to just wrap
10936
07:43:16,680 --> 07:43:17,680
this class whatever we wrote over there
10937
07:43:20,280 --> 07:43:21,280
so go ahead and head into your beginner
10938
07:43:23,940 --> 07:43:24,940
course solution
10939
07:43:25,620 --> 07:43:26,620
that is your main project solution
10940
07:43:31,860 --> 07:43:32,860
and now if you head into your test
10941
07:43:34,860 --> 07:43:35,860
plugin
10942
07:43:37,320 --> 07:43:38,320
or rather the one which you created now
10943
07:43:40,020 --> 07:43:41,020
so TPL plugin source TPL plugin
10944
07:43:44,878 --> 07:43:45,878
and we should be able to actually work
10945
07:43:47,218 --> 07:43:48,218
with this so we'll just do it inside
10946
07:43:48,718 --> 07:43:49,718
this header file uh as I showed you for
10947
07:43:52,798 --> 07:43:53,798
the previous plugin if you want to add
10948
07:43:54,478 --> 07:43:55,478
in more files and stuff you can do it
10949
07:43:57,058 --> 07:43:58,058
through the project or we can actually
10950
07:43:58,620 --> 07:43:59,620
do that actually since we have our
10951
07:44:00,360 --> 07:44:01,360
solution open anyways I mean our unreal
10952
07:44:02,580 --> 07:44:03,580
project
10953
07:44:03,958 --> 07:44:04,958
so over here we can go ahead into tools
10954
07:44:06,840 --> 07:44:07,840
add a new C plus plus class we don't
10955
07:44:09,958 --> 07:44:10,958
really require an actor so we'll create
10956
07:44:12,540 --> 07:44:13,540
an object so object
10957
07:44:15,478 --> 07:44:16,478
create it and we'll call this one
10958
07:44:18,200 --> 07:44:19,200
wrapper object
10959
07:44:21,298 --> 07:44:22,298
and this will just be under my TPL
10960
07:44:24,240 --> 07:44:25,240
plugin
10961
07:44:25,440 --> 07:44:26,440
so we can close our solution since it
10962
07:44:27,660 --> 07:44:28,660
will open it up once again and create
10963
07:44:29,400 --> 07:44:30,400
the class
10964
07:44:31,138 --> 07:44:32,138
now if you were to open up your solution
10965
07:44:33,240 --> 07:44:34,240
you should see a wrapper object.cpp and
10966
07:44:36,000 --> 07:44:37,000
stuff and one more thing uh this is
10967
07:44:38,940 --> 07:44:39,940
something which you really don't need
10968
07:44:42,478 --> 07:44:43,478
so now you can just feel free to head
10969
07:44:45,058 --> 07:44:46,058
into this function here and just delete
10970
07:44:47,580 --> 07:44:48,580
all this code and over here as well you
10971
07:44:50,638 --> 07:44:51,638
can go ahead and just delete this make
10972
07:44:52,260 --> 07:44:53,260
sure you just have the functions and for
10973
07:44:54,600 --> 07:44:55,600
this one basically we don't have our
10974
07:44:56,878 --> 07:44:57,878
example library.h we instead have our
10975
07:44:59,160 --> 07:45:00,160
test class.h
10976
07:45:01,080 --> 07:45:02,080
so this will work we don't need it here
10977
07:45:03,240 --> 07:45:04,240
so we aren't going to use it so you can
10978
07:45:05,820 --> 07:45:06,820
just leave the rest of it as is
10979
07:45:08,180 --> 07:45:09,180
and now if we were to continue now
10980
07:45:12,000 --> 07:45:13,000
but now if I were to go ahead and build
10981
07:45:14,280 --> 07:45:15,280
this so if I just go ahead and hit build
10982
07:45:18,540 --> 07:45:19,540
now wait for it and now you notice you
10983
07:45:21,840 --> 07:45:22,840
actually get errors even though you
10984
07:45:23,580 --> 07:45:24,580
didn't have any code
10985
07:45:25,260 --> 07:45:26,260
uh the reason is
10986
07:45:27,180 --> 07:45:28,180
well we don't actually have our uobject
10987
07:45:30,298 --> 07:45:31,298
module if you get any errors like this
10988
07:45:32,340 --> 07:45:33,340
cannot open include file and it's
10989
07:45:34,978 --> 07:45:35,978
something like this basically it's the
10990
07:45:38,520 --> 07:45:39,520
same thing you haven't included the
10991
07:45:40,138 --> 07:45:41,138
module so what you have to do is head
10992
07:45:42,240 --> 07:45:43,240
into your
10993
07:45:44,240 --> 07:45:45,240
uh TPL plugin
10994
07:45:47,478 --> 07:45:48,478
undersource you should find your TPL
10995
07:45:50,340 --> 07:45:51,340
plugin build.cs file and if you were to
10996
07:45:53,100 --> 07:45:54,100
recall your main build.cs file that is
10997
07:45:55,740 --> 07:45:56,740
your projects build.cs file so if I head
10998
07:45:58,378 --> 07:45:59,378
into Source begin a course beginner
10999
07:46:00,660 --> 07:46:01,660
course build.cs you see there is a
11000
07:46:02,458 --> 07:46:03,458
module known as score you object and
11001
07:46:05,160 --> 07:46:06,160
this isn't there in the TPL plugin
11002
07:46:08,100 --> 07:46:09,100
build.cs so I'll just go ahead and
11003
07:46:09,718 --> 07:46:10,718
include that and now it should build
11004
07:46:11,280 --> 07:46:12,280
successfully so if I just click on build
11005
07:46:14,700 --> 07:46:15,700
now this should build with absolutely no
11006
07:46:17,160 --> 07:46:18,160
problems
11007
07:46:18,360 --> 07:46:19,360
so now we can go about implementing a
11008
07:46:21,180 --> 07:46:22,180
wrapper object basically we are trying
11009
07:46:23,040 --> 07:46:24,040
to get our test class to work with our
11010
07:46:25,500 --> 07:46:26,500
actual code here
11011
07:46:27,058 --> 07:46:28,058
so I'll just do it under the public
11012
07:46:28,740 --> 07:46:29,740
section so whenever this uh your object
11013
07:46:32,940 --> 07:46:33,940
that is your wrapper object will be
11014
07:46:34,620 --> 07:46:35,620
instantiated I want our actual
11015
07:46:37,920 --> 07:46:38,920
third-party Library object to be
11016
07:46:39,958 --> 07:46:40,958
instantiated as well so we can go ahead
11017
07:46:42,058 --> 07:46:43,058
and type in test class
11018
07:46:44,580 --> 07:46:45,580
class
11019
07:46:45,900 --> 07:46:46,900
obj
11020
07:46:47,400 --> 07:46:48,400
equals we had a default Constructor so
11021
07:46:49,978 --> 07:46:50,978
we'll just call that and the reason we
11022
07:46:52,020 --> 07:46:53,020
get errors is because we haven't
11023
07:46:53,580 --> 07:46:54,580
included the header so we can get TPL
11024
07:46:57,240 --> 07:46:58,240
plugin
11025
07:46:58,860 --> 07:46:59,860
Library so Library
11026
07:47:02,340 --> 07:47:03,340
and we call it testclass.h
11027
07:47:06,240 --> 07:47:07,240
now we shouldn't get that error now we
11028
07:47:08,820 --> 07:47:09,820
should be able to create our object and
11029
07:47:10,920 --> 07:47:11,920
now we can go about writing our
11030
07:47:12,840 --> 07:47:13,840
functions for it so the only difference
11031
07:47:15,240 --> 07:47:16,240
in the main with the standard C plus
11032
07:47:18,000 --> 07:47:19,000
plus API and unreals API in our example
11033
07:47:22,020 --> 07:47:23,020
is that we used STD string over there
11034
07:47:24,660 --> 07:47:25,660
but we want to use F string so we can
11035
07:47:27,540 --> 07:47:28,540
write a u function for it so your
11036
07:47:29,340 --> 07:47:30,340
function we can just call it get name
11037
07:47:32,820 --> 07:47:33,820
and the return type is going to be F
11038
07:47:34,740 --> 07:47:35,740
string of course
11039
07:47:37,798 --> 07:47:38,798
and we can create a definition for it
11040
07:47:42,120 --> 07:47:43,120
create a definition
11041
07:47:43,978 --> 07:47:44,978
open it up and inside the F string
11042
07:47:46,798 --> 07:47:47,798
Constructor we can get our object obj
11043
07:47:49,320 --> 07:47:50,320
dot get name Dot cstr
11044
07:47:53,520 --> 07:47:54,520
so C Str
11045
07:47:56,340 --> 07:47:57,340
so this is how we can just convert it
11046
07:47:58,440 --> 07:47:59,440
now this is something related to the
11047
07:48:00,240 --> 07:48:01,240
conversion you can just look into the
11048
07:48:02,218 --> 07:48:03,218
documentation or the Forum so this is
11049
07:48:04,320 --> 07:48:05,320
how we would go about converting it and
11050
07:48:06,780 --> 07:48:07,780
we'll make this one blueprint callable
11051
07:48:08,280 --> 07:48:09,280
as well just so that we can test it in
11052
07:48:10,740 --> 07:48:11,740
Blueprint are now successfully we have
11053
07:48:14,040 --> 07:48:15,040
translated our standard C plus plus
11054
07:48:15,840 --> 07:48:16,840
function in our third party library and
11055
07:48:18,718 --> 07:48:19,718
this is now usable in unreal so if I
11056
07:48:21,900 --> 07:48:22,900
just go ahead and run a debugger here
11057
07:48:26,940 --> 07:48:27,940
inside our project now we can ignore
11058
07:48:30,298 --> 07:48:31,298
this and we can head into content and
11059
07:48:33,420 --> 07:48:34,420
we'll just do it under blueprints go
11060
07:48:35,638 --> 07:48:36,638
ahead create a new blueprint class and
11061
07:48:37,920 --> 07:48:38,920
this will be of type wrapper object
11062
07:48:42,200 --> 07:48:43,200
so we don't find it and we forgot to
11063
07:48:46,020 --> 07:48:47,020
make this blueprint table once again no
11064
07:48:48,360 --> 07:48:49,360
issues we can make this blueprint table
11065
07:48:50,878 --> 07:48:51,878
and you can make it blueprint type as
11066
07:48:52,740 --> 07:48:53,740
well if you wish so we can go ahead and
11067
07:48:54,840 --> 07:48:55,840
restart the editor now
11068
07:48:59,520 --> 07:49:00,520
and now under content blueprints if I
11069
07:49:02,458 --> 07:49:03,458
right click create a blueprint class and
11070
07:49:05,100 --> 07:49:06,100
type in wrapper object we should get a
11071
07:49:07,320 --> 07:49:08,320
wrapper object
11072
07:49:08,580 --> 07:49:09,580
and we can go ahead and just call it BP
11073
07:49:11,878 --> 07:49:12,878
underscore wrapper
11074
07:49:14,520 --> 07:49:15,520
so this is our wrapper class basically
11075
07:49:18,540 --> 07:49:19,540
now if I were to actually go ahead and
11076
07:49:22,798 --> 07:49:23,798
call the function we can actually do
11077
07:49:24,898 --> 07:49:25,898
that so we'll instantiate the object and
11078
07:49:27,058 --> 07:49:28,058
call it so our function was called get
11079
07:49:29,340 --> 07:49:30,340
name
11080
07:49:30,540 --> 07:49:31,540
oops get name
11081
07:49:33,420 --> 07:49:34,420
call function get name Target is wrapper
11082
07:49:35,940 --> 07:49:36,940
object and we get a string so we can go
11083
07:49:38,398 --> 07:49:39,398
ahead and test this method out so in our
11084
07:49:40,740 --> 07:49:41,740
level blueprint we'll just construct an
11085
07:49:42,540 --> 07:49:43,540
object so we can ignore this
11086
07:49:45,180 --> 07:49:46,180
we can go ahead and construct object
11087
07:49:47,878 --> 07:49:48,878
from class
11088
07:49:49,260 --> 07:49:50,260
and we can construct our wrapper object
11089
07:49:53,040 --> 07:49:54,040
so BP wrapper
11090
07:49:54,898 --> 07:49:55,898
we didn't really need it to be honest
11091
07:49:56,820 --> 07:49:57,820
but anyways we can go ahead and call the
11092
07:50:01,020 --> 07:50:02,020
function get name
11093
07:50:02,878 --> 07:50:03,878
once it's successfully constructed
11094
07:50:05,520 --> 07:50:06,520
and we can print strings so that we can
11095
07:50:08,700 --> 07:50:09,700
check if it works
11096
07:50:11,580 --> 07:50:12,580
so now if I go ahead and press play
11097
07:50:15,540 --> 07:50:16,540
as you would see I get this is some test
11098
07:50:18,540 --> 07:50:19,540
string
11099
07:50:19,500 --> 07:50:20,500
and this is exactly what we put in our
11100
07:50:22,320 --> 07:50:23,320
third party Library so if I head into
11101
07:50:24,180 --> 07:50:25,180
third party
11102
07:50:25,458 --> 07:50:26,458
testclass dot CPP
11103
07:50:28,440 --> 07:50:29,440
as you can see we had our STD string and
11104
07:50:31,080 --> 07:50:32,080
we actually called this method through
11105
07:50:33,660 --> 07:50:34,660
our wrapper class
11106
07:50:35,700 --> 07:50:36,700
so this is basically how you implement a
11107
07:50:38,280 --> 07:50:39,280
third-party static Library
11108
07:50:42,040 --> 07:50:43,040
[Music]
11109
07:50:46,920 --> 07:50:47,920
so now let's get to dlls now working
11110
07:50:50,280 --> 07:50:51,280
with dlls is going to be a little more
11111
07:50:53,280 --> 07:50:54,280
tedious and if you were to take my
11112
07:50:56,160 --> 07:50:57,160
opinion in Unreal Engine at least it's
11113
07:50:58,798 --> 07:50:59,798
really not worth the hassle to work with
11114
07:51:01,260 --> 07:51:02,260
dlls I always prefer just working with
11115
07:51:04,138 --> 07:51:05,138
you know static libraries or any unreal
11116
07:51:07,020 --> 07:51:08,020
native plugins but anyways I'll just
11117
07:51:09,540 --> 07:51:10,540
show you guys with the example itself
11118
07:51:11,458 --> 07:51:12,458
the procedure is the same head into
11119
07:51:13,138 --> 07:51:14,138
plugins
11120
07:51:14,398 --> 07:51:15,398
click on ADD third-party library and
11121
07:51:17,820 --> 07:51:18,820
we'll just call this gamium and plugin
11122
07:51:20,700 --> 07:51:21,700
name let's just call it dll test
11123
07:51:24,840 --> 07:51:25,840
so we're going to create the plugin and
11124
07:51:27,840 --> 07:51:28,840
it should take us into Visual Studio
11125
07:51:32,398 --> 07:51:33,398
so we get this message box here
11126
07:51:36,058 --> 07:51:37,058
so which is from uh the functions given
11127
07:51:40,020 --> 07:51:41,020
in the dll so
11128
07:51:42,240 --> 07:51:43,240
just head into your solution Explorer
11129
07:51:45,360 --> 07:51:46,360
add under your plugins
11130
07:51:48,780 --> 07:51:49,780
you should find a dll test plugin
11131
07:51:51,600 --> 07:51:52,600
and if you open up your
11132
07:51:54,058 --> 07:51:55,058
third party folder you should be able to
11133
07:51:56,340 --> 07:51:57,340
see the code
11134
07:51:57,660 --> 07:51:58,660
now we'll just be modifying it in here
11135
07:52:01,500 --> 07:52:02,500
so we'll just call a function
11136
07:52:04,798 --> 07:52:05,798
so example Library function let's just
11137
07:52:06,840 --> 07:52:07,840
head into the definition this is
11138
07:52:08,458 --> 07:52:09,458
creating a message box
11139
07:52:10,200 --> 07:52:11,200
similarly we could just have our own
11140
07:52:11,940 --> 07:52:12,940
function the important bit over here is
11141
07:52:15,540 --> 07:52:16,540
the export part so basically you have
11142
07:52:18,420 --> 07:52:19,420
this macro which is going to export the
11143
07:52:20,398 --> 07:52:21,398
function now
11144
07:52:22,440 --> 07:52:23,440
the usage of classes isn't really
11145
07:52:25,020 --> 07:52:26,020
covered here so I'm just going to do
11146
07:52:27,478 --> 07:52:28,478
that instead of writing my own function
11147
07:52:29,520 --> 07:52:30,520
obviously you can implement the same
11148
07:52:31,500 --> 07:52:32,500
thing with your own dll but remember uh
11149
07:52:34,558 --> 07:52:35,558
the changes to the build.cs files which
11150
07:52:36,780 --> 07:52:37,780
you have to make so under plugins dll
11151
07:52:40,620 --> 07:52:41,620
test
11152
07:52:41,638 --> 07:52:42,638
Source dll test or other third party dll
11153
07:52:45,718 --> 07:52:46,718
test library and in this build.cs file
11154
07:52:49,080 --> 07:52:50,080
again you will probably have to change a
11155
07:52:52,320 --> 07:52:53,320
few parts you can remove this if you are
11156
07:52:54,478 --> 07:52:55,478
working on your windows
11157
07:52:56,540 --> 07:52:57,540
so this is over here just change the
11158
07:53:01,500 --> 07:53:02,500
file name to whatever your dll is
11159
07:53:04,760 --> 07:53:05,760
and over here for the lib file as well
11160
07:53:07,680 --> 07:53:08,680
just make sure you change it to whatever
11161
07:53:09,420 --> 07:53:10,420
your file name is even here as well just
11162
07:53:12,360 --> 07:53:13,360
do those changes and you should be good
11163
07:53:14,218 --> 07:53:15,218
to go and the addition of modules will
11164
07:53:17,580 --> 07:53:18,580
still remain the same so you will still
11165
07:53:19,978 --> 07:53:20,978
have to include choreo object and stuff
11166
07:53:22,378 --> 07:53:23,378
we'll do that so not to worry
11167
07:53:25,920 --> 07:53:26,920
so if you want to actually export a
11168
07:53:28,200 --> 07:53:29,200
class
11169
07:53:29,218 --> 07:53:30,218
you would have to do it right here in
11170
07:53:32,100 --> 07:53:33,100
the dot hatch file you can have the
11171
07:53:33,898 --> 07:53:34,898
definition separately in the CPP file
11172
07:53:36,058 --> 07:53:37,058
but I'll show you guys how to actually
11173
07:53:38,398 --> 07:53:39,398
do it so the way you do it for classes
11174
07:53:41,458 --> 07:53:42,458
is a bit different for functions you can
11175
07:53:43,200 --> 07:53:44,200
follow this example and move on
11176
07:53:46,080 --> 07:53:47,080
but over here let's say I want a class
11177
07:53:48,240 --> 07:53:49,240
so I can do example Library export now I
11178
07:53:52,740 --> 07:53:53,740
am assuming we are developing for
11179
07:53:54,540 --> 07:53:55,540
Windows so I'll just go ahead and delete
11180
07:53:57,240 --> 07:53:58,240
all these alifs
11181
07:53:59,280 --> 07:54:00,280
so I won't be having any of that so I'll
11182
07:54:01,620 --> 07:54:02,620
only have the macro declared even over
11183
07:54:05,458 --> 07:54:06,458
here as well so I I'll just go ahead and
11184
07:54:08,580 --> 07:54:09,580
remove all of this and I'm just assuming
11185
07:54:11,760 --> 07:54:12,760
that everything is
11186
07:54:13,320 --> 07:54:14,320
for Windows
11187
07:54:15,540 --> 07:54:16,540
so with that assumption let's continue
11188
07:54:18,420 --> 07:54:19,420
now if you want a class we can go ahead
11189
07:54:21,360 --> 07:54:22,360
and declare it and one more thing in
11190
07:54:24,298 --> 07:54:25,298
your dot h file as well make sure you
11191
07:54:26,280 --> 07:54:27,280
just have this macro
11192
07:54:27,958 --> 07:54:28,958
if you want to work with class if you're
11193
07:54:29,700 --> 07:54:30,700
working only with functions you don't
11194
07:54:31,620 --> 07:54:32,620
really require
11195
07:54:33,360 --> 07:54:34,360
so now what you want to do is let's just
11196
07:54:35,878 --> 07:54:36,878
call this one test class
11197
07:54:39,298 --> 07:54:40,298
and over here we can go ahead and have
11198
07:54:41,878 --> 07:54:42,878
some methods
11199
07:54:43,378 --> 07:54:44,378
so let's say in
11200
07:54:47,040 --> 07:54:48,040
get num or something and we can have a
11201
07:54:49,920 --> 07:54:50,920
variable as well so under private
11202
07:54:54,120 --> 07:54:55,120
we can have in Num
11203
07:54:58,500 --> 07:54:59,500
and for this we can go ahead and provide
11204
07:55:01,138 --> 07:55:02,138
a definition for it
11205
07:55:02,878 --> 07:55:03,878
and one more thing for each definitions
11206
07:55:07,080 --> 07:55:08,080
so for your class definition here make
11207
07:55:09,120 --> 07:55:10,120
sure you put in export
11208
07:55:11,100 --> 07:55:12,100
for methods you would put in import here
11209
07:55:13,320 --> 07:55:14,320
and export in the definition but since
11210
07:55:15,660 --> 07:55:16,660
your class definition is here itself
11211
07:55:17,458 --> 07:55:18,458
make sure you have example Library
11212
07:55:19,860 --> 07:55:20,860
export
11213
07:55:21,298 --> 07:55:22,298
or whatever your library name is
11214
07:55:23,760 --> 07:55:24,760
and we can just go ahead and return num
11215
07:55:26,878 --> 07:55:27,878
so what we can do is we can write uh
11216
07:55:30,718 --> 07:55:31,718
we can just say we can just set this to
11217
07:55:33,420 --> 07:55:34,420
some value
11218
07:55:34,440 --> 07:55:35,440
what we can do here is we can write a
11219
07:55:37,740 --> 07:55:38,740
Constructor actually
11220
07:55:39,600 --> 07:55:40,600
so this class is called test class
11221
07:55:44,398 --> 07:55:45,398
and we'll just write it in line over
11222
07:55:46,320 --> 07:55:47,320
here what we can do is num equals
11223
07:55:52,020 --> 07:55:53,020
can grab in a random number
11224
07:55:55,500 --> 07:55:56,500
between 0 and 99. so this should work as
11225
07:55:59,580 --> 07:56:00,580
expected and then I'll get num function
11226
07:56:02,100 --> 07:56:03,100
should work as well
11227
07:56:03,840 --> 07:56:04,840
now once you are done with this our
11228
07:56:07,378 --> 07:56:08,378
dlls example Library should work
11229
07:56:10,920 --> 07:56:11,920
so what we can do is we can go ahead and
11230
07:56:13,320 --> 07:56:14,320
before building actually we can create a
11231
07:56:15,058 --> 07:56:16,058
new file
11232
07:56:16,020 --> 07:56:17,020
so head into your editor
11233
07:56:19,260 --> 07:56:20,260
and we can close the solution for now we
11234
07:56:21,898 --> 07:56:22,898
can build it and close it
11235
07:56:25,440 --> 07:56:26,440
so we have live coding enabled just
11236
07:56:27,600 --> 07:56:28,600
ignore that so build it
11237
07:56:32,820 --> 07:56:33,820
so this should build successfully
11238
07:56:36,000 --> 07:56:37,000
now if I just head back into my project
11239
07:56:38,160 --> 07:56:39,160
beginner course
11240
07:56:40,378 --> 07:56:41,378
and if I head into my you project file
11241
07:56:42,540 --> 07:56:43,540
here
11242
07:56:44,840 --> 07:56:45,840
once it loads up you would see the
11243
07:56:47,700 --> 07:56:48,700
message box as is if you don't want that
11244
07:56:49,978 --> 07:56:50,978
I'll just show you guys how to disable
11245
07:56:51,600 --> 07:56:52,600
that if you don't want the message box
11246
07:56:53,638 --> 07:56:54,638
head into your dll test third party
11247
07:56:55,798 --> 07:56:56,798
third party library or whatever or
11248
07:56:58,378 --> 07:56:59,378
rather Source dll test
11249
07:57:01,260 --> 07:57:02,260
private
11250
07:57:02,840 --> 07:57:03,840
dlltest.cpp this is the file where it's
11251
07:57:05,280 --> 07:57:06,280
actually
11252
07:57:06,680 --> 07:57:07,680
given the function definition so just go
11253
07:57:10,620 --> 07:57:11,620
ahead open that and edit the file to
11254
07:57:13,680 --> 07:57:14,680
remove the function definition
11255
07:57:15,478 --> 07:57:16,478
so let it open up
11256
07:57:17,638 --> 07:57:18,638
and over here what you would want to do
11257
07:57:20,040 --> 07:57:21,040
is you would want to remove this
11258
07:57:22,558 --> 07:57:23,558
function definition
11259
07:57:24,540 --> 07:57:25,540
so you can remove this and then the
11260
07:57:26,760 --> 07:57:27,760
message box isn't going to pop up you
11261
07:57:29,218 --> 07:57:30,218
can remove this as well
11262
07:57:30,840 --> 07:57:31,840
but that's not going to be called unless
11263
07:57:33,000 --> 07:57:34,000
it fails so not to worry
11264
07:57:35,040 --> 07:57:36,040
and even this path as well so if you do
11265
07:57:39,478 --> 07:57:40,478
require to change it you will have to
11266
07:57:42,120 --> 07:57:43,120
change it if you are implementing your
11267
07:57:44,160 --> 07:57:45,160
own make sure you account for all of
11268
07:57:46,020 --> 07:57:47,020
this
11269
07:57:47,298 --> 07:57:48,298
so heading back go to tools you see plus
11270
07:57:51,540 --> 07:57:52,540
plus class all classes object will go
11271
07:57:55,020 --> 07:57:56,020
ahead and just or we can do actor just
11272
07:57:57,718 --> 07:57:58,718
to keep things a little more interesting
11273
07:57:59,940 --> 07:58:00,940
so we can go ahead and create an actor
11274
07:58:02,878 --> 07:58:03,878
click on next my actor make it under dll
11275
07:58:07,020 --> 07:58:08,020
test and we can go ahead and create the
11276
07:58:09,360 --> 07:58:10,360
class
11277
07:58:11,218 --> 07:58:12,218
so this should open up our solution file
11278
07:58:15,558 --> 07:58:16,558
and
11279
07:58:17,340 --> 07:58:18,340
don't mind if live coding fails we'll
11280
07:58:19,680 --> 07:58:20,680
just close and reopen that not to worry
11281
07:58:23,520 --> 07:58:24,520
we can go ahead and open the solution
11282
07:58:25,558 --> 07:58:26,558
file once again so we'll go ahead and
11283
07:58:27,840 --> 07:58:28,840
close this
11284
07:58:29,280 --> 07:58:30,280
and once the solution is open we should
11285
07:58:31,740 --> 07:58:32,740
be able to go ahead and find our file
11286
07:58:33,898 --> 07:58:34,898
here so under dll test
11287
07:58:36,478 --> 07:58:37,478
private
11288
07:58:37,820 --> 07:58:38,820
dlltest.cpp or rather myactor.cpp and we
11289
07:58:42,000 --> 07:58:43,000
should find all our function definitions
11290
07:58:43,860 --> 07:58:44,860
and not to worry if you get so many
11291
07:58:46,680 --> 07:58:47,680
errors it's just to do with the build.cs
11292
07:58:49,080 --> 07:58:50,080
file once again it's kind of dumb but
11293
07:58:51,958 --> 07:58:52,958
it's something which you have to deal
11294
07:58:53,580 --> 07:58:54,580
with
11295
07:58:54,478 --> 07:58:55,478
so over here make sure you include
11296
07:58:57,600 --> 07:58:58,600
engine
11297
07:58:59,040 --> 07:59:00,040
and make sure you include core view
11298
07:59:01,920 --> 07:59:02,920
object
11299
07:59:03,000 --> 07:59:04,000
make sure you have these two modules if
11300
07:59:05,280 --> 07:59:06,280
you want to access gizmet and stuff like
11301
07:59:07,320 --> 07:59:08,320
that you will need engine
11302
07:59:08,940 --> 07:59:09,940
if you want to access your your object
11303
07:59:11,218 --> 07:59:12,218
type you'll need core your object so
11304
07:59:14,160 --> 07:59:15,160
if you don't have an idea of what
11305
07:59:16,440 --> 07:59:17,440
contains what you can go ahead and have
11306
07:59:18,298 --> 07:59:19,298
a look at the engine module in the
11307
07:59:20,458 --> 07:59:21,458
documentation everything is given over
11308
07:59:22,558 --> 07:59:23,558
there otherwise you could just follow
11309
07:59:24,360 --> 07:59:25,360
along
11310
07:59:25,620 --> 07:59:26,620
so head into now it will build
11311
07:59:28,040 --> 07:59:29,040
intellisens isn't refreshed yet
11312
07:59:31,440 --> 07:59:32,440
so head into your myactor.h and we can
11313
07:59:34,440 --> 07:59:35,440
go ahead and include a header so you can
11314
07:59:36,360 --> 07:59:37,360
go hash include
11315
07:59:37,920 --> 07:59:38,920
dll underscore test Library
11316
07:59:43,138 --> 07:59:44,138
and our header is called example
11317
07:59:45,840 --> 07:59:46,840
library.h of course if you have your own
11318
07:59:48,058 --> 07:59:49,058
header that's going to replace this
11319
07:59:50,520 --> 07:59:51,520
and we shouldn't get any sort of errors
11320
07:59:53,580 --> 07:59:54,580
here
11321
07:59:54,840 --> 07:59:55,840
and over here we can just write a
11322
07:59:56,820 --> 07:59:57,820
function we'll just do it in line so you
11323
07:59:58,860 --> 07:59:59,860
function make this one blueprint
11324
08:00:01,200 --> 08:00:02,200
callable to make things simple so
11325
08:00:03,600 --> 08:00:04,600
blueprint
11326
08:00:05,940 --> 08:00:06,940
callable and we can call this one
11327
08:00:09,478 --> 08:00:10,478
void
11328
08:00:11,280 --> 08:00:12,280
run dll function
11329
08:00:14,040 --> 08:00:15,040
so I'm not really bothered about the
11330
08:00:15,660 --> 08:00:16,660
name too much
11331
08:00:17,580 --> 08:00:18,580
and now what I can do is I can go ahead
11332
08:00:19,920 --> 08:00:20,920
and write a definition for it we'll just
11333
08:00:21,660 --> 08:00:22,660
do it over here
11334
08:00:23,458 --> 08:00:24,458
so from our dll we can go ahead and grab
11335
08:00:26,458 --> 08:00:27,458
it so the function which we had
11336
08:00:29,580 --> 08:00:30,580
was called
11337
08:00:32,218 --> 08:00:33,218
get num so we can go ahead and
11338
08:00:34,500 --> 08:00:35,500
instantiate an object to that class so
11339
08:00:37,200 --> 08:00:38,200
our class was called test class
11340
08:00:41,040 --> 08:00:42,040
just call it obj
11341
08:00:43,200 --> 08:00:44,200
and we can go ahead and call the
11342
08:00:45,180 --> 08:00:46,180
function
11343
08:00:46,798 --> 08:00:47,798
we'll do it in the next line
11344
08:00:49,260 --> 08:00:50,260
and obj Dot get num we can go ahead and
11345
08:00:53,340 --> 08:00:54,340
print this by typing in you Kismet
11346
08:00:57,478 --> 08:00:58,478
system Library
11347
08:01:00,298 --> 08:01:01,298
print string
11348
08:01:02,280 --> 08:01:03,280
and we can just pass in at this pointer
11349
08:01:04,820 --> 08:01:05,820
and we can do F string
11350
08:01:08,700 --> 08:01:09,700
so it's an integer so from int
11351
08:01:11,878 --> 08:01:12,878
and this should be good to go
11352
08:01:14,340 --> 08:01:15,340
now what we can do is we can include
11353
08:01:16,138 --> 08:01:17,138
Kismet because we don't have the print
11354
08:01:18,058 --> 08:01:19,058
string function here so hash include
11355
08:01:20,638 --> 08:01:21,638
Kismet
11356
08:01:22,978 --> 08:01:23,978
Kismet system Library dot h
11357
08:01:27,600 --> 08:01:28,600
now this should build successfully
11358
08:01:29,280 --> 08:01:30,280
assuming we haven't made any mistakes
11359
08:01:31,558 --> 08:01:32,558
here
11360
08:01:32,820 --> 08:01:33,820
now it's giving us an error it says test
11361
08:01:35,940 --> 08:01:36,940
class class type redefinition a simple
11362
08:01:38,700 --> 08:01:39,700
fix would be just to do pragma once so
11363
08:01:41,820 --> 08:01:42,820
pragma once and this should build now
11364
08:01:45,120 --> 08:01:46,120
with no problems now we can go ahead and
11365
08:01:48,180 --> 08:01:49,180
open up the editor
11366
08:01:51,420 --> 08:01:52,420
so once we open it up
11367
08:01:53,398 --> 08:01:54,398
we won't get the message box now because
11368
08:01:55,620 --> 08:01:56,620
we had disabled that
11369
08:01:57,780 --> 08:01:58,780
and over here if we just head into a
11370
08:02:00,298 --> 08:02:01,298
level blueprint for example and make
11371
08:02:02,160 --> 08:02:03,160
sure under the play mode just change
11372
08:02:03,780 --> 08:02:04,780
this to Standalone because we had it set
11373
08:02:06,240 --> 08:02:07,240
to multiply we can go ahead and
11374
08:02:07,500 --> 08:02:08,500
construct an object from class
11375
08:02:09,780 --> 08:02:10,780
or rather we can do spawn actors and
11376
08:02:11,580 --> 08:02:12,580
sets an actor so my actor
11377
08:02:16,020 --> 08:02:17,020
my actor is what it was called
11378
08:02:18,660 --> 08:02:19,660
and we can just have a default transform
11379
08:02:21,058 --> 08:02:22,058
it doesn't really have anything and from
11380
08:02:23,520 --> 08:02:24,520
this we can go ahead and I'm not sure
11381
08:02:25,558 --> 08:02:26,558
what the function was called
11382
08:02:27,840 --> 08:02:28,840
so let me just have a look
11383
08:02:30,718 --> 08:02:31,718
so our function in my actor was called
11384
08:02:33,360 --> 08:02:34,360
run dll function so I can go ahead and
11385
08:02:36,000 --> 08:02:37,000
call that
11386
08:02:37,020 --> 08:02:38,020
so run
11387
08:02:38,398 --> 08:02:39,398
dll function
11388
08:02:41,218 --> 08:02:42,218
so in theory we should get stuff printed
11389
08:02:44,520 --> 08:02:45,520
over here but this will probably not
11390
08:02:48,180 --> 08:02:49,180
work now because we haven't actually
11391
08:02:49,798 --> 08:02:50,798
compiled our library itself which is
11392
08:02:51,898 --> 08:02:52,898
kind of stupid so heading to dll test
11393
08:02:56,878 --> 08:02:57,878
so third party dll test Library example
11394
08:03:00,898 --> 08:03:01,898
Library dot solution
11395
08:03:03,540 --> 08:03:04,540
and now just click ok
11396
08:03:06,360 --> 08:03:07,360
and now what you would want to do over
11397
08:03:08,218 --> 08:03:09,218
here is go ahead and select a release
11398
08:03:11,700 --> 08:03:12,700
configuration
11399
08:03:13,320 --> 08:03:14,320
and go ahead and build it
11400
08:03:15,660 --> 08:03:16,660
oh and yeah make sure you close the
11401
08:03:18,000 --> 08:03:19,000
editor when doing it that was the error
11402
08:03:20,398 --> 08:03:21,398
which we got right there now if you were
11403
08:03:22,920 --> 08:03:23,920
to go ahead and open up your beginner
11404
08:03:25,378 --> 08:03:26,378
course view project
11405
08:03:27,958 --> 08:03:28,958
once that's loaded in now we should be
11406
08:03:30,718 --> 08:03:31,718
able to call the function and it should
11407
08:03:33,360 --> 08:03:34,360
work as expected so in your level
11408
08:03:36,718 --> 08:03:37,718
blueprint where you called it run dll
11409
08:03:39,240 --> 08:03:40,240
function and we can go ahead and click
11410
08:03:41,820 --> 08:03:42,820
on selected viewport and as you can see
11411
08:03:44,458 --> 08:03:45,458
we got 95 if I go ahead and play we get
11412
08:03:47,820 --> 08:03:48,820
66
11413
08:03:49,200 --> 08:03:50,200
and we keep getting random numbers every
11414
08:03:51,478 --> 08:03:52,478
time so our dll actually worked but
11415
08:03:56,100 --> 08:03:57,100
if you do want to implement your own it
11416
08:03:59,160 --> 08:04:00,160
is going to be a little more complicated
11417
08:04:01,200 --> 08:04:02,200
than this even with just including the
11418
08:04:05,160 --> 08:04:06,160
one which was provided to us with unreal
11419
08:04:07,440 --> 08:04:08,440
it was a big hassle so make sure you
11420
08:04:10,500 --> 08:04:11,500
guys uh avoid using dlls I prefer using
11421
08:04:15,298 --> 08:04:16,298
static libraries or I restrict myself to
11422
08:04:18,540 --> 08:04:19,540
those for unreal at least
11423
08:04:20,520 --> 08:04:21,520
so that's it I guess about third party
11424
08:04:23,280 --> 08:04:24,280
libraries we can go ahead and talk about
11425
08:04:25,440 --> 08:04:26,440
multiplayer now it's going to get fun
11426
08:04:27,298 --> 08:04:28,298
guys
11427
08:04:28,920 --> 08:04:29,920
[Music]
11428
08:04:33,298 --> 08:04:34,298
now let's talk about networking in
11429
08:04:36,180 --> 08:04:37,180
Unreal Engine so networking basically in
11430
08:04:40,558 --> 08:04:41,558
unreal revolves around start topology
11431
08:04:43,500 --> 08:04:44,500
basically your server client model so
11432
08:04:46,740 --> 08:04:47,740
basically you have one player or a
11433
08:04:50,820 --> 08:04:51,820
dedicated machine which acts as a host
11434
08:04:54,180 --> 08:04:55,180
which we call the server and you have
11435
08:04:57,000 --> 08:04:58,000
all the other players which are clients
11436
08:04:59,820 --> 08:05:00,820
now there are two types of servers in
11437
08:05:03,058 --> 08:05:04,058
Unreal Engine one is a lesson server and
11438
08:05:05,458 --> 08:05:06,458
another one is a dedicated server in a
11439
08:05:08,218 --> 08:05:09,218
lesson server the server itself acts as
11440
08:05:10,978 --> 08:05:11,978
a client as well as the server that is
11441
08:05:13,378 --> 08:05:14,378
the host whereas in a dedicated server
11442
08:05:17,280 --> 08:05:18,280
the server only acts as a host and does
11443
08:05:20,398 --> 08:05:21,398
not have a player controller so these
11444
08:05:23,160 --> 08:05:24,160
are the two types of servers and
11445
08:05:25,680 --> 08:05:26,680
basically any data that has to be passed
11446
08:05:27,780 --> 08:05:28,780
through Network as you can see in this
11447
08:05:29,160 --> 08:05:30,160
diagram here there is no connection
11448
08:05:31,200 --> 08:05:32,200
there is no direct connection between
11449
08:05:33,120 --> 08:05:34,120
two clients always if data has to be
11450
08:05:36,360 --> 08:05:37,360
passed from client 1 to client 2 or vice
11451
08:05:39,000 --> 08:05:40,000
versa it has to be routed through the
11452
08:05:41,458 --> 08:05:42,458
server so that is one thing to note when
11453
08:05:44,160 --> 08:05:45,160
it comes to networking in Unreal Engine
11454
08:05:46,920 --> 08:05:47,920
now there are many questions which might
11455
08:05:49,620 --> 08:05:50,620
arise regarding the efficiency of this
11456
08:05:52,080 --> 08:05:53,080
and stuff but most games these days work
11457
08:05:55,200 --> 08:05:56,200
based on this principle and it is in
11458
08:05:58,200 --> 08:05:59,200
fact very robustly implemented and we
11459
08:06:00,660 --> 08:06:01,660
will be talking about all the features
11460
08:06:02,700 --> 08:06:03,700
of unreal networking soon
11461
08:06:06,200 --> 08:06:07,200
[Music]
11462
08:06:10,740 --> 08:06:11,740
I have brought up my main menu level
11463
08:06:12,780 --> 08:06:13,780
here and I just want to demonstrate how
11464
08:06:16,138 --> 08:06:17,138
you are going to join two Standalone
11465
08:06:18,420 --> 08:06:19,420
games that is two games on separate
11466
08:06:20,940 --> 08:06:21,940
computers into one so if you aren't
11467
08:06:24,058 --> 08:06:25,058
familiar net mode will basically let you
11468
08:06:26,638 --> 08:06:27,638
choose between the types of servers
11469
08:06:28,500 --> 08:06:29,500
which I talked about play as client is
11470
08:06:30,780 --> 08:06:31,780
your dedicated server basically and play
11471
08:06:33,240 --> 08:06:34,240
as listen server is going to be a server
11472
08:06:36,298 --> 08:06:37,298
which is also a player along with the
11473
08:06:38,218 --> 08:06:39,218
other clients Place Standalone will
11474
08:06:40,558 --> 08:06:41,558
basically mean two separate games and
11475
08:06:42,298 --> 08:06:43,298
that's what we will be doing
11476
08:06:44,040 --> 08:06:45,040
now what if you wanted to connect
11477
08:06:45,958 --> 08:06:46,958
between these two
11478
08:06:47,638 --> 08:06:48,638
so we'll be using the game instance for
11479
08:06:49,680 --> 08:06:50,680
it so open up your BP game instance now
11480
08:06:52,798 --> 08:06:53,798
I am recording this a little bit later
11481
08:06:54,660 --> 08:06:55,660
so that's the reason you may see a few
11482
08:06:57,298 --> 08:06:58,298
things which you haven't seen so BP rgi
11483
08:07:00,180 --> 08:07:01,180
and we can just set up a couple of
11484
08:07:02,160 --> 08:07:03,160
custom events we'll first of all delete
11485
08:07:04,138 --> 08:07:05,138
all of this we don't need this
11486
08:07:07,320 --> 08:07:08,320
so I'm not sure we may have broken some
11487
08:07:09,898 --> 08:07:10,898
reference
11488
08:07:11,638 --> 08:07:12,638
doesn't matter so
11489
08:07:13,740 --> 08:07:14,740
we'll just go ahead and fix that
11490
08:07:16,080 --> 08:07:17,080
so we'll just delete that
11491
08:07:18,600 --> 08:07:19,600
and now if I head into rgi and I'll
11492
08:07:22,320 --> 08:07:23,320
create a custom event now basically
11493
08:07:24,780 --> 08:07:25,780
connecting to a single game is handled
11494
08:07:27,958 --> 08:07:28,958
by something known as a session
11495
08:07:30,180 --> 08:07:31,180
so every time your players are connected
11496
08:07:32,958 --> 08:07:33,958
unreal actually has something known as a
11497
08:07:36,180 --> 08:07:37,180
session stored internally we aren't
11498
08:07:38,878 --> 08:07:39,878
going to be diving into the C plus plus
11499
08:07:40,620 --> 08:07:41,620
part of this we'll just be doing this in
11500
08:07:42,958 --> 08:07:43,958
Blueprint but please note that if you
11501
08:07:45,120 --> 08:07:46,120
want finer control over these properties
11502
08:07:47,700 --> 08:07:48,700
you would want to work with C plus plus
11503
08:07:50,458 --> 08:07:51,458
so session is basically what is going to
11504
08:07:53,280 --> 08:07:54,280
allow your players to connect
11505
08:07:55,080 --> 08:07:56,080
so let's go ahead and create a session
11506
08:07:57,298 --> 08:07:58,298
so what we can do is we can do something
11507
08:08:00,000 --> 08:08:01,000
like create
11508
08:08:02,280 --> 08:08:03,280
Lobby would be inappropriate I'll just
11509
08:08:04,680 --> 08:08:05,680
call this one create session
11510
08:08:07,320 --> 08:08:08,320
and we'll go ahead and type in create
11511
08:08:09,240 --> 08:08:10,240
session
11512
08:08:11,280 --> 08:08:12,280
and as you see there is an async task
11513
08:08:13,500 --> 08:08:14,500
over here
11514
08:08:14,700 --> 08:08:15,700
and if you guys aren't familiar with
11515
08:08:16,680 --> 08:08:17,680
this clock symbol and a node like this
11516
08:08:18,718 --> 08:08:19,718
this is an async task and public
11517
08:08:21,298 --> 08:08:22,298
connections we'll just set that to two
11518
08:08:22,978 --> 08:08:23,978
for example so to players and player
11519
08:08:26,160 --> 08:08:27,160
controller this is for lesson servers if
11520
08:08:28,920 --> 08:08:29,920
you have a dedicated server you don't
11521
08:08:30,540 --> 08:08:31,540
have to pass in the player controller
11522
08:08:32,160 --> 08:08:33,160
but in our case we are passing it in so
11523
08:08:35,040 --> 08:08:36,040
we are going to use the function get
11524
08:08:37,320 --> 08:08:38,320
player controller
11525
08:08:38,878 --> 08:08:39,878
and then use Lan is set to false you
11526
08:08:42,478 --> 08:08:43,478
could do it if you wish and upon success
11527
08:08:45,600 --> 08:08:46,600
what you can do is you can go ahead and
11528
08:08:48,240 --> 08:08:49,240
load a level so open level
11529
08:08:51,840 --> 08:08:52,840
and we can go ahead and open our
11530
08:08:54,260 --> 08:08:55,260
beginner course level
11531
08:08:57,058 --> 08:08:58,058
all right
11532
08:08:58,320 --> 08:08:59,320
and then what we can do is we can go
11533
08:09:00,958 --> 08:09:01,958
ahead and create a function
11534
08:09:02,820 --> 08:09:03,820
to join
11535
08:09:04,440 --> 08:09:05,440
join session
11536
08:09:07,200 --> 08:09:08,200
all right I would call this one create
11537
08:09:09,000 --> 08:09:10,000
match
11538
08:09:10,138 --> 08:09:11,138
so that it sounds a little more familiar
11539
08:09:12,378 --> 08:09:13,378
join match
11540
08:09:16,860 --> 08:09:17,860
so what we can do is we can first of all
11541
08:09:19,200 --> 08:09:20,200
find sessions
11542
08:09:20,878 --> 08:09:21,878
so type in find sessions
11543
08:09:23,580 --> 08:09:24,580
these are the only few functions which
11544
08:09:25,620 --> 08:09:26,620
are there in this Library so that's the
11545
08:09:27,298 --> 08:09:28,298
reason I'm not really going over them
11546
08:09:28,680 --> 08:09:29,680
that much so we can get the player
11547
08:09:31,020 --> 08:09:32,020
controller and what we can do is Max
11548
08:09:33,718 --> 08:09:34,718
results you can just set it to something
11549
08:09:35,340 --> 08:09:36,340
like 100
11550
08:09:37,040 --> 08:09:38,040
and we're going to check if it's a
11551
08:09:41,340 --> 08:09:42,340
failure or if it's a success so what we
11552
08:09:44,458 --> 08:09:45,458
can do is first of all we can get the
11553
08:09:46,080 --> 08:09:47,080
length
11554
08:09:48,360 --> 08:09:49,360
so if it's a failure we're just going to
11555
08:09:50,580 --> 08:09:51,580
print something
11556
08:09:53,218 --> 08:09:54,218
so we could say
11557
08:09:56,100 --> 08:09:57,100
failed
11558
08:09:59,218 --> 08:10:00,218
to join a match
11559
08:10:03,000 --> 08:10:04,000
and what we can do is we can get the
11560
08:10:04,920 --> 08:10:05,920
length
11561
08:10:06,180 --> 08:10:07,180
and if it is greater than zero
11562
08:10:10,020 --> 08:10:11,020
we'll go ahead and just join the first
11563
08:10:11,820 --> 08:10:12,820
session obviously you can have your own
11564
08:10:13,798 --> 08:10:14,798
logic here
11565
08:10:16,378 --> 08:10:17,378
so each session is going to be one
11566
08:10:18,898 --> 08:10:19,898
hosted game basically so let's say there
11567
08:10:21,958 --> 08:10:22,958
are three uh three members in this array
11568
08:10:25,200 --> 08:10:26,200
or three elements in this array what it
11569
08:10:28,138 --> 08:10:29,138
basically means is there are three
11570
08:10:30,180 --> 08:10:31,180
people hosting a match right now that's
11571
08:10:31,978 --> 08:10:32,978
what it means
11572
08:10:34,020 --> 08:10:35,020
so now what I can do is I can grab the
11573
08:10:36,840 --> 08:10:37,840
results
11574
08:10:38,160 --> 08:10:39,160
and I can get a copy of the first one
11575
08:10:42,478 --> 08:10:43,478
if the length is greater than 0 and I
11576
08:10:44,760 --> 08:10:45,760
can go ahead and type in join session
11577
08:10:48,360 --> 08:10:49,360
all right and here we'll again need to
11578
08:10:51,000 --> 08:10:52,000
pass in the player controller and note
11579
08:10:53,398 --> 08:10:54,398
whoops
11580
08:10:55,080 --> 08:10:56,080
and note that you can only run these
11581
08:10:58,260 --> 08:10:59,260
session functions either on the player
11582
08:11:00,540 --> 08:11:01,540
controller or in the game instance you
11583
08:11:03,000 --> 08:11:04,000
cannot run them on other blueprints it
11584
08:11:05,100 --> 08:11:06,100
is simply going to fail
11585
08:11:07,200 --> 08:11:08,200
now once that's done
11586
08:11:09,478 --> 08:11:10,478
let's say we have no sessions we can go
11587
08:11:13,440 --> 08:11:14,440
ahead and create a match so create match
11588
08:11:19,020 --> 08:11:20,020
and on success we don't need to do
11589
08:11:21,540 --> 08:11:22,540
anything engine will handle it for us
11590
08:11:23,520 --> 08:11:24,520
over here you can have something like a
11591
08:11:25,920 --> 08:11:26,920
progress bar or something until on
11592
08:11:28,138 --> 08:11:29,138
success is called you could probably
11593
08:11:29,638 --> 08:11:30,638
have some throbber or something like
11594
08:11:31,260 --> 08:11:32,260
that to show that it's loading same over
11595
08:11:33,780 --> 08:11:34,780
here
11596
08:11:35,100 --> 08:11:36,100
so this should be good
11597
08:11:37,398 --> 08:11:38,398
and something very simple which you
11598
08:11:39,898 --> 08:11:40,898
could do is inside the main menu
11599
08:11:43,440 --> 08:11:44,440
so on clicked
11600
08:11:45,360 --> 08:11:46,360
what I can do is instead of opening it I
11601
08:11:47,878 --> 08:11:48,878
can grab a reference to my game instance
11602
08:11:49,680 --> 08:11:50,680
so I can type in get game instance which
11603
08:11:52,378 --> 08:11:53,378
is a static function and I can cast it
11604
08:11:54,600 --> 08:11:55,600
to BP rgi this will always succeed I'll
11605
08:11:58,260 --> 08:11:59,260
just cast it over here I'm not going to
11606
08:12:00,240 --> 08:12:01,240
bother storing a reference to it as of
11607
08:12:02,580 --> 08:12:03,580
now
11608
08:12:03,298 --> 08:12:04,298
and I can go ahead and or actually I'll
11609
08:12:06,000 --> 08:12:07,000
just do it the right way so I'll just
11610
08:12:08,100 --> 08:12:09,100
call this one main GI you could call it
11611
08:12:10,138 --> 08:12:11,138
anything
11612
08:12:11,100 --> 08:12:12,100
just a reference to our game instance
11613
08:12:14,760 --> 08:12:15,760
and once we have that we can go ahead
11614
08:12:17,340 --> 08:12:18,340
and use it and we can go ahead and join
11615
08:12:19,680 --> 08:12:20,680
match so join match
11616
08:12:23,520 --> 08:12:24,520
now that that's done if I go ahead and
11617
08:12:25,620 --> 08:12:26,620
press play if I go ahead and press play
11618
08:12:27,718 --> 08:12:28,718
here
11619
08:12:30,718 --> 08:12:31,718
as you can see nothing is really
11620
08:12:32,820 --> 08:12:33,820
happening but after a while we go ahead
11621
08:12:36,420 --> 08:12:37,420
and join the session basically we load
11622
08:12:38,760 --> 08:12:39,760
up the map
11623
08:12:39,840 --> 08:12:40,840
now now that we have actually created a
11624
08:12:42,898 --> 08:12:43,898
session and if I press play on the other
11625
08:12:44,760 --> 08:12:45,760
game here and if I just wait for a while
11626
08:12:48,420 --> 08:12:49,420
so you would want to disable the input
11627
08:12:50,520 --> 08:12:51,520
during this time but anyways for now
11628
08:12:52,920 --> 08:12:53,920
we'll just not do anything you would see
11629
08:12:55,378 --> 08:12:56,378
that you actually don't join the session
11630
08:12:57,440 --> 08:12:58,440
the reason is you actually need to be
11631
08:13:00,718 --> 08:13:01,718
listening for incoming Connections in
11632
08:13:03,420 --> 08:13:04,420
order to actually be able to join the
11633
08:13:06,780 --> 08:13:07,780
game and I'll show you guys how to do
11634
08:13:08,580 --> 08:13:09,580
that
11635
08:13:09,780 --> 08:13:10,780
over here where you have open level make
11636
08:13:12,718 --> 08:13:13,718
sure you just put in listen under the
11637
08:13:14,878 --> 08:13:15,878
options
11638
08:13:15,898 --> 08:13:16,898
so make sure you do that before you
11639
08:13:17,940 --> 08:13:18,940
actually do it and one more thing plane
11640
08:13:20,280 --> 08:13:21,280
editor is crashing my game for some
11641
08:13:22,558 --> 08:13:23,558
reason so I'm just going to go ahead and
11642
08:13:25,138 --> 08:13:26,138
I'm going to run this Standalone so
11643
08:13:29,958 --> 08:13:30,958
Standalone game and Standalone so play
11644
08:13:32,820 --> 08:13:33,820
Standalone and replace this as a
11645
08:13:35,040 --> 08:13:36,040
standalone game so I'm not really sure
11646
08:13:37,378 --> 08:13:38,378
why the issue is happening but this is
11647
08:13:40,440 --> 08:13:41,440
one way I can test it so if I press play
11648
08:13:43,200 --> 08:13:44,200
on one of them and if I go ahead and
11649
08:13:45,958 --> 08:13:46,958
wait
11650
08:13:47,040 --> 08:13:48,040
so we should land inside a session
11651
08:13:49,620 --> 08:13:50,620
as expected we are in the level and we
11652
08:13:52,020 --> 08:13:53,020
are able to do stuff
11653
08:13:53,458 --> 08:13:54,458
now I'll just go ahead and click on play
11654
08:13:55,740 --> 08:13:56,740
here
11655
08:13:57,000 --> 08:13:58,000
in theory if everything is set we should
11656
08:13:59,940 --> 08:14:00,940
in theory land in the same map so
11657
08:14:03,420 --> 08:14:04,420
as you can see post login was called on
11658
08:14:05,700 --> 08:14:06,700
the server and if I were to notice my
11659
08:14:09,000 --> 08:14:10,000
client has successfully connected over
11660
08:14:11,160 --> 08:14:12,160
here
11661
08:14:12,478 --> 08:14:13,478
so as you can see I'm able to play the
11662
08:14:15,000 --> 08:14:16,000
game like this
11663
08:14:16,320 --> 08:14:17,320
so this is basically how you connect two
11664
08:14:18,478 --> 08:14:19,478
clients now let's actually talk about
11665
08:14:20,398 --> 08:14:21,398
how to set up stuff in multiplayer guys
11666
08:14:24,390 --> 08:14:25,390
[Music]
11667
08:14:29,160 --> 08:14:30,160
okay then so if we want to work with
11668
08:14:31,920 --> 08:14:32,920
multiplayer what we can go ahead and do
11669
08:14:34,740 --> 08:14:35,740
is we'll start with a new level because
11670
08:14:36,660 --> 08:14:37,660
if I go ahead and press play with two
11671
08:14:38,638 --> 08:14:39,638
players here
11672
08:14:39,958 --> 08:14:40,958
and
11673
08:14:41,218 --> 08:14:42,218
if I actually close the game you see
11674
08:14:43,500 --> 08:14:44,500
we'll get a few runtime errors now this
11675
08:14:46,260 --> 08:14:47,260
is mostly because our code isn't really
11676
08:14:48,660 --> 08:14:49,660
set up for multiplayer and you will soon
11677
08:14:50,760 --> 08:14:51,760
understand why
11678
08:14:52,798 --> 08:14:53,798
so basically now what I want you guys to
11679
08:14:55,558 --> 08:14:56,558
do is head into your Maps folder create
11680
08:14:57,540 --> 08:14:58,540
a new level and we'll call this one
11681
08:15:00,080 --> 08:15:01,080
multiplayer testing
11682
08:15:05,520 --> 08:15:06,520
so go ahead and open it up
11683
08:15:08,398 --> 08:15:09,398
so this should be a blank level
11684
08:15:10,558 --> 08:15:11,558
so I'll just grab in a sky
11685
08:15:14,420 --> 08:15:15,420
and grab in a directional light here
11686
08:15:18,180 --> 08:15:19,180
and we should have everything set up
11687
08:15:21,898 --> 08:15:22,898
and maybe if you want we could have fog
11688
08:15:26,520 --> 08:15:27,520
and we can just create a simple
11689
08:15:28,680 --> 08:15:29,680
landscape
11690
08:15:29,878 --> 08:15:30,878
so head into your mode selection
11691
08:15:34,020 --> 08:15:35,020
landscape
11692
08:15:35,700 --> 08:15:36,700
and we can go ahead and create it
11693
08:15:41,040 --> 08:15:42,040
so I'll just do a little bit of noise so
11694
08:15:44,280 --> 08:15:45,280
that we have a starting point so that we
11695
08:15:46,860 --> 08:15:47,860
have some sort of
11696
08:15:48,718 --> 08:15:49,718
a workable landscape
11697
08:15:51,780 --> 08:15:52,780
so increase the brush size
11698
08:15:54,780 --> 08:15:55,780
so the strength is a little too much
11699
08:15:56,718 --> 08:15:57,718
point of I should be fine
11700
08:16:01,378 --> 08:16:02,378
so let me just go back
11701
08:16:10,620 --> 08:16:11,620
okay that should be good for us
11702
08:16:13,200 --> 08:16:14,200
now what we can do is we can go ahead
11703
08:16:15,600 --> 08:16:16,600
and talk about multiplayer
11704
08:16:17,580 --> 08:16:18,580
so the main aspects of multiplayer in
11705
08:16:21,540 --> 08:16:22,540
unreal are replication and remote
11706
08:16:24,958 --> 08:16:25,958
procedural calls
11707
08:16:27,000 --> 08:16:28,000
if you are clear with how to use these
11708
08:16:29,520 --> 08:16:30,520
two concepts
11709
08:16:30,718 --> 08:16:31,718
it's pretty simple to code a multiplayer
11710
08:16:33,780 --> 08:16:34,780
game in Unreal Engine it's much more
11711
08:16:37,080 --> 08:16:38,080
difficult to do it with general
11712
08:16:39,298 --> 08:16:40,298
knowledge of networking but with
11713
08:16:42,000 --> 08:16:43,000
unreal's framework it's really very
11714
08:16:44,458 --> 08:16:45,458
simple to set up multiplayer
11715
08:16:46,978 --> 08:16:47,978
we'll discuss both blueprint and C plus
11716
08:16:49,378 --> 08:16:50,378
plus aspects but first the basics
11717
08:16:52,620 --> 08:16:53,620
now I want you guys to head into
11718
08:16:54,958 --> 08:16:55,958
blueprints
11719
08:16:56,878 --> 08:16:57,878
and under here I want you guys to just
11720
08:17:00,558 --> 08:17:01,558
select your character and your BPA so I
11721
08:17:05,398 --> 08:17:06,398
guess this one is where we had physics
11722
08:17:07,680 --> 08:17:08,680
enabled so if we do yep we have physics
11723
08:17:10,500 --> 08:17:11,500
enabled so I want you guys to just show
11724
08:17:13,500 --> 08:17:14,500
the problem with this running
11725
08:17:15,420 --> 08:17:16,420
multiplayer in general so I'll just go
11726
08:17:18,000 --> 08:17:19,000
ahead and drag this in
11727
08:17:19,940 --> 08:17:20,940
and
11728
08:17:21,718 --> 08:17:22,718
what I can do now
11729
08:17:23,638 --> 08:17:24,638
is
11730
08:17:24,958 --> 08:17:25,958
I can go ahead and grab a few player
11731
08:17:27,120 --> 08:17:28,120
starts here so I'll grab one here grab
11732
08:17:29,638 --> 08:17:30,638
another here
11733
08:17:30,780 --> 08:17:31,780
and make sure they're all facing the
11734
08:17:33,478 --> 08:17:34,478
same direction
11735
08:17:34,798 --> 08:17:35,798
so what I can do is I can make this one
11736
08:17:36,840 --> 08:17:37,840
90.
11737
08:17:38,458 --> 08:17:39,458
so they're all facing towards this ball
11738
08:17:40,620 --> 08:17:41,620
right there
11739
08:17:42,298 --> 08:17:43,298
and now what I'm gonna do is I'm going
11740
08:17:45,840 --> 08:17:46,840
to change the world settings to use our
11741
08:17:48,420 --> 08:17:49,420
BP game mode
11742
08:17:50,040 --> 08:17:51,040
and for the player controller we can
11743
08:17:52,080 --> 08:17:53,080
ignore that we'll still get the runtime
11744
08:17:53,820 --> 08:17:54,820
errors
11745
08:17:55,378 --> 08:17:56,378
so what we can do is we can remove this
11746
08:17:58,020 --> 08:17:59,020
logic so we'll forget about the HUD for
11747
08:18:00,780 --> 08:18:01,780
now and if I go ahead and press play
11748
08:18:03,840 --> 08:18:04,840
now you see the ball has fallen down and
11749
08:18:07,740 --> 08:18:08,740
it's rolling down the hill over there
11750
08:18:10,978 --> 08:18:11,978
and as you can see I kicked the ball
11751
08:18:13,860 --> 08:18:14,860
but if you were to notice
11752
08:18:16,680 --> 08:18:17,680
the ball is in a completely different
11753
08:18:18,360 --> 08:18:19,360
position
11754
08:18:20,520 --> 08:18:21,520
so the ball is over there for me
11755
08:18:23,218 --> 08:18:24,218
and if I actually head near the ball
11756
08:18:25,260 --> 08:18:26,260
here
11757
08:18:27,240 --> 08:18:28,240
you'll see that I am not actually going
11758
08:18:29,638 --> 08:18:30,638
near the ball on my other screen so if I
11759
08:18:32,638 --> 08:18:33,638
actually turn around
11760
08:18:34,500 --> 08:18:35,500
my character is somewhere there and my
11761
08:18:37,440 --> 08:18:38,440
ball is somewhere over there
11762
08:18:40,260 --> 08:18:41,260
so as you can see both of these are not
11763
08:18:42,898 --> 08:18:43,898
in sync now this is something related to
11764
08:18:44,820 --> 08:18:45,820
the widget nothing much to worry about
11765
08:18:47,160 --> 08:18:48,160
so basically what I'm trying to say is
11766
08:18:49,740 --> 08:18:50,740
that these two games which are running
11767
08:18:53,040 --> 08:18:54,040
on separate windows are not in sync
11768
08:18:56,218 --> 08:18:57,218
but you notice one thing that your
11769
08:18:58,620 --> 08:18:59,620
characters are in sync so for example if
11770
08:19:01,378 --> 08:19:02,378
I go ahead and run forward
11771
08:19:05,340 --> 08:19:06,340
and if I go ahead and run forward over
11772
08:19:09,478 --> 08:19:10,478
there and if I actually look up you
11773
08:19:12,298 --> 08:19:13,298
would see that my characters are in sync
11774
08:19:14,340 --> 08:19:15,340
it's just that the physics object over
11775
08:19:17,458 --> 08:19:18,458
there is not in sync
11776
08:19:19,680 --> 08:19:20,680
so the reason this is happening is
11777
08:19:22,978 --> 08:19:23,978
because in our character if you head
11778
08:19:24,898 --> 08:19:25,898
into your class defaults and head into
11779
08:19:26,520 --> 08:19:27,520
the replication tab you see that these
11780
08:19:29,398 --> 08:19:30,398
two flags called replicate movement and
11781
08:19:32,280 --> 08:19:33,280
replicates are enabled
11782
08:19:34,620 --> 08:19:35,620
basically this is unreal's way of
11783
08:19:38,160 --> 08:19:39,160
telling us that or rather asking us
11784
08:19:42,240 --> 08:19:43,240
whether we want this particular class to
11785
08:19:46,260 --> 08:19:47,260
be in sync with all players when
11786
08:19:48,240 --> 08:19:49,240
instantiated so let's say we instantiate
11787
08:19:51,058 --> 08:19:52,058
a BP character it will always be in sync
11788
08:19:54,120 --> 08:19:55,120
obviously there are conditions you have
11789
08:19:56,100 --> 08:19:57,100
to instantiate it on the server we'll
11790
08:19:58,378 --> 08:19:59,378
talk about servers and clients soon
11791
08:20:01,260 --> 08:20:02,260
so let's head into our actor and try to
11792
08:20:03,420 --> 08:20:04,420
fix it so head into your class defaults
11793
08:20:06,540 --> 08:20:07,540
and let's try enabling replicate
11794
08:20:08,958 --> 08:20:09,958
movement and replicates if I compile and
11795
08:20:13,440 --> 08:20:14,440
if I go ahead and press play
11796
08:20:17,160 --> 08:20:18,160
as you can see now the ball is rolling
11797
08:20:20,218 --> 08:20:21,218
down it's near me and as you can see
11798
08:20:23,100 --> 08:20:24,100
this seems to be in sync
11799
08:20:26,040 --> 08:20:27,040
if I go ahead and block this
11800
08:20:28,378 --> 08:20:29,378
as you can see this is almost completely
11801
08:20:31,378 --> 08:20:32,378
in sync
11802
08:20:32,820 --> 08:20:33,820
now uh one of my characters flying is
11803
08:20:36,240 --> 08:20:37,240
due to the movement mode just ignore
11804
08:20:38,160 --> 08:20:39,160
that but
11805
08:20:40,260 --> 08:20:41,260
as far as I can see everything is in
11806
08:20:43,020 --> 08:20:44,020
sync
11807
08:20:44,218 --> 08:20:45,218
so this is basically how you get stuff
11808
08:20:47,820 --> 08:20:48,820
to go in sync in a network game in
11809
08:20:50,398 --> 08:20:51,398
unreal this is the most basic aspect of
11810
08:20:53,040 --> 08:20:54,040
it
11811
08:20:53,878 --> 08:20:54,878
you might see that there are a few more
11812
08:20:55,860 --> 08:20:56,860
Flags here such as always relevant call
11813
08:20:59,040 --> 08:21:00,040
pre-replication Net load on client most
11814
08:21:02,458 --> 08:21:03,458
of these aren't really important we'll
11815
08:21:04,200 --> 08:21:05,200
just talk a little bit about net curve
11816
08:21:06,420 --> 08:21:07,420
distance squared and net dormancy and
11817
08:21:08,700 --> 08:21:09,700
stuff but most of the times 9 out of 10
11818
08:21:11,398 --> 08:21:12,398
times you'll only mess with replicates
11819
08:21:13,740 --> 08:21:14,740
and replicate movement sometimes you may
11820
08:21:16,860 --> 08:21:17,860
need your actor to be always relevant
11821
08:21:18,600 --> 08:21:19,600
let's say it's something important to
11822
08:21:20,100 --> 08:21:21,100
your gameplay you will have always
11823
08:21:21,540 --> 08:21:22,540
relevant enabled
11824
08:21:23,820 --> 08:21:24,820
so once that said let's also talk about
11825
08:21:26,580 --> 08:21:27,580
net priority basically the higher the
11826
08:21:28,680 --> 08:21:29,680
value the more priority is given for
11827
08:21:31,378 --> 08:21:32,378
this to be updated so let's say you have
11828
08:21:33,660 --> 08:21:34,660
thousands of actors and your bandwidth
11829
08:21:36,898 --> 08:21:37,898
is insufficient to actually update all
11830
08:21:39,298 --> 08:21:40,298
the actors the ones with higher
11831
08:21:41,638 --> 08:21:42,638
priorities will be updated first
11832
08:21:43,440 --> 08:21:44,440
basically
11833
08:21:45,180 --> 08:21:46,180
so now that we know the basics of
11834
08:21:47,160 --> 08:21:48,160
replication
11835
08:21:48,500 --> 08:21:49,500
[Music]
11836
08:21:53,160 --> 08:21:54,160
let's start syncing up some variables
11837
08:21:56,040 --> 08:21:57,040
so if I head into my actor
11838
08:21:59,180 --> 08:22:00,180
and if I go ahead and create a variable
11839
08:22:02,520 --> 08:22:03,520
so we have some float already
11840
08:22:05,100 --> 08:22:06,100
and what we'll do is on begin play
11841
08:22:08,520 --> 08:22:09,520
we'll go ahead and set this to some
11842
08:22:10,440 --> 08:22:11,440
random value
11843
08:22:11,878 --> 08:22:12,878
so we'll get random So Random float
11844
08:22:15,780 --> 08:22:16,780
and what we can also do is we can go
11845
08:22:18,420 --> 08:22:19,420
ahead and print this string
11846
08:22:21,298 --> 08:22:22,298
all right
11847
08:22:23,360 --> 08:22:24,360
so let's look at what happens
11848
08:22:28,798 --> 08:22:29,798
so let's actually delete some of our
11849
08:22:31,558 --> 08:22:32,558
other methods here so I guess we had
11850
08:22:33,958 --> 08:22:34,958
some stuff in our character
11851
08:22:36,540 --> 08:22:37,540
so we'll just stop calling this function
11852
08:22:39,958 --> 08:22:40,958
and we'll ignore the spawn actor
11853
08:22:43,020 --> 08:22:44,020
and I'm not sure if anything else is
11854
08:22:45,000 --> 08:22:46,000
printing something so we'll ignore the
11855
08:22:46,860 --> 08:22:47,860
left Mouse Button as well now if I press
11856
08:22:49,440 --> 08:22:50,440
play
11857
08:22:50,458 --> 08:22:51,458
as you can see we only get our post
11858
08:22:52,558 --> 08:22:53,558
login and we have 0.809
11859
08:22:55,740 --> 08:22:56,740
and we have 0.43
11860
08:22:58,500 --> 08:22:59,500
now clearly this is not what you want
11861
08:23:01,200 --> 08:23:02,200
you want them to be in sync
11862
08:23:03,360 --> 08:23:04,360
so if you want variables to be in sync
11863
08:23:06,058 --> 08:23:07,058
the first thing you'd want to do is you
11864
08:23:08,638 --> 08:23:09,638
would want to set this replication tab
11865
08:23:10,860 --> 08:23:11,860
to replicate it
11866
08:23:12,718 --> 08:23:13,718
now let's go ahead and try that actually
11867
08:23:15,780 --> 08:23:16,780
so if I press play
11868
08:23:18,180 --> 08:23:19,180
we still get different values
11869
08:23:21,420 --> 08:23:22,420
the reason is
11870
08:23:24,180 --> 08:23:25,180
even though we set the value we need to
11871
08:23:27,420 --> 08:23:28,420
set it on the server and we also need to
11872
08:23:30,240 --> 08:23:31,240
wait for the replication cycle to take
11873
08:23:33,120 --> 08:23:34,120
place
11874
08:23:34,020 --> 08:23:35,020
basically your value doesn't immediately
11875
08:23:37,200 --> 08:23:38,200
get replicated instead your value gets
11876
08:23:40,680 --> 08:23:41,680
replicated in the next replication cycle
11877
08:23:43,620 --> 08:23:44,620
so every once in a while so in our case
11878
08:23:46,320 --> 08:23:47,320
if you head into class defaults you see
11879
08:23:48,420 --> 08:23:49,420
this net update frequency parameter it's
11880
08:23:51,120 --> 08:23:52,120
set to 100. let's say we set it to
11881
08:23:53,638 --> 08:23:54,638
something like 10
11882
08:23:55,500 --> 08:23:56,500
now this variable will be updated after
11883
08:23:59,280 --> 08:24:00,280
approximately 0.1 seconds obviously it
11884
08:24:02,218 --> 08:24:03,218
can be less than that but up to 0.1
11885
08:24:04,260 --> 08:24:05,260
seconds if I make it 100 it's going to
11886
08:24:06,540 --> 08:24:07,540
be up to 0.01 seconds so it's not
11887
08:24:08,638 --> 08:24:09,638
instantaneous
11888
08:24:10,020 --> 08:24:11,020
remember that these two players what we
11889
08:24:12,718 --> 08:24:13,718
play here
11890
08:24:14,218 --> 08:24:15,218
they are not running on the same machine
11891
08:24:16,920 --> 08:24:17,920
so you cannot expect
11892
08:24:19,378 --> 08:24:20,378
the variable to update immediately
11893
08:24:22,378 --> 08:24:23,378
so what we can do is we can actually set
11894
08:24:25,200 --> 08:24:26,200
some logic to update this
11895
08:24:27,240 --> 08:24:28,240
the principle which actually goes into
11896
08:24:30,000 --> 08:24:31,000
this is the fact that all your
11897
08:24:32,040 --> 08:24:33,040
replicated variables need to be set on
11898
08:24:34,320 --> 08:24:35,320
the server so let's go ahead and do that
11899
08:24:36,958 --> 08:24:37,958
now just a quick note here the event
11900
08:24:39,780 --> 08:24:40,780
begin play which is there
11901
08:24:41,760 --> 08:24:42,760
since this actor is replicated each time
11902
08:24:45,600 --> 08:24:46,600
one computer out of all the players
11903
08:24:49,200 --> 08:24:50,200
will spawn the actor so for each
11904
08:24:52,138 --> 08:24:53,138
computer this begin play will be called
11905
08:24:54,000 --> 08:24:55,000
so if you didn't get what I mean if I
11906
08:24:56,520 --> 08:24:57,520
actually simply go ahead and print a
11907
08:24:58,320 --> 08:24:59,320
string so if I go ahead and type in
11908
08:25:00,120 --> 08:25:01,120
print
11909
08:25:01,138 --> 08:25:02,138
and if I print hello and if I press play
11910
08:25:03,660 --> 08:25:04,660
you would notice that the server and the
11911
08:25:06,718 --> 08:25:07,718
client print hello
11912
08:25:08,100 --> 08:25:09,100
what that basically means is as soon as
11913
08:25:10,320 --> 08:25:11,320
the client logged in that is when the
11914
08:25:12,718 --> 08:25:13,718
client entered the game this actor was
11915
08:25:14,940 --> 08:25:15,940
born on the client and begin play was
11916
08:25:17,520 --> 08:25:18,520
called both on the server as well as the
11917
08:25:19,860 --> 08:25:20,860
client
11918
08:25:21,478 --> 08:25:22,478
so what we can do is we can check if we
11919
08:25:23,638 --> 08:25:24,638
are on the server so we can type in a
11920
08:25:25,558 --> 08:25:26,558
server
11921
08:25:27,058 --> 08:25:28,058
and we can do a simple if check
11922
08:25:29,820 --> 08:25:30,820
if we are the server we can go ahead and
11923
08:25:33,600 --> 08:25:34,600
set this value
11924
08:25:34,978 --> 08:25:35,978
so we can go ahead and do that and if we
11925
08:25:38,218 --> 08:25:39,218
are not the server we can go ahead and
11926
08:25:40,558 --> 08:25:41,558
print it
11927
08:25:41,760 --> 08:25:42,760
so one more thing we can do is okay this
11928
08:25:45,180 --> 08:25:46,180
is going to work let's just do it so we
11929
08:25:48,120 --> 08:25:49,120
can go ahead and print some float
11930
08:25:52,080 --> 08:25:53,080
and go ahead and press play
11931
08:25:55,740 --> 08:25:56,740
as you can see the values are the same
11932
08:25:57,780 --> 08:25:58,780
in case you guys have any doubts
11933
08:25:59,638 --> 08:26:00,638
regarding that you can go ahead and plug
11934
08:26:02,638 --> 08:26:03,638
this in directly
11935
08:26:04,260 --> 08:26:05,260
like this
11936
08:26:05,878 --> 08:26:06,878
if I press play Let's see 0.718 0.718
11937
08:26:10,680 --> 08:26:11,680
the value is the same so basically all
11938
08:26:13,740 --> 08:26:14,740
your replicated variables need to be set
11939
08:26:15,660 --> 08:26:16,660
on the server that's the first thing now
11940
08:26:18,298 --> 08:26:19,298
what if you wanted a client to set the
11941
08:26:20,700 --> 08:26:21,700
value so your client cannot actually set
11942
08:26:23,638 --> 08:26:24,638
the value however oh and just another
11943
08:26:26,760 --> 08:26:27,760
thing this logic is going to work for
11944
08:26:28,920 --> 08:26:29,920
three players as well so if I go ahead
11945
08:26:30,600 --> 08:26:31,600
and do this for three players
11946
08:26:32,700 --> 08:26:33,700
so as you can see all three players have
11947
08:26:34,680 --> 08:26:35,680
the same value initialize so that's
11948
08:26:36,180 --> 08:26:37,180
going to work as well okay anyways
11949
08:26:38,580 --> 08:26:39,580
getting back so let's say
11950
08:26:41,398 --> 08:26:42,398
now instead of this we wanted a client
11951
08:26:44,700 --> 08:26:45,700
to actually set the value for us
11952
08:26:47,280 --> 08:26:48,280
for all the players
11953
08:26:49,080 --> 08:26:50,080
so the way you do that is through a
11954
08:26:51,298 --> 08:26:52,298
remote procedural call
11955
08:26:53,350 --> 08:26:54,350
[Music]
11956
08:26:57,600 --> 08:26:58,600
so replicating variables this is about
11957
08:27:00,360 --> 08:27:01,360
it there's really nothing much to it so
11958
08:27:03,660 --> 08:27:04,660
this is basically how you replicate
11959
08:27:05,340 --> 08:27:06,340
variables I will get to rep notify
11960
08:27:08,100 --> 08:27:09,100
so let's say you wanted to call a
11961
08:27:10,798 --> 08:27:11,798
function when a variable has been
11962
08:27:13,920 --> 08:27:14,920
replicated
11963
08:27:15,120 --> 08:27:16,120
instead of replicated you can check this
11964
08:27:17,340 --> 08:27:18,340
rep notify option so then what's going
11965
08:27:19,920 --> 08:27:20,920
to happen is when the value of the
11966
08:27:22,320 --> 08:27:23,320
variable is set this function will
11967
08:27:24,540 --> 08:27:25,540
actually be called on all the clients so
11968
08:27:26,398 --> 08:27:27,398
if I go ahead and play
11969
08:27:28,680 --> 08:27:29,680
Let's see we get a Hello as well along
11970
08:27:30,600 --> 08:27:31,600
with that
11971
08:27:32,398 --> 08:27:33,398
so we can just type in rep notify
11972
08:27:37,378 --> 08:27:38,378
so we get whatever string we put over
11973
08:27:39,718 --> 08:27:40,718
there so basically that basically shows
11974
08:27:42,240 --> 08:27:43,240
that our replication logic is working
11975
08:27:43,860 --> 08:27:44,860
that's pretty much it
11976
08:27:45,718 --> 08:27:46,718
we can have any other functionality for
11977
08:27:47,878 --> 08:27:48,878
example let's say you have rep notify on
11978
08:27:50,520 --> 08:27:51,520
a health variable you can update the
11979
08:27:52,440 --> 08:27:53,440
health bar so something simple like that
11980
08:27:55,200 --> 08:27:56,200
now let's go ahead and run this logic
11981
08:27:57,718 --> 08:27:58,718
from the client so let's say we set this
11982
08:27:59,878 --> 08:28:00,878
on the client and we already saw that
11983
08:28:02,218 --> 08:28:03,218
that does not really work that well
11984
08:28:04,378 --> 08:28:05,378
so what you have to do is you have to
11985
08:28:06,000 --> 08:28:07,000
use a concept known as a remote
11986
08:28:07,320 --> 08:28:08,320
procedural calls basically they're just
11987
08:28:10,080 --> 08:28:11,080
custom events meant for multiplayer in
11988
08:28:12,540 --> 08:28:13,540
Blueprint so type in custom event
11989
08:28:16,138 --> 08:28:17,138
and we'll call this one
11990
08:28:18,120 --> 08:28:19,120
set
11991
08:28:19,200 --> 08:28:20,200
some float some float is the variable
11992
08:28:21,840 --> 08:28:22,840
name so we just made a setup for it
11993
08:28:23,580 --> 08:28:24,580
under this replicates tab set this
11994
08:28:27,540 --> 08:28:28,540
to run on server
11995
08:28:29,458 --> 08:28:30,458
now what this is going to do is this is
11996
08:28:34,320 --> 08:28:35,320
going to ensure that this runs on the
11997
08:28:36,718 --> 08:28:37,718
server
11998
08:28:37,798 --> 08:28:38,798
so if you call this from an owning
11999
08:28:40,500 --> 08:28:41,500
client
12000
08:28:41,458 --> 08:28:42,458
now we will get to the problem with it
12001
08:28:44,218 --> 08:28:45,218
and if we run it from an owning client
12002
08:28:46,978 --> 08:28:47,978
we are going to be able to call this on
12003
08:28:50,040 --> 08:28:51,040
the server so reliable basically means
12004
08:28:53,638 --> 08:28:54,638
you want it to run in order so let's say
12005
08:28:56,218 --> 08:28:57,218
you run two rpcs so it's going to run in
12006
08:29:00,058 --> 08:29:01,058
the same order if it's reliable if it's
12007
08:29:01,860 --> 08:29:02,860
not reliable the order may change since
12008
08:29:04,080 --> 08:29:05,080
it's networked it's not instantaneous
12009
08:29:06,898 --> 08:29:07,898
so stuff like that can happen so now
12010
08:29:09,360 --> 08:29:10,360
I'll just make this reliable I'll just
12011
08:29:11,700 --> 08:29:12,700
go ahead and print a string and I'll
12012
08:29:13,440 --> 08:29:14,440
call this one server RPC
12013
08:29:17,458 --> 08:29:18,458
so now what we can do is we can go ahead
12014
08:29:20,520 --> 08:29:21,520
and we'll not do this set with notify
12015
08:29:23,820 --> 08:29:24,820
we can go ahead and instead of that we
12016
08:29:26,398 --> 08:29:27,398
can call our set sum float
12017
08:29:29,458 --> 08:29:30,458
and let's see if we get anything printed
12018
08:29:35,218 --> 08:29:36,218
now something weird happens
12019
08:29:39,478 --> 08:29:40,478
as you can see
12020
08:29:42,540 --> 08:29:43,540
we are not able to actually call this
12021
08:29:45,000 --> 08:29:46,000
RPC if I were to actually play this and
12022
08:29:49,320 --> 08:29:50,320
if I open up the output log here as you
12023
08:29:52,558 --> 08:29:53,558
see it says warning unit driver process
12024
08:29:55,860 --> 08:29:56,860
remote function no earning connection
12025
08:29:57,840 --> 08:29:58,840
for actor BPA C1 this is basically the
12026
08:30:02,340 --> 08:30:03,340
display name of the actor
12027
08:30:05,040 --> 08:30:06,040
function sum floor set some float will
12028
08:30:07,978 --> 08:30:08,978
not be processed
12029
08:30:09,478 --> 08:30:10,478
what has basically happened here is that
12030
08:30:13,020 --> 08:30:14,020
unreal basically does not know
12031
08:30:16,080 --> 08:30:17,080
which client actually owns this actor
12032
08:30:18,600 --> 08:30:19,600
now this actor isn't owned by anyone
12033
08:30:22,080 --> 08:30:23,080
and if you were to notice this RPC call
12034
08:30:25,020 --> 08:30:26,020
it says reliable replicated to server if
12035
08:30:28,020 --> 08:30:29,020
owning client now this if earning
12036
08:30:31,378 --> 08:30:32,378
clients client section which is there
12037
08:30:33,298 --> 08:30:34,298
that is what is causing our server RPC
12038
08:30:35,638 --> 08:30:36,638
to fail
12039
08:30:36,780 --> 08:30:37,780
now let's do a similar drill but inside
12040
08:30:39,898 --> 08:30:40,898
a character so if I were to just create
12041
08:30:43,440 --> 08:30:44,440
an RPC here so I'll just go ahead and
12042
08:30:45,540 --> 08:30:46,540
create a custom event oops custom event
12043
08:30:47,898 --> 08:30:48,898
and I'll just call this one
12044
08:30:51,058 --> 08:30:52,058
as we underscore test something like
12045
08:30:54,298 --> 08:30:55,298
that and make this one a server RPC
12046
08:30:56,878 --> 08:30:57,878
reliable go ahead and we'll just print
12047
08:30:59,280 --> 08:31:00,280
out a string and we can say RPC called
12048
08:31:02,478 --> 08:31:03,478
RPC called from character now we want to
12049
08:31:07,200 --> 08:31:08,200
be able to call this from the client
12050
08:31:08,760 --> 08:31:09,760
instead of big inflations we are in the
12051
08:31:11,218 --> 08:31:12,218
character anyway so we can use a more
12052
08:31:13,558 --> 08:31:14,558
elegant solution maybe on a key press so
12053
08:31:16,500 --> 08:31:17,500
maybe K on the keyboard because we don't
12054
08:31:18,840 --> 08:31:19,840
have any other things so okay on the
12055
08:31:20,878 --> 08:31:21,878
keyboard
12056
08:31:22,558 --> 08:31:23,558
so find it over there
12057
08:31:27,660 --> 08:31:28,660
so there is K
12058
08:31:29,520 --> 08:31:30,520
so when we press it this will obviously
12059
08:31:32,040 --> 08:31:33,040
run on the client which presses the key
12060
08:31:34,378 --> 08:31:35,378
we can call SV test
12061
08:31:37,500 --> 08:31:38,500
so go ahead and play this
12062
08:31:39,660 --> 08:31:40,660
and if I go ahead and press ok
12063
08:31:41,940 --> 08:31:42,940
it works on the server and if I were to
12064
08:31:44,638 --> 08:31:45,638
press K on the client it works on the
12065
08:31:47,040 --> 08:31:48,040
server too I mean obviously it's a
12066
08:31:48,780 --> 08:31:49,780
server or PC so the function will run on
12067
08:31:50,878 --> 08:31:51,878
the server but the point is our RPC
12068
08:31:54,600 --> 08:31:55,600
worked and our client was able to make
12069
08:31:56,878 --> 08:31:57,878
the server RPC now what if we wanted to
12070
08:32:00,298 --> 08:32:01,298
be able to call this
12071
08:32:02,100 --> 08:32:03,100
so from a client
12072
08:32:04,200 --> 08:32:05,200
so for this you will basically need to
12073
08:32:07,138 --> 08:32:08,138
have an owner for this the way you do it
12074
08:32:09,478 --> 08:32:10,478
is through the spawn actor function so
12075
08:32:11,340 --> 08:32:12,340
if you have just placed it in the level
12076
08:32:12,718 --> 08:32:13,718
like that you will have to use the set
12077
08:32:14,700 --> 08:32:15,700
owner method which again I mean if you
12078
08:32:17,340 --> 08:32:18,340
were to place something in the level
12079
08:32:18,600 --> 08:32:19,600
it's pretty obvious you wouldn't have an
12080
08:32:20,458 --> 08:32:21,458
owner for it but let's just see an
12081
08:32:23,580 --> 08:32:24,580
example where we use the owner so what
12082
08:32:26,280 --> 08:32:27,280
we can do is okay we already have a span
12083
08:32:28,620 --> 08:32:29,620
actor function
12084
08:32:30,240 --> 08:32:31,240
and for the owner here this is something
12085
08:32:32,280 --> 08:32:33,280
which I did a bit later so for the owner
12086
08:32:35,100 --> 08:32:36,100
here go ahead and plug in self so spawn
12087
08:32:37,740 --> 08:32:38,740
an actor doesn't matter the location and
12088
08:32:40,080 --> 08:32:41,080
stuff doesn't matter we aren't worried
12089
08:32:42,240 --> 08:32:43,240
about the actual actor itself we are
12090
08:32:44,040 --> 08:32:45,040
worried about the RPC
12091
08:32:45,898 --> 08:32:46,898
so make owner self and now what I want
12092
08:32:49,860 --> 08:32:50,860
you guys to do is run this only on the
12093
08:32:53,218 --> 08:32:54,218
client
12094
08:32:54,540 --> 08:32:55,540
so let's say for example we'll again do
12095
08:32:57,240 --> 08:32:58,240
it on key press so then that's going to
12096
08:32:59,398 --> 08:33:00,398
be easy for us to manage so we can
12097
08:33:01,440 --> 08:33:02,440
manually call it
12098
08:33:03,000 --> 08:33:04,000
so on key plus what we can do and we
12099
08:33:06,240 --> 08:33:07,240
want to spawn this on the server
12100
08:33:07,558 --> 08:33:08,558
obviously we don't want to spawn this on
12101
08:33:09,898 --> 08:33:10,898
the client because it is replicated
12102
08:33:11,760 --> 08:33:12,760
remember so you have to spawn it on the
12103
08:33:14,520 --> 08:33:15,520
server itself even spawning cannot be on
12104
08:33:17,218 --> 08:33:18,218
the client
12105
08:33:18,958 --> 08:33:19,958
so make sure you spawn it on the server
12106
08:33:21,180 --> 08:33:22,180
so is server only if it is the server we
12107
08:33:25,200 --> 08:33:26,200
are going to spawn it and obviously this
12108
08:33:28,260 --> 08:33:29,260
will run multiple times because for each
12109
08:33:31,378 --> 08:33:32,378
player which will be spawned this will
12110
08:33:33,660 --> 08:33:34,660
run
12111
08:33:34,860 --> 08:33:35,860
so there's no way for us to actually
12112
08:33:36,958 --> 08:33:37,958
ensure that it happens only once but
12113
08:33:39,240 --> 08:33:40,240
nothing to worry
12114
08:33:40,920 --> 08:33:41,920
so we can just grab a reference to this
12115
08:33:44,940 --> 08:33:45,940
and we'll need to make this replicated
12116
08:33:46,860 --> 08:33:47,860
if we want access to it from the client
12117
08:33:48,840 --> 08:33:49,840
so we'll go ahead and promote this to a
12118
08:33:51,660 --> 08:33:52,660
variable
12119
08:33:53,218 --> 08:33:54,218
and we'll call this one obj for example
12120
08:33:55,978 --> 08:33:56,978
and make this replicated so that we can
12121
08:33:58,978 --> 08:33:59,978
access it from the client
12122
08:34:00,600 --> 08:34:01,600
and now when we press the K key we can
12123
08:34:03,058 --> 08:34:04,058
just check if it is valid I mean it will
12124
08:34:04,920 --> 08:34:05,920
be but just for a safety check if it is
12125
08:34:07,978 --> 08:34:08,978
valid we can go ahead and call our RPC I
12126
08:34:10,500 --> 08:34:11,500
don't know what we called it so we
12127
08:34:11,940 --> 08:34:12,940
called it set some float
12128
08:34:14,700 --> 08:34:15,700
so we called it set sum plot
12129
08:34:18,780 --> 08:34:19,780
go ahead and run this now if I were to
12130
08:34:21,898 --> 08:34:22,898
press play
12131
08:34:23,040 --> 08:34:24,040
and if I press K on the keyboard
12132
08:34:25,860 --> 08:34:26,860
as you see we get server RPC printed
12133
08:34:29,638 --> 08:34:30,638
so if I were to check this we have
12134
08:34:31,920 --> 08:34:32,920
server RPC over here and let's just test
12135
08:34:34,680 --> 08:34:35,680
it on the client as well so go ahead and
12136
08:34:36,958 --> 08:34:37,958
press K as you can see Server RPC is
12137
08:34:40,200 --> 08:34:41,200
getting printed so we are able to call
12138
08:34:42,058 --> 08:34:43,058
it on the client basically the ownership
12139
08:34:44,280 --> 08:34:45,280
is important generally it's a good thing
12140
08:34:47,398 --> 08:34:48,398
actually that you wouldn't really
12141
08:34:49,378 --> 08:34:50,378
require to call any rpcs from actors
12142
08:34:53,218 --> 08:34:54,218
like this generally you would have rpcs
12143
08:34:55,620 --> 08:34:56,620
in your character game mode game State
12144
08:34:57,540 --> 08:34:58,540
stuff like that not in the game mode
12145
08:34:58,798 --> 08:34:59,798
game mode everything is going to run on
12146
08:35:00,660 --> 08:35:01,660
the server but for the most commonly
12147
08:35:04,920 --> 08:35:05,920
used classes networking is already set
12148
08:35:07,260 --> 08:35:08,260
up for you and in case you wanted to use
12149
08:35:09,540 --> 08:35:10,540
it for an actor like this I have shown
12150
08:35:11,280 --> 08:35:12,280
you guys how to do it so this is how you
12151
08:35:12,958 --> 08:35:13,958
do it make sure you just set the owner
12152
08:35:14,638 --> 08:35:15,638
so let's say I don't actually set the
12153
08:35:16,920 --> 08:35:17,920
owner and if I go ahead and press play
12154
08:35:19,020 --> 08:35:20,020
this will still work actually so if I
12155
08:35:21,478 --> 08:35:22,478
press k
12156
08:35:22,500 --> 08:35:23,500
this is going to work but if I do it on
12157
08:35:25,200 --> 08:35:26,200
the client it's not going to work
12158
08:35:27,478 --> 08:35:28,478
so that's one thing to note from the
12159
08:35:30,180 --> 08:35:31,180
client the reason this won't work is
12160
08:35:32,760 --> 08:35:33,760
because now that we do this so let me
12161
08:35:34,920 --> 08:35:35,920
just set the owner
12162
08:35:36,660 --> 08:35:37,660
when I set the owner over here
12163
08:35:39,660 --> 08:35:40,660
now when I press play I have two
12164
08:35:42,000 --> 08:35:43,000
characters so one is on the server and
12165
08:35:44,638 --> 08:35:45,638
the other one is on the client and for
12166
08:35:47,218 --> 08:35:48,218
both of these characters the begin play
12167
08:35:49,500 --> 08:35:50,500
is going to run so this is going to run
12168
08:35:51,478 --> 08:35:52,478
both for the server as well as the
12169
08:35:53,280 --> 08:35:54,280
client
12170
08:35:54,298 --> 08:35:55,298
so for the first version everything is
12171
08:35:56,760 --> 08:35:57,760
going to run fine but when this begin
12172
08:36:00,120 --> 08:36:01,120
play occurs on the client's version of
12173
08:36:04,500 --> 08:36:05,500
the character
12174
08:36:05,760 --> 08:36:06,760
even this character will have a begin
12175
08:36:07,860 --> 08:36:08,860
play on both the server and the client
12176
08:36:09,840 --> 08:36:10,840
because since this is networked this
12177
08:36:13,080 --> 08:36:14,080
character will be spawned both on the
12178
08:36:14,940 --> 08:36:15,940
server and the client
12179
08:36:16,378 --> 08:36:17,378
so when the RPC takes when the begin
12180
08:36:19,200 --> 08:36:20,200
place called on the server for this one
12181
08:36:21,420 --> 08:36:22,420
that is when the owner property starts
12182
08:36:24,600 --> 08:36:25,600
mattering to us
12183
08:36:26,638 --> 08:36:27,638
over here if we don't set self
12184
08:36:29,218 --> 08:36:30,218
in in which case it it will refer to
12185
08:36:31,920 --> 08:36:32,920
this particular character
12186
08:36:34,740 --> 08:36:35,740
in the game
12187
08:36:36,840 --> 08:36:37,840
our logic is not going to work
12188
08:36:39,298 --> 08:36:40,298
so that was pretty elaborate in my
12189
08:36:41,638 --> 08:36:42,638
opinion this is probably something which
12190
08:36:43,200 --> 08:36:44,200
you wouldn't even require that much but
12191
08:36:45,660 --> 08:36:46,660
this is basically how you do RPC calls
12192
08:36:48,240 --> 08:36:49,240
now there's one more type of RPC which I
12193
08:36:50,458 --> 08:36:51,458
want to hint upon and that is multicast
12194
08:36:52,320 --> 08:36:53,320
what if now we are now that you're on
12195
08:36:54,780 --> 08:36:55,780
the server
12196
08:36:55,978 --> 08:36:56,978
what if you wanted to print this for all
12197
08:36:58,500 --> 08:36:59,500
the players
12198
08:36:59,520 --> 08:37:00,520
in which case it's really simple type in
12199
08:37:01,860 --> 08:37:02,860
custom event and we'll just call this
12200
08:37:03,898 --> 08:37:04,898
one MC underscore
12201
08:37:06,000 --> 08:37:07,000
print I mean we actually didn't set the
12202
08:37:08,700 --> 08:37:09,700
float here which is kinda ironic but
12203
08:37:11,160 --> 08:37:12,160
we'll just do SV underscore print so SV
12204
08:37:13,798 --> 08:37:14,798
print
12205
08:37:16,500 --> 08:37:17,500
so we'll print this and we'll just
12206
08:37:19,280 --> 08:37:20,280
duplicate this over here and make this a
12207
08:37:21,540 --> 08:37:22,540
multicast start PC now I generally don't
12208
08:37:25,020 --> 08:37:26,020
prefer making these reliable generally
12209
08:37:27,660 --> 08:37:28,660
you would use multicast for things such
12210
08:37:29,878 --> 08:37:30,878
as particle effects so you wouldn't
12211
08:37:31,978 --> 08:37:32,978
really need reliable but anyways I'll
12212
08:37:34,320 --> 08:37:35,320
just do it for this example
12213
08:37:36,058 --> 08:37:37,058
and we'll call this one multicast
12214
08:37:41,040 --> 08:37:42,040
so we'll just call MC print and remember
12215
08:37:44,100 --> 08:37:45,100
multicast star PCS have to be called on
12216
08:37:46,680 --> 08:37:47,680
the server if they are not called on the
12217
08:37:48,958 --> 08:37:49,958
server it will only run on that client
12218
08:37:51,360 --> 08:37:52,360
so it's not going to run on all the
12219
08:37:53,580 --> 08:37:54,580
others
12220
08:37:55,680 --> 08:37:56,680
so if I were to press play as you can
12221
08:37:58,500 --> 08:37:59,500
see we get multicast RPC
12222
08:38:02,580 --> 08:38:03,580
so this is basically how we would go
12223
08:38:04,440 --> 08:38:05,440
about doing this now this worked on the
12224
08:38:06,780 --> 08:38:07,780
servers instance uh obviously because we
12225
08:38:10,320 --> 08:38:11,320
spawned it over here
12226
08:38:12,120 --> 08:38:13,120
otherwise it wouldn't work
12227
08:38:14,340 --> 08:38:15,340
so if I were to just go ahead and press
12228
08:38:16,920 --> 08:38:17,920
play you would see it works
12229
08:38:18,958 --> 08:38:19,958
and if we had more players it's going to
12230
08:38:21,058 --> 08:38:22,058
work again
12231
08:38:22,798 --> 08:38:23,798
if at three players
12232
08:38:24,898 --> 08:38:25,898
it's going to print it multiple times so
12233
08:38:28,378 --> 08:38:29,378
it's going to print it on the server
12234
08:38:30,440 --> 08:38:31,440
client one and client so we have server
12235
08:38:33,898 --> 08:38:34,898
RPC multicast RPC and stuff works like
12236
08:38:37,978 --> 08:38:38,978
that
12237
08:38:39,120 --> 08:38:40,120
so this is basically how you would go
12238
08:38:41,700 --> 08:38:42,700
about calling rpcs so you have SV print
12239
08:38:45,718 --> 08:38:46,718
which is routed to the server and we can
12240
08:38:49,138 --> 08:38:50,138
actually test that out rather than doing
12241
08:38:51,240 --> 08:38:52,240
it on begin play that is kind of an
12242
08:38:52,920 --> 08:38:53,920
incorrect way obviously I showed you
12243
08:38:55,138 --> 08:38:56,138
guys the right way to do it so this is
12244
08:38:57,540 --> 08:38:58,540
some sort of logic which you would never
12245
08:38:59,280 --> 08:39:00,280
use
12246
08:39:00,420 --> 08:39:01,420
so we'll just ignore all of this go
12247
08:39:02,878 --> 08:39:03,878
ahead and press play
12248
08:39:04,200 --> 08:39:05,200
if I press K on the keyboard you see we
12249
08:39:07,260 --> 08:39:08,260
are calling the RPC if I press K on the
12250
08:39:09,780 --> 08:39:10,780
client it works as well if I press K on
12251
08:39:12,780 --> 08:39:13,780
the other client it works as well and
12252
08:39:15,058 --> 08:39:16,058
all of the players can see the printed
12253
08:39:17,100 --> 08:39:18,100
string
12254
08:39:18,478 --> 08:39:19,478
now you can also have the logic the
12255
08:39:21,120 --> 08:39:22,120
other way around so let's say you are
12256
08:39:23,820 --> 08:39:24,820
the server and then let's say for
12257
08:39:25,798 --> 08:39:26,798
example I'm just taking an example here
12258
08:39:27,600 --> 08:39:28,600
let's say when the game starts you
12259
08:39:29,520 --> 08:39:30,520
wanted to show a countdown and the
12260
08:39:32,100 --> 08:39:33,100
widget obviously will be spawned on the
12261
08:39:34,080 --> 08:39:35,080
individual clients because obviously
12262
08:39:36,600 --> 08:39:37,600
it's a widget so it has to be spawned on
12263
08:39:38,820 --> 08:39:39,820
the particular client's computer so for
12264
08:39:41,940 --> 08:39:42,940
that you will again use a client RPC so
12265
08:39:44,520 --> 08:39:45,520
I'll just do it over here so let's say
12266
08:39:47,638 --> 08:39:48,638
when I press the K key we will test this
12267
08:39:50,458 --> 08:39:51,458
on the server itself client rpcs can
12268
08:39:53,700 --> 08:39:54,700
only be run from that owning client or
12269
08:39:56,100 --> 08:39:57,100
the server if you run a client RPC from
12270
08:39:59,218 --> 08:40:00,218
another client it's not really going to
12271
08:40:01,200 --> 08:40:02,200
work
12272
08:40:02,398 --> 08:40:03,398
so in order to do that we'll just create
12273
08:40:04,740 --> 08:40:05,740
an RPC so we'll make this one cl
12274
08:40:07,080 --> 08:40:08,080
underscore test
12275
08:40:09,600 --> 08:40:10,600
and make this run on owning client
12276
08:40:12,360 --> 08:40:13,360
and what I can do now is I can go ahead
12277
08:40:15,240 --> 08:40:16,240
and print a string and let let this just
12278
08:40:18,240 --> 08:40:19,240
be there so if I do CL underscore test
12279
08:40:22,680 --> 08:40:23,680
and if I were to press play if I
12280
08:40:25,440 --> 08:40:26,440
actually press K here RPC called from
12281
08:40:28,260 --> 08:40:29,260
character runs on the server
12282
08:40:30,000 --> 08:40:31,000
over here as well this runs on the
12283
08:40:32,280 --> 08:40:33,280
client
12284
08:40:33,058 --> 08:40:34,058
and over here as well this runs on the
12285
08:40:35,638 --> 08:40:36,638
client
12286
08:40:37,080 --> 08:40:38,080
so this is basically how you do it it'll
12287
08:40:39,058 --> 08:40:40,058
just run on the client
12288
08:40:40,860 --> 08:40:41,860
but what if you wanted to run this from
12289
08:40:44,520 --> 08:40:45,520
the server so if you do this through a
12290
08:40:47,100 --> 08:40:48,100
server RPC it is going to be routed
12291
08:40:49,978 --> 08:40:50,978
through the server so I'll just do that
12292
08:40:52,020 --> 08:40:53,020
and show you guys
12293
08:40:53,700 --> 08:40:54,700
so what we'll just do is we'll just uh
12294
08:40:56,058 --> 08:40:57,058
diyte ourselves so we can say SV test
12295
08:40:59,458 --> 08:41:00,458
and this will run on the server we can
12296
08:41:01,860 --> 08:41:02,860
have another print string and we'll call
12297
08:41:03,660 --> 08:41:04,660
This One SV for server and over here
12298
08:41:07,260 --> 08:41:08,260
instead of that we'll call the server
12299
08:41:09,058 --> 08:41:10,058
RPC
12300
08:41:10,260 --> 08:41:11,260
and now what we can do is once this is
12301
08:41:12,540 --> 08:41:13,540
printed we can go ahead and call the
12302
08:41:14,398 --> 08:41:15,398
client RPC so CL test
12303
08:41:17,458 --> 08:41:18,458
now if you were to notice if I go ahead
12304
08:41:20,160 --> 08:41:21,160
and press play
12305
08:41:21,780 --> 08:41:22,780
if I press K as you can see now both are
12306
08:41:24,898 --> 08:41:25,898
called on the server so the server RPC
12307
08:41:27,180 --> 08:41:28,180
work and the client RPC worked but if I
12308
08:41:29,638 --> 08:41:30,638
do this on a client as you can see the
12309
08:41:32,398 --> 08:41:33,398
server printed SV and the server again
12310
08:41:34,920 --> 08:41:35,920
called a function on this client so this
12311
08:41:38,520 --> 08:41:39,520
is basically how you would go about
12312
08:41:40,320 --> 08:41:41,320
using client rpcs so for any multiplayer
12313
08:41:43,920 --> 08:41:44,920
logic this is exactly how you would go
12314
08:41:46,020 --> 08:41:47,020
about doing this
12315
08:41:47,398 --> 08:41:48,398
in C plus plus this logic is pretty
12316
08:41:51,240 --> 08:41:52,240
straightforward there's just a few
12317
08:41:53,458 --> 08:41:54,458
additional steps for rep notify and uh
12318
08:41:56,520 --> 08:41:57,520
replicating variables but other than
12319
08:41:59,280 --> 08:42:00,280
that
12320
08:42:00,478 --> 08:42:01,478
even the C plus plus part is pretty
12321
08:42:02,820 --> 08:42:03,820
straightforward so generally you would
12322
08:42:05,040 --> 08:42:06,040
use blueprint itself for core
12323
08:42:07,320 --> 08:42:08,320
multiplayer logic unless it's something
12324
08:42:09,740 --> 08:42:10,740
uh you know fundamental to your game and
12325
08:42:13,138 --> 08:42:14,138
you want it to work
12326
08:42:15,080 --> 08:42:16,080
properly like let's say you had like a
12327
08:42:17,580 --> 08:42:18,580
firing mechanic or something and you
12328
08:42:19,978 --> 08:42:20,978
don't want any sort of performance
12329
08:42:22,138 --> 08:42:23,138
issues or any overheads you then you
12330
08:42:24,298 --> 08:42:25,298
would use C plus plus otherwise you
12331
08:42:25,978 --> 08:42:26,978
would really just use blueprint for most
12332
08:42:28,378 --> 08:42:29,378
of the things because it makes things so
12333
08:42:30,298 --> 08:42:31,298
simple as you can see you don't have to
12334
08:42:32,638 --> 08:42:33,638
do stuff like opening ports and stuff so
12335
08:42:36,058 --> 08:42:37,058
all of that is handled by unreal
12336
08:42:38,940 --> 08:42:39,940
and now let's go ahead and see how to
12337
08:42:41,820 --> 08:42:42,820
run rpcs in C plus plus
12338
08:42:46,490 --> 08:42:47,490
[Music]
12339
08:42:49,878 --> 08:42:50,878
thank you
12340
08:42:51,898 --> 08:42:52,898
now I've gone ahead and opened up visual
12341
08:42:55,440 --> 08:42:56,440
studio now we'll just ignore the plugins
12342
08:42:57,958 --> 08:42:58,958
part right now and we'll head into our
12343
08:42:59,638 --> 08:43:00,638
source folder beginner course public and
12344
08:43:03,000 --> 08:43:04,000
we'll head into first of all we'll head
12345
08:43:05,398 --> 08:43:06,398
into a character
12346
08:43:06,780 --> 08:43:07,780
now what I want you guys to do here is
12347
08:43:09,540 --> 08:43:10,540
first of all before you actually use any
12348
08:43:12,000 --> 08:43:13,000
networking feature just make sure you
12349
08:43:14,638 --> 08:43:15,638
include
12350
08:43:15,718 --> 08:43:16,718
net
12351
08:43:17,160 --> 08:43:18,160
slash unrealnetwork.h
12352
08:43:20,878 --> 08:43:21,878
dot h
12353
08:43:22,378 --> 08:43:23,378
make sure you include this header if you
12354
08:43:25,080 --> 08:43:26,080
do not include this header you will get
12355
08:43:26,878 --> 08:43:27,878
all sorts of weird errors so make sure
12356
08:43:29,580 --> 08:43:30,580
you do that
12357
08:43:30,600 --> 08:43:31,600
now first things first let's talk about
12358
08:43:33,180 --> 08:43:34,180
variable replication so if you want a
12359
08:43:36,298 --> 08:43:37,298
variable to be replicated
12360
08:43:38,520 --> 08:43:39,520
uh you basically have to make it a U
12361
08:43:41,160 --> 08:43:42,160
property first things first
12362
08:43:43,200 --> 08:43:44,200
and this one will give the specified
12363
08:43:46,320 --> 08:43:47,320
blueprint read right as usual to make
12364
08:43:48,420 --> 08:43:49,420
things simple for us
12365
08:43:50,280 --> 08:43:51,280
and one more thing which you have to
12366
08:43:52,080 --> 08:43:53,080
give is you have to give the specifier
12367
08:43:53,820 --> 08:43:54,820
replicated
12368
08:43:55,878 --> 08:43:56,878
and we'll make this let's say a float
12369
08:44:00,600 --> 08:44:01,600
float
12370
08:44:01,940 --> 08:44:02,940
replicated CPP variable Maybe
12371
08:44:07,020 --> 08:44:08,020
now one more thing which you have to do
12372
08:44:09,180 --> 08:44:10,180
this is additional this is not something
12373
08:44:11,340 --> 08:44:12,340
you have to do in Blueprint but one
12374
08:44:13,558 --> 08:44:14,558
thing you have to do for the replication
12375
08:44:15,058 --> 08:44:16,058
logic to work is you have to actually
12376
08:44:17,218 --> 08:44:18,218
write one function in the CPP file of
12377
08:44:20,280 --> 08:44:21,280
our character we'll go ahead and do that
12378
08:44:22,440 --> 08:44:23,440
and then we should be able to make this
12379
08:44:24,840 --> 08:44:25,840
work directly
12380
08:44:27,958 --> 08:44:28,958
so I've gone ahead and opened up the
12381
08:44:30,478 --> 08:44:31,478
documentation so this is the function
12382
08:44:32,580 --> 08:44:33,580
which we actually need so we can go
12383
08:44:34,260 --> 08:44:35,260
ahead and copy this and paste it inside
12384
08:44:37,558 --> 08:44:38,558
our character.cpp files have opened that
12385
08:44:40,500 --> 08:44:41,500
up and I'll just written a comment
12386
08:44:43,080 --> 08:44:44,080
called replicating variables go ahead
12387
08:44:45,958 --> 08:44:46,958
and paste it and we can go ahead and
12388
08:44:47,820 --> 08:44:48,820
have a definition for it
12389
08:44:49,700 --> 08:44:50,700
so over here this is going to be acpp
12390
08:44:53,280 --> 08:44:54,280
underscore character just put your class
12391
08:44:55,260 --> 08:44:56,260
name followed by the scope resolution
12392
08:44:57,420 --> 08:44:58,420
operator
12393
08:44:58,860 --> 08:44:59,860
then you can go ahead and just move
12394
08:45:01,020 --> 08:45:02,020
everything to one line to keep things
12395
08:45:02,820 --> 08:45:03,820
clean
12396
08:45:03,780 --> 08:45:04,780
and over here you would want to run this
12397
08:45:06,718 --> 08:45:07,718
macro called do rep Lifetime and this
12398
08:45:09,958 --> 08:45:10,958
takes in two parameters one is the class
12399
08:45:11,878 --> 08:45:12,878
which is going to be our current class
12400
08:45:14,660 --> 08:45:15,660
and the variable name the variable name
12401
08:45:17,520 --> 08:45:18,520
is going to be this
12402
08:45:20,040 --> 08:45:21,040
oh it's going to be replicated CPP
12403
08:45:22,378 --> 08:45:23,378
variable
12404
08:45:23,458 --> 08:45:24,458
now I'm recording this a bit later but
12405
08:45:25,558 --> 08:45:26,558
one thing that I forgot to mention is
12406
08:45:27,180 --> 08:45:28,180
make sure you call uh super of this
12407
08:45:30,058 --> 08:45:31,058
function otherwise you'll get weird
12408
08:45:32,700 --> 08:45:33,700
classes when you use the weird uh
12409
08:45:35,580 --> 08:45:36,580
artifacts when you use the derived
12410
08:45:38,100 --> 08:45:39,100
classes and for the parameter you can
12411
08:45:40,500 --> 08:45:41,500
just pass this in so make sure you just
12412
08:45:42,478 --> 08:45:43,478
do that otherwise your movement
12413
08:45:44,040 --> 08:45:45,040
variables and stuff will not be
12414
08:45:45,660 --> 08:45:46,660
replicated if you use your BP character
12415
08:45:47,878 --> 08:45:48,878
so that's one thing to note
12416
08:45:50,520 --> 08:45:51,520
and now if I were to go ahead and run a
12417
08:45:53,280 --> 08:45:54,280
debugger we should be able to do it just
12418
08:45:55,020 --> 08:45:56,020
make sure you close the editor and then
12419
08:45:56,878 --> 08:45:57,878
run a debugger
12420
08:45:59,760 --> 08:46:00,760
so as you can see the build succeeded
12421
08:46:01,558 --> 08:46:02,558
and now we should be in theory able to
12422
08:46:04,200 --> 08:46:05,200
use this variable as a normal replicated
12423
08:46:07,200 --> 08:46:08,200
variable in Blueprint
12424
08:46:09,660 --> 08:46:10,660
so I'll just show you guys replicated
12425
08:46:12,420 --> 08:46:13,420
variables are shown with those two balls
12426
08:46:14,520 --> 08:46:15,520
on the top so BP character is inherited
12427
08:46:17,520 --> 08:46:18,520
from CPP characters so we should have it
12428
08:46:19,320 --> 08:46:20,320
so if I just type in CPP get replicated
12429
08:46:22,320 --> 08:46:23,320
CPP variable and as you can see this
12430
08:46:24,360 --> 08:46:25,360
variable is replicated if I were to
12431
08:46:26,940 --> 08:46:27,940
actually go ahead and check this
12432
08:46:30,360 --> 08:46:31,360
variable over here it says cpf net this
12433
08:46:33,718 --> 08:46:34,718
basically means it's replicated so now
12434
08:46:37,620 --> 08:46:38,620
this should work like a normal
12435
08:46:39,058 --> 08:46:40,058
replicated variable
12436
08:46:40,860 --> 08:46:41,860
now I'll show you guys how to handle our
12437
08:46:43,680 --> 08:46:44,680
pieces as well
12438
08:46:46,860 --> 08:46:47,860
so rpcs are simple I'll show you guys
12439
08:46:50,700 --> 08:46:51,700
how to handle server and multicast rpcs
12440
08:46:54,000 --> 08:46:55,000
I won't really go over client or PCS
12441
08:46:56,638 --> 08:46:57,638
they work pretty much the same
12442
08:46:58,500 --> 08:46:59,500
so I'll go ahead and stop this now
12443
08:47:01,740 --> 08:47:02,740
and for the for rpcs in C plus plus you
12444
08:47:06,420 --> 08:47:07,420
need to basically have a u function
12445
08:47:09,298 --> 08:47:10,298
first of all so create a view function
12446
08:47:12,898 --> 08:47:13,898
and you cannot make rpcs in C plus plus
12447
08:47:16,920 --> 08:47:17,920
blueprint callable however you can wrap
12448
08:47:20,160 --> 08:47:21,160
them inside another function and then
12449
08:47:21,898 --> 08:47:22,898
make them blueprint callable or whatever
12450
08:47:23,820 --> 08:47:24,820
so what I'm going to do is I'm going to
12451
08:47:26,878 --> 08:47:27,878
make call uh put the specifier server
12452
08:47:31,798 --> 08:47:32,798
and one more thing I am going to make
12453
08:47:33,840 --> 08:47:34,840
this either reliable or unreliable so
12454
08:47:36,058 --> 08:47:37,058
this is where you specified
12455
08:47:37,860 --> 08:47:38,860
so reliable
12456
08:47:39,840 --> 08:47:40,840
or you can make it unreliable
12457
08:47:42,958 --> 08:47:43,958
now I can go ahead and actually write
12458
08:47:47,100 --> 08:47:48,100
something here so let's say void
12459
08:47:51,058 --> 08:47:52,058
test server RPC underscore CPP just to
12460
08:47:56,398 --> 08:47:57,398
indicate that this is NC plus plus
12461
08:47:59,280 --> 08:48:00,280
now what you need to do is you need to
12462
08:48:01,440 --> 08:48:02,440
Define it over there but also
12463
08:48:04,620 --> 08:48:05,620
uh rather than defining this you are
12464
08:48:08,280 --> 08:48:09,280
supposed to Define
12465
08:48:10,160 --> 08:48:11,160
another function known as the
12466
08:48:13,558 --> 08:48:14,558
implementation for this
12467
08:48:16,080 --> 08:48:17,080
so what we are going to do is we are
12468
08:48:18,540 --> 08:48:19,540
going to just copy this over into the
12469
08:48:21,058 --> 08:48:22,058
next line This need not be a u function
12470
08:48:22,740 --> 08:48:23,740
and type in underscore implementation
12471
08:48:25,080 --> 08:48:26,080
okay just ignore the parentheses there
12472
08:48:27,298 --> 08:48:28,298
implementation
12473
08:48:29,580 --> 08:48:30,580
and now what we can do is we can create
12474
08:48:32,100 --> 08:48:33,100
a definition for this instead so I've
12475
08:48:34,920 --> 08:48:35,920
already done that so I have the
12476
08:48:37,260 --> 08:48:38,260
definition for this and we can do
12477
08:48:39,660 --> 08:48:40,660
something simple such as a print string
12478
08:48:41,700 --> 08:48:42,700
so you Kismet system Library print
12479
08:48:43,740 --> 08:48:44,740
string
12480
08:48:45,080 --> 08:48:46,080
and we can go ahead and print in
12481
08:48:48,378 --> 08:48:49,378
this is a server RPC from C plus plus
12482
08:48:54,600 --> 08:48:55,600
now this shouldn't clearly work and if
12483
08:48:57,780 --> 08:48:58,780
we want to call this RPC what we would
12484
08:49:00,840 --> 08:49:01,840
do is you can you can just go ahead and
12485
08:49:03,240 --> 08:49:04,240
call this we don't have to call the
12486
08:49:04,978 --> 08:49:05,978
implementation we have to call this in
12487
08:49:07,138 --> 08:49:08,138
order for the implementation to get
12488
08:49:09,000 --> 08:49:10,000
called on the server or we could just uh
12489
08:49:12,478 --> 08:49:13,478
do something else such as wrapping it in
12490
08:49:14,760 --> 08:49:15,760
another function so I'll show you guys
12491
08:49:16,740 --> 08:49:17,740
both the approaches actually so I'll
12492
08:49:18,780 --> 08:49:19,780
just do it on begin play so on the
12493
08:49:21,958 --> 08:49:22,958
gameplay what we'll do is we'll go ahead
12494
08:49:25,020 --> 08:49:26,020
and we'll actually delete some of this
12495
08:49:27,120 --> 08:49:28,120
code
12496
08:49:28,680 --> 08:49:29,680
so we'll delete this and what we can do
12497
08:49:31,378 --> 08:49:32,378
is over here we can go ahead and check
12498
08:49:34,138 --> 08:49:35,138
so if we are on the server in fact or if
12499
08:49:38,040 --> 08:49:39,040
we are not on the server we are going to
12500
08:49:39,478 --> 08:49:40,478
do it so if is server
12501
08:49:44,940 --> 08:49:45,940
so I guess it's called GS server I think
12502
08:49:48,120 --> 08:49:49,120
it's a variable not a method so if this
12503
08:49:51,058 --> 08:49:52,058
is not a server we are going to call
12504
08:49:53,580 --> 08:49:54,580
this RPC
12505
08:49:55,620 --> 08:49:56,620
over here we'll call test server RPC
12506
08:49:58,680 --> 08:49:59,680
underscore CPP
12507
08:50:01,558 --> 08:50:02,558
and this will work as expected
12508
08:50:04,440 --> 08:50:05,440
and we can go ahead and wrap this in a
12509
08:50:07,138 --> 08:50:08,138
blueprint view function so we'll create
12510
08:50:09,600 --> 08:50:10,600
a new function
12511
08:50:11,160 --> 08:50:12,160
make this one
12512
08:50:13,138 --> 08:50:14,138
blueprint callable
12513
08:50:18,718 --> 08:50:19,718
and from here what we can do is we can
12514
08:50:20,940 --> 08:50:21,940
just type in void
12515
08:50:23,398 --> 08:50:24,398
wrapper for CPP RPC
12516
08:50:29,280 --> 08:50:30,280
and this one we can just write it like
12517
08:50:31,798 --> 08:50:32,798
any other function and the RPC will run
12518
08:50:34,860 --> 08:50:35,860
now what you can do over here is you can
12519
08:50:37,020 --> 08:50:38,020
go ahead and run this function inside of
12520
08:50:40,138 --> 08:50:41,138
that
12521
08:50:41,458 --> 08:50:42,458
so we'll go ahead and call this
12522
08:50:43,978 --> 08:50:44,978
and since this is blueprint callable we
12523
08:50:46,260 --> 08:50:47,260
can go ahead and just call this from
12524
08:50:47,700 --> 08:50:48,700
blueprint
12525
08:50:48,718 --> 08:50:49,718
also realize that just because of the
12526
08:50:52,020 --> 08:50:53,020
way the function call works this is not
12527
08:50:54,360 --> 08:50:55,360
going to run at all
12528
08:50:56,040 --> 08:50:57,040
no matter what you do it is going to
12529
08:51:01,138 --> 08:51:02,138
come outside the if
12530
08:51:03,478 --> 08:51:04,478
so if it comes inside this it's again
12531
08:51:06,360 --> 08:51:07,360
not going to the condition is again not
12532
08:51:08,878 --> 08:51:09,878
going to be valid so you're not going to
12533
08:51:10,740 --> 08:51:11,740
run this function
12534
08:51:12,120 --> 08:51:13,120
so anyways we'll just run it as is and
12535
08:51:14,458 --> 08:51:15,458
then we can go ahead and run a debugger
12536
08:51:18,058 --> 08:51:19,058
so now if I were to actually go ahead
12537
08:51:20,458 --> 08:51:21,458
and wait for it
12538
08:51:24,840 --> 08:51:25,840
so once it loads in
12539
08:51:27,420 --> 08:51:28,420
and I go ahead and press play
12540
08:51:31,440 --> 08:51:32,440
if I press play right now
12541
08:51:34,680 --> 08:51:35,680
you'll notice that you get this is a
12542
08:51:37,978 --> 08:51:38,978
server RPC from C plus plus so we got
12543
08:51:40,860 --> 08:51:41,860
two server RPC calls one from the client
12544
08:51:43,620 --> 08:51:44,620
and one from the server
12545
08:51:46,860 --> 08:51:47,860
now I'll also set up some logic so that
12546
08:51:49,680 --> 08:51:50,680
we run this during gameplay
12547
08:51:52,378 --> 08:51:53,378
so under your BP character what we can
12548
08:51:54,360 --> 08:51:55,360
do is we can run the wrapper so type in
12549
08:51:56,638 --> 08:51:57,638
wrapper for CPP or PC now if I go ahead
12550
08:51:59,940 --> 08:52:00,940
and press play and press K on the
12551
08:52:02,040 --> 08:52:03,040
keyboard as you can see it runs on the
12552
08:52:04,680 --> 08:52:05,680
server
12553
08:52:05,700 --> 08:52:06,700
and if I do it on the client that works
12554
08:52:08,638 --> 08:52:09,638
as well totally as expected now one
12555
08:52:12,660 --> 08:52:13,660
extra feature which I want to cover in C
12556
08:52:15,240 --> 08:52:16,240
plus plus rpcs is the validation so if I
12557
08:52:19,138 --> 08:52:20,138
just type in a comma and type in width
12558
08:52:22,020 --> 08:52:23,020
okay how my caps lock on with
12559
08:52:24,958 --> 08:52:25,958
validation
12560
08:52:26,940 --> 08:52:27,940
now what I can do is I can write a
12561
08:52:30,180 --> 08:52:31,180
function which returns a Boolean and
12562
08:52:32,458 --> 08:52:33,458
instead of underscore implementation if
12563
08:52:34,680 --> 08:52:35,680
I type in underscore validate
12564
08:52:37,378 --> 08:52:38,378
you can make it so that this function
12565
08:52:40,020 --> 08:52:41,020
will only run under a certain condition
12566
08:52:41,898 --> 08:52:42,898
this is especially useful for something
12567
08:52:44,580 --> 08:52:45,580
like cheat detection so if I were to
12568
08:52:46,860 --> 08:52:47,860
just create a definition for it
12569
08:52:49,138 --> 08:52:50,138
and what I can do is if this returns
12570
08:52:51,840 --> 08:52:52,840
false basically this client which is
12571
08:52:54,058 --> 08:52:55,058
calling the RPC will get disconnected
12572
08:52:56,040 --> 08:52:57,040
immediately so I can just do return true
12573
08:52:58,680 --> 08:52:59,680
for now and this RPC is going to run so
12574
08:53:01,020 --> 08:53:02,020
if you had something like a health
12575
08:53:02,218 --> 08:53:03,218
variable or something and you do
12576
08:53:03,898 --> 08:53:04,898
something like if health is you know
12577
08:53:06,718 --> 08:53:07,718
less than or equal to 100
12578
08:53:08,940 --> 08:53:09,940
and
12579
08:53:10,440 --> 08:53:11,440
or maybe if you had any other conditions
12580
08:53:13,138 --> 08:53:14,138
so let's say the health you had a set
12581
08:53:15,420 --> 08:53:16,420
Health function which is an RPC of
12582
08:53:17,878 --> 08:53:18,878
course so then you would check if it is
12583
08:53:20,218 --> 08:53:21,218
less than or equal to 100 because you
12584
08:53:21,780 --> 08:53:22,780
don't want the player to set the health
12585
08:53:23,458 --> 08:53:24,458
to a value greater than 100 stuff like
12586
08:53:26,700 --> 08:53:27,700
this but for now we'll just leave this
12587
08:53:28,200 --> 08:53:29,200
to true this function will run just to
12588
08:53:31,080 --> 08:53:32,080
Showcase I'm just going to print string
12589
08:53:33,058 --> 08:53:34,058
once again so this
12590
08:53:35,458 --> 08:53:36,458
and we'll call this validate
12591
08:53:39,240 --> 08:53:40,240
and will not do this on begin play soops
12592
08:53:42,600 --> 08:53:43,600
print string
12593
08:53:45,180 --> 08:53:46,180
go ahead and run a debugger and before
12594
08:53:48,420 --> 08:53:49,420
we do that I'll actually just show you
12595
08:53:50,040 --> 08:53:51,040
guys how to handle rpcs as well I mean
12596
08:53:53,600 --> 08:53:54,600
rep notify as well
12597
08:53:55,978 --> 08:53:56,978
so let's say I wanted to make this rep
12598
08:53:59,280 --> 08:54:00,280
notify I would use the replicated using
12599
08:54:02,878 --> 08:54:03,878
flag I will do it after this actually
12600
08:54:06,840 --> 08:54:07,840
now if I were to go ahead and press play
12601
08:54:09,478 --> 08:54:10,478
as you would see the validate function
12602
08:54:11,818 --> 08:54:12,818
was also called on the server so the
12603
08:54:14,100 --> 08:54:15,100
server is going to validate and
12604
08:54:16,378 --> 08:54:17,378
accordingly it is going to disconnect
12605
08:54:18,120 --> 08:54:19,120
the client if the condition is not met
12606
08:54:20,398 --> 08:54:21,398
so that function whatever we saw right
12607
08:54:22,558 --> 08:54:23,558
there that has to return true in order
12608
08:54:24,660 --> 08:54:25,660
for the RPC call to take place
12609
08:54:26,580 --> 08:54:27,580
successfully and for the client to
12610
08:54:28,798 --> 08:54:29,798
continue stay connected so this is
12611
08:54:31,318 --> 08:54:32,318
basically validation and now let's talk
12612
08:54:33,718 --> 08:54:34,718
about rep notify
12613
08:54:36,000 --> 08:54:37,000
I am back inside the header file and for
12614
08:54:39,000 --> 08:54:40,000
rep notify over here you can just go
12615
08:54:41,700 --> 08:54:42,700
ahead and create a function so what do
12616
08:54:44,218 --> 08:54:45,218
we call this function this need not be
12617
08:54:45,958 --> 08:54:46,958
your function but you can make it as
12618
08:54:47,818 --> 08:54:48,818
well so we'll call this one
12619
08:54:50,638 --> 08:54:51,638
uh on rep it's just a convention to use
12620
08:54:53,580 --> 08:54:54,580
on rep but it need not be on rep
12621
08:54:57,200 --> 08:54:58,200
wrapper for CPP let's say
12622
08:55:00,920 --> 08:55:01,920
for CPP
12623
08:55:03,120 --> 08:55:04,120
and this one will just be void no need
12624
08:55:06,718 --> 08:55:07,718
to return anything you could return a
12625
08:55:09,000 --> 08:55:10,000
value if you wish but there's really
12626
08:55:10,558 --> 08:55:11,558
nothing much you can do with it
12627
08:55:12,420 --> 08:55:13,420
go ahead and write a function definition
12628
08:55:14,760 --> 08:55:15,760
for it
12629
08:55:16,318 --> 08:55:17,318
now again what we can do is we can go
12630
08:55:19,318 --> 08:55:20,318
ahead and just print something so we'll
12631
08:55:21,780 --> 08:55:22,780
just copy this over and rather than
12632
08:55:23,520 --> 08:55:24,520
validate we'll just print
12633
08:55:25,740 --> 08:55:26,740
rep notify from C plus plus
12634
08:55:30,240 --> 08:55:31,240
so now what we can do is now we can feel
12635
08:55:32,638 --> 08:55:33,638
free to come in here and rather than
12636
08:55:34,798 --> 08:55:35,798
typing in replicated type replicated
12637
08:55:36,898 --> 08:55:37,898
using equals and just pass in the
12638
08:55:40,620 --> 08:55:41,620
function name
12639
08:55:41,940 --> 08:55:42,940
so you don't have to pass in anything
12640
08:55:43,680 --> 08:55:44,680
else and this is going to work as you
12641
08:55:46,378 --> 08:55:47,378
would expect one thing that you would
12642
08:55:48,840 --> 08:55:49,840
want to do is wherever you call this
12643
08:55:50,580 --> 08:55:51,580
function uh that will obviously be on
12644
08:55:53,818 --> 08:55:54,818
the server make sure you call this
12645
08:55:57,478 --> 08:55:58,478
function as well separately
12646
08:56:00,298 --> 08:56:01,298
so where you set the variable
12647
08:56:03,420 --> 08:56:04,420
so we are setting this replicated CPP
12648
08:56:06,180 --> 08:56:07,180
variable so we'll do that
12649
08:56:08,520 --> 08:56:09,520
make sure you call this as well so if
12650
08:56:10,620 --> 08:56:11,620
you are setting this in Blueprint make
12651
08:56:12,058 --> 08:56:13,058
sure you make this function a u function
12652
08:56:14,040 --> 08:56:15,040
and make it blueprint callable
12653
08:56:16,020 --> 08:56:17,020
so we'll do that actually
12654
08:56:19,020 --> 08:56:20,020
there's one issue with it in C plus plus
12655
08:56:21,898 --> 08:56:22,898
this is how we would uh the same this
12656
08:56:25,200 --> 08:56:26,200
thing works in the same way as it works
12657
08:56:27,298 --> 08:56:28,298
in Blueprint
12658
08:56:28,680 --> 08:56:29,680
so we'll just do it on our RPC itself
12659
08:56:31,160 --> 08:56:32,160
anyways we are running the RPC so in the
12660
08:56:33,958 --> 08:56:34,958
implementation for it
12661
08:56:35,700 --> 08:56:36,700
will not have the print string rather we
12662
08:56:38,700 --> 08:56:39,700
will have our ref notify
12663
08:56:42,478 --> 08:56:43,478
the way you do that is we'll modify the
12664
08:56:44,878 --> 08:56:45,878
value of the variable if you modify the
12665
08:56:46,680 --> 08:56:47,680
value automatically rep notify will be
12666
08:56:49,080 --> 08:56:50,080
called Equals I'll just type Rand mod
12667
08:56:55,260 --> 08:56:56,260
19 I just chose a random number over
12668
08:56:57,478 --> 08:56:58,478
there and what you want to do is you
12669
08:57:00,360 --> 08:57:01,360
would want to call this function
12670
08:57:02,818 --> 08:57:03,818
only over here
12671
08:57:04,920 --> 08:57:05,920
and the rest will be handled for you
12672
08:57:08,218 --> 08:57:09,218
now we can go ahead and run a debugger
12673
08:57:12,120 --> 08:57:13,120
and you would see that our rep notify
12674
08:57:14,638 --> 08:57:15,638
will be called and rep notify from C
12675
08:57:16,680 --> 08:57:17,680
plus plus is going to be printed it just
12676
08:57:19,378 --> 08:57:20,378
works just like that
12677
08:57:21,780 --> 08:57:22,780
so wait for the editor to load in
12678
08:57:24,840 --> 08:57:25,840
and once we are inside the editor if I
12679
08:57:27,660 --> 08:57:28,660
go ahead and press play as you can see
12680
08:57:29,760 --> 08:57:30,760
rep notify from C plus plus and it was
12681
08:57:32,520 --> 08:57:33,520
called on the client as well since there
12682
08:57:35,100 --> 08:57:36,100
are two versions of the character here
12683
08:57:36,718 --> 08:57:37,718
so one on the client and one on the
12684
08:57:38,398 --> 08:57:39,398
server both of them called it two times
12685
08:57:40,378 --> 08:57:41,378
so that's the reason we got four prints
12686
08:57:42,660 --> 08:57:43,660
and the same thing is going to work when
12687
08:57:44,760 --> 08:57:45,760
we use the wrapper
12688
08:57:46,860 --> 08:57:47,860
so if I just type in k for example you
12689
08:57:49,378 --> 08:57:50,378
see the rep notify works so
12690
08:57:52,200 --> 08:57:53,200
we get the validate rep notify as well
12691
08:57:55,200 --> 08:57:56,200
as anything else that you would expect
12692
08:57:57,600 --> 08:57:58,600
so wrap notify on the server and the
12693
08:57:59,878 --> 08:58:00,878
client
12694
08:58:01,860 --> 08:58:02,860
and if you want to do the same in
12695
08:58:03,298 --> 08:58:04,298
Blueprint
12696
08:58:04,440 --> 08:58:05,440
so you can go ahead and set
12697
08:58:07,740 --> 08:58:08,740
our replicated CPP variable to something
12698
08:58:11,458 --> 08:58:12,458
and you would notice something weird
12699
08:58:14,280 --> 08:58:15,280
uh first of all I have to do it on the
12700
08:58:16,440 --> 08:58:17,440
server so we'll do it on a server or PC
12701
08:58:19,260 --> 08:58:20,260
so SV test rather than doing CL test
12702
08:58:22,260 --> 08:58:23,260
we'll go ahead and set the value of this
12703
08:58:24,420 --> 08:58:25,420
variable
12704
08:58:26,160 --> 08:58:27,160
and we can do SV test
12705
08:58:29,580 --> 08:58:30,580
go ahead and close this
12706
08:58:32,398 --> 08:58:33,398
and if I were to press K let's just wait
12707
08:58:34,860 --> 08:58:35,860
for it as you see
12708
08:58:37,020 --> 08:58:38,020
this rep notify is only called on the
12709
08:58:39,840 --> 08:58:40,840
client this is not actually called on
12710
08:58:42,180 --> 08:58:43,180
the server
12711
08:58:44,818 --> 08:58:45,818
so in order for rep notified to work
12712
08:58:47,160 --> 08:58:48,160
again once you do this you will have to
12713
08:58:49,740 --> 08:58:50,740
type in on rep wrapper for CPP
12714
08:58:53,700 --> 08:58:54,700
so make sure you actually type that
12715
08:58:57,058 --> 08:58:58,058
so now if I were to go ahead and press K
12716
08:59:00,180 --> 08:59:01,180
on the keyboard you see it runs both on
12717
08:59:02,100 --> 08:59:03,100
the server and the client
12718
08:59:03,660 --> 08:59:04,660
so there's just one extra step which you
12719
08:59:05,700 --> 08:59:06,700
have to take in C plus plus that is if
12720
08:59:08,940 --> 08:59:09,940
you have your replicated variable in C
12721
08:59:10,798 --> 08:59:11,798
plus plus
12722
08:59:12,600 --> 08:59:13,600
so that's about it for rep notify I
12723
08:59:15,120 --> 08:59:16,120
guess we have covered almost all aspects
12724
08:59:16,978 --> 08:59:17,978
of replication uh multicast is something
12725
08:59:19,920 --> 08:59:20,920
which I'll just talk about so all the
12726
08:59:23,100 --> 08:59:24,100
same parameters except or here you would
12727
08:59:25,500 --> 08:59:26,500
have net multicast
12728
08:59:27,898 --> 08:59:28,898
so don't mind the spelling I mean the
12729
08:59:30,660 --> 08:59:31,660
capitalization
12730
08:59:31,920 --> 08:59:32,920
so I have my caps lock on net multicast
12731
08:59:36,540 --> 08:59:37,540
and this will work as expected you can
12732
08:59:39,780 --> 08:59:40,780
again have your reliable and validation
12733
08:59:41,940 --> 08:59:42,940
and stuff like that
12734
08:59:43,378 --> 08:59:44,378
uh the rest of it will remain exactly
12735
08:59:46,378 --> 08:59:47,378
the same so you'll have your
12736
08:59:48,000 --> 08:59:49,000
implementation and you can have your
12737
08:59:50,280 --> 08:59:51,280
validate if required
12738
08:59:52,080 --> 08:59:53,080
but you wouldn't really have a validate
12739
08:59:54,120 --> 08:59:55,120
for a multicast RPC so I'll just go
12740
08:59:57,000 --> 08:59:58,000
ahead and delete that
12741
08:59:59,180 --> 09:00:00,180
and this should work just as expected so
12742
09:00:03,360 --> 09:00:04,360
I'm not going to really show that this
12743
09:00:05,160 --> 09:00:06,160
is how you would basically set up a
12744
09:00:06,540 --> 09:00:07,540
multicast RPC and the documentation is
12745
09:00:09,420 --> 09:00:10,420
there we did the example for the server
12746
09:00:11,760 --> 09:00:12,760
there are no syntactical changes to this
12747
09:00:14,340 --> 09:00:15,340
so it should be totally okay so we'll
12748
09:00:16,978 --> 09:00:17,978
just delete that definition and I guess
12749
09:00:19,500 --> 09:00:20,500
then we are done with multiplayer guys
12750
09:00:22,720 --> 09:00:23,720
[Music]
12751
09:00:27,000 --> 09:00:28,000
now that we are done with covering all
12752
09:00:29,398 --> 09:00:30,398
aspects of game development in Unreal
12753
09:00:32,398 --> 09:00:33,398
Engine let's go ahead and actually take
12754
09:00:35,580 --> 09:00:36,580
a look at how to install Unreal Engine
12755
09:00:37,680 --> 09:00:38,680
from source so the main part is actually
12756
09:00:40,620 --> 09:00:41,620
done now we'll be doing a couple of
12757
09:00:42,958 --> 09:00:43,958
things such as downloading the source
12758
09:00:45,120 --> 09:00:46,120
looking at how we can build it as well
12759
09:00:47,638 --> 09:00:48,638
as we'll be going ahead and changing the
12760
09:00:49,680 --> 09:00:50,680
engine version on our existing project
12761
09:00:52,280 --> 09:00:53,280
so first of all as I mentioned at the
12762
09:00:55,920 --> 09:00:56,920
very start of the course make sure you
12763
09:00:57,780 --> 09:00:58,780
guys do get access to this repository
12764
09:01:00,600 --> 09:01:01,600
here
12765
09:01:01,620 --> 09:01:02,620
as of this date the release Branch
12766
09:01:04,080 --> 09:01:05,080
should have 5.1.0 and you should be able
12767
09:01:07,378 --> 09:01:08,378
to download the zip file over here so
12768
09:01:09,240 --> 09:01:10,240
download the zip
12769
09:01:12,660 --> 09:01:13,660
first of all uh especially when you're
12770
09:01:15,298 --> 09:01:16,298
installing unreal Source just to avoid
12771
09:01:18,600 --> 09:01:19,600
you know the permission issues which you
12772
09:01:20,340 --> 09:01:21,340
are going to get make sure you head into
12773
09:01:22,200 --> 09:01:23,200
your C drive
12774
09:01:23,580 --> 09:01:24,580
new folder and just create a folder
12775
09:01:26,218 --> 09:01:27,218
called unreal Source or something it
12776
09:01:28,798 --> 09:01:29,798
need not be the C drive just make sure
12777
09:01:31,318 --> 09:01:32,318
you do it in your SSD if you have one so
12778
09:01:35,340 --> 09:01:36,340
in my case it's the C drive so that's
12779
09:01:37,138 --> 09:01:38,138
the reason I'm doing it so I'll just go
12780
09:01:39,360 --> 09:01:40,360
ahead and install it there so go ahead
12781
09:01:41,398 --> 09:01:42,398
and extract the files
12782
09:01:43,740 --> 09:01:44,740
over here under C I'll go ahead and
12783
09:01:47,218 --> 09:01:48,218
browse the directory over there
12784
09:01:49,558 --> 09:01:50,558
so see unreal source
12785
09:01:53,340 --> 09:01:54,340
go ahead extract
12786
09:01:55,558 --> 09:01:56,558
and extract it under the directory and
12787
09:01:58,740 --> 09:01:59,740
hit OK
12788
09:02:03,180 --> 09:02:04,180
now we're just a few steps away in order
12789
09:02:05,940 --> 09:02:06,940
to install Unreal Engine so first of all
12790
09:02:08,878 --> 09:02:09,878
go ahead and run your setup batch file
12791
09:02:11,100 --> 09:02:12,100
and try to run it as an administrator
12792
09:02:13,740 --> 09:02:14,740
just to ensure it has all the
12793
09:02:15,660 --> 09:02:16,660
permissions for everything so run the
12794
09:02:17,580 --> 09:02:18,580
setup batch file as an admin
12795
09:02:19,680 --> 09:02:20,680
so something like this should show up
12796
09:02:21,660 --> 09:02:22,660
and once it's completed we'll head into
12797
09:02:24,000 --> 09:02:25,000
the next step
12798
09:02:26,218 --> 09:02:27,218
after the setup batch file has completed
12799
09:02:28,798 --> 09:02:29,798
running you can go ahead and run the
12800
09:02:30,718 --> 09:02:31,718
generate project
12801
09:02:32,360 --> 09:02:33,360
files.bat so this file is basically
12802
09:02:35,160 --> 09:02:36,160
going to generate your Visual Studio
12803
09:02:36,840 --> 09:02:37,840
solution so let's go ahead and run that
12804
09:02:39,298 --> 09:02:40,298
again try to run it as an administrator
12805
09:02:41,940 --> 09:02:42,940
it should work regardless but if you do
12806
09:02:44,160 --> 09:02:45,160
get any errors just run it as an admin
12807
09:02:46,860 --> 09:02:47,860
so you should see something like this
12808
09:02:48,660 --> 09:02:49,660
and this should complete relatively
12809
09:02:50,458 --> 09:02:51,458
quickly
12810
09:02:51,898 --> 09:02:52,898
at this point you should be able to see
12811
09:02:54,180 --> 09:02:55,180
our solution file so go ahead and open
12812
09:02:56,398 --> 09:02:57,398
it up once the solution is open and you
12813
09:02:59,520 --> 09:03:00,520
see ready over here at the bottom left
12814
09:03:01,740 --> 09:03:02,740
hand side what you should do is you
12815
09:03:04,500 --> 09:03:05,500
should go ahead and head into engine and
12816
09:03:06,840 --> 09:03:07,840
if it does ask you to install a few more
12817
09:03:08,878 --> 09:03:09,878
components in Visual Studio make sure
12818
09:03:10,798 --> 09:03:11,798
you just go ahead and do that just
12819
09:03:12,058 --> 09:03:13,058
follow along but in my case I've already
12820
09:03:14,580 --> 09:03:15,580
done that so I'm gonna go ahead right
12821
09:03:16,680 --> 09:03:17,680
click on you if I and click build
12822
09:03:19,200 --> 09:03:20,200
now once your build has succeeded
12823
09:03:22,080 --> 09:03:23,080
under your engine binaries when 64 you
12824
09:03:25,920 --> 09:03:26,920
should find unreal editor.exe so by
12825
09:03:29,580 --> 09:03:30,580
default the build configuration is set
12826
09:03:31,378 --> 09:03:32,378
to development editor if you don't see
12827
09:03:33,360 --> 09:03:34,360
this it means your build configuration
12828
09:03:35,580 --> 09:03:36,580
was probably something else and it
12829
09:03:37,318 --> 09:03:38,318
didn't get built so anyways let's go
12830
09:03:39,420 --> 09:03:40,420
ahead and open it up and our editor
12831
09:03:41,818 --> 09:03:42,818
should load up if we do get any errors
12832
09:03:43,500 --> 09:03:44,500
we can go ahead and debug it now
12833
09:03:46,680 --> 09:03:47,680
so everything seems to be working fine
12834
09:03:48,798 --> 09:03:49,798
and it is going to compile some shaders
12835
09:03:51,478 --> 09:03:52,478
once that's done I'll be right back
12836
09:03:53,520 --> 09:03:54,520
foreign
12837
09:04:02,360 --> 09:04:03,360
course project and now I'll show you
12838
09:04:05,160 --> 09:04:06,160
guys how to change the engine version so
12839
09:04:07,138 --> 09:04:08,138
headed your beginner course your project
12840
09:04:09,180 --> 09:04:10,180
file right click switch Unreal Engine
12841
09:04:11,760 --> 09:04:12,760
version and now you should see Source
12842
09:04:14,340 --> 09:04:15,340
build at whatever so basically I opened
12843
09:04:16,860 --> 09:04:17,860
and closed the editor that's it so
12844
09:04:19,020 --> 09:04:20,020
whatever we did there open unreal
12845
09:04:21,360 --> 09:04:22,360
editor.exe I just closed it immediately
12846
09:04:23,638 --> 09:04:24,638
and now I'm back to this location and
12847
09:04:25,860 --> 09:04:26,860
you should see this so if I hit OK it is
12848
09:04:28,500 --> 09:04:29,500
going to generate some Visual Studio
12849
09:04:30,120 --> 09:04:31,120
project files and unless something's
12850
09:04:33,420 --> 09:04:34,420
horribly wrong it should in theory work
12851
09:04:35,520 --> 09:04:36,520
out of the box
12852
09:04:37,340 --> 09:04:38,340
so that's about it and now you can go
12853
09:04:40,860 --> 09:04:41,860
ahead and just Build Your solution once
12854
09:04:43,200 --> 09:04:44,200
again because there may be a few API
12855
09:04:45,298 --> 09:04:46,298
changes which you might have to make so
12856
09:04:47,458 --> 09:04:48,458
those will be lifted and listed in the
12857
09:04:49,620 --> 09:04:50,620
output log and as well as in the release
12858
09:04:51,660 --> 09:04:52,660
notes and the documentation or whatnot
12859
09:04:54,718 --> 09:04:55,718
so head into your solution
12860
09:04:58,680 --> 09:04:59,680
now we have switched the Unreal Engine
12861
09:05:00,600 --> 09:05:01,600
version
12862
09:05:01,798 --> 09:05:02,798
so now we can go ahead and right click
12863
09:05:04,378 --> 09:05:05,378
on our beginner course and click on
12864
09:05:06,298 --> 09:05:07,298
build
12865
09:05:08,100 --> 09:05:09,100
foreign
12866
09:05:09,540 --> 09:05:10,540
so we get our first error here and this
12867
09:05:12,600 --> 09:05:13,600
is actually fairly common so basically
12868
09:05:15,120 --> 09:05:16,120
we have switched the Unreal Engine
12869
09:05:16,740 --> 09:05:17,740
version and we have a plug-in over here
12870
09:05:19,440 --> 09:05:20,440
which is based on the older version of
12871
09:05:22,318 --> 09:05:23,318
the engine there are two ways to fix it
12872
09:05:24,540 --> 09:05:25,540
one you can head into the marketplace
12873
09:05:26,760 --> 09:05:27,760
and reinstall the plugin which is meant
12874
09:05:29,458 --> 09:05:30,458
for 5.1 or I'll just show you guys the
12875
09:05:32,280 --> 09:05:33,280
way to do it without up using the
12876
09:05:34,440 --> 09:05:35,440
marketplace so in the marketplace it's
12877
09:05:36,058 --> 09:05:37,058
really easy you can just go ahead and
12878
09:05:37,378 --> 09:05:38,378
update the plugin but over here if you
12879
09:05:40,680 --> 09:05:41,680
really want to just use the same one
12880
09:05:43,080 --> 09:05:44,080
what you can do is you can head into
12881
09:05:45,120 --> 09:05:46,120
your engine installation directory so in
12882
09:05:47,760 --> 09:05:48,760
my case it is C unreal Source Unreal
12883
09:05:50,458 --> 09:05:51,458
Engine release engine
12884
09:05:52,318 --> 09:05:53,318
plugins
12885
09:05:54,020 --> 09:05:55,020
Marketplace uh it's not here because we
12886
09:05:57,898 --> 09:05:58,898
haven't yet installed so you'll find it
12887
09:05:59,638 --> 09:06:00,638
there so we'll go to our previous
12888
09:06:02,340 --> 09:06:03,340
installation program files Unreal Engine
12889
09:06:05,040 --> 09:06:06,040
this is where I had it
12890
09:06:06,660 --> 09:06:07,660
ue5.0 engine
12891
09:06:09,480 --> 09:06:10,480
plugins
12892
09:06:10,980 --> 09:06:11,980
and you should find Marketplace
12893
09:06:13,258 --> 09:06:14,258
and the one we are interested in is low
12894
09:06:15,540 --> 09:06:16,540
entry extended standard Library
12895
09:06:18,300 --> 09:06:19,300
you don't need to copy it to the engine
12896
09:06:20,520 --> 09:06:21,520
installation although you could what
12897
09:06:23,218 --> 09:06:24,218
I'll do is I'll just take it to the
12898
09:06:24,660 --> 09:06:25,660
plugins folder over here
12899
09:06:26,840 --> 09:06:27,840
so over here and under inside the U
12900
09:06:31,918 --> 09:06:32,918
plugin file we'll do the same
12901
09:06:33,418 --> 09:06:34,418
modifications
12902
09:06:35,520 --> 09:06:36,520
over here what we are going to do is
12903
09:06:38,040 --> 09:06:39,040
under the engine version we are going to
12904
09:06:40,622 --> 09:06:41,622
type in 5.1.0
12905
09:06:44,218 --> 09:06:45,218
and now if we go ahead and try to build
12906
09:06:46,980 --> 09:06:47,980
this once again
12907
09:06:48,480 --> 09:06:49,480
we shouldn't get that error hopefully
12908
09:06:52,558 --> 09:06:53,558
so it will take a while and if we do get
12909
09:06:56,340 --> 09:06:57,340
any errors we'll go ahead and change it
12910
09:06:59,040 --> 09:07:00,040
or fix those
12911
09:07:03,960 --> 09:07:04,960
so we have a few errors here and these
12912
09:07:07,438 --> 09:07:08,438
are mostly the changes which came
12913
09:07:10,738 --> 09:07:11,738
according to the documentation due to
12914
09:07:12,898 --> 09:07:13,898
the platform SDK upgrades but it's not
12915
09:07:16,140 --> 09:07:17,140
really a problem
12916
09:07:17,340 --> 09:07:18,340
so because I don't think any of you guys
12917
09:07:20,840 --> 09:07:21,840
unless you guys work for a triple a
12918
09:07:23,578 --> 09:07:24,578
studio or something I don't think you'll
12919
09:07:25,078 --> 09:07:26,078
be using this and this is from the
12920
09:07:26,758 --> 09:07:27,758
plugin this is not something in the
12921
09:07:28,378 --> 09:07:29,378
engine so nothing to worry so what I can
12922
09:07:30,480 --> 09:07:31,480
do is we can simply just delete this
12923
09:07:32,040 --> 09:07:33,040
code and just to return false
12924
09:07:34,680 --> 09:07:35,680
and even for the Xbox one so we can just
12925
09:07:37,980 --> 09:07:38,980
do the same thing
12926
09:07:39,558 --> 09:07:40,558
and I'll tell you guys which file this
12927
09:07:42,238 --> 09:07:43,238
is it's basically this file right here
12928
09:07:44,398 --> 09:07:45,398
so in the error list you see platform
12929
09:07:47,282 --> 09:07:48,282
PS4 whatever so just head into that just
12930
09:07:50,938 --> 09:07:51,938
double click on that and you will reach
12931
09:07:53,640 --> 09:07:54,640
there
12932
09:07:54,598 --> 09:07:55,598
and over here as well
12933
09:07:57,180 --> 09:07:58,180
so line 264
12934
09:08:00,540 --> 09:08:01,540
so I feel like
12935
09:08:03,000 --> 09:08:04,000
this was it so before changing it was in
12936
09:08:05,938 --> 09:08:06,938
line to 64. so now it's gone a bit up
12937
09:08:09,500 --> 09:08:10,500
anyways let's try building this once
12938
09:08:11,820 --> 09:08:12,820
again
12939
09:08:14,340 --> 09:08:15,340
and as you can see the build has indeed
12940
09:08:17,218 --> 09:08:18,218
succeeded but once the plugin actually
12941
09:08:20,398 --> 09:08:21,398
comes for 5.1 what you can basically do
12942
09:08:22,980 --> 09:08:23,980
is install 5.1 here like in the epic
12943
09:08:25,622 --> 09:08:26,622
games launcher install the plugin from
12944
09:08:28,078 --> 09:08:29,078
the marketplace and then you can go
12945
09:08:30,418 --> 09:08:31,418
ahead and copy that into the plugins
12946
09:08:32,700 --> 09:08:33,700
folder in the engine level
12947
09:08:34,800 --> 09:08:35,800
so what you would do is you would have
12948
09:08:37,020 --> 09:08:38,020
it over here so see unreal Source
12949
09:08:39,960 --> 09:08:40,960
release
12950
09:08:41,480 --> 09:08:42,480
an engine plugins
12951
09:08:44,938 --> 09:08:45,938
over here you would create a new folder
12952
09:08:47,098 --> 09:08:48,098
called Marketplace or something and then
12953
09:08:48,898 --> 09:08:49,898
you would like just copy it in
12954
09:08:50,820 --> 09:08:51,820
anyways we are not really worried about
12955
09:08:53,040 --> 09:08:54,040
that right now
12956
09:08:54,660 --> 09:08:55,660
now what we can do is now that it's
12957
09:08:56,640 --> 09:08:57,640
built successfully we can go ahead and
12958
09:08:59,040 --> 09:09:00,040
run a debugger and we should be able to
12959
09:09:01,078 --> 09:09:02,078
run this in 5.1 so I did show you guys
12960
09:09:03,782 --> 09:09:04,782
multiple things so the errors which you
12961
09:09:06,840 --> 09:09:07,840
get will actually depend on what plugins
12962
09:09:09,598 --> 09:09:10,598
you're using and how's your code base
12963
09:09:12,598 --> 09:09:13,598
and what changes are made to the engines
12964
09:09:16,558 --> 09:09:17,558
API itself
12965
09:09:18,122 --> 09:09:19,122
so depending on that you'll have to look
12966
09:09:20,460 --> 09:09:21,460
at the output log and the error list and
12967
09:09:22,622 --> 09:09:23,622
do something and there are a few
12968
09:09:24,480 --> 09:09:25,480
deprecation warnings as well so if you
12969
09:09:26,878 --> 09:09:27,878
just have a look
12970
09:09:29,098 --> 09:09:30,098
so I'm not really sure
12971
09:09:31,438 --> 09:09:32,438
what this is but this will probably be
12972
09:09:34,558 --> 09:09:35,558
changed soon once the plugin is updated
12973
09:09:36,840 --> 09:09:37,840
but right now I'm not really worried
12974
09:09:39,122 --> 09:09:40,122
since it's just a warning so now I can
12975
09:09:41,520 --> 09:09:42,520
go ahead and run a debugger
12976
09:09:45,122 --> 09:09:46,122
all right so our project has opened
12977
09:09:48,058 --> 09:09:49,058
successfully and it is prompting us to
12978
09:09:50,578 --> 09:09:51,578
change a few project settings in order
12979
09:09:52,438 --> 09:09:53,438
to actually use Virtual Shadow maps and
12980
09:09:55,500 --> 09:09:56,500
nanite so that's not really an issue we
12981
09:09:58,200 --> 09:09:59,200
can head into the project settings
12982
09:10:00,360 --> 09:10:01,360
uh and over here
12983
09:10:03,360 --> 09:10:04,360
under it should in theory
12984
09:10:06,598 --> 09:10:07,598
be here so platforms
12985
09:10:10,438 --> 09:10:11,438
so let's just search for platforms
12986
09:10:13,918 --> 09:10:14,918
it'll be under any one of these so
12987
09:10:17,598 --> 09:10:18,598
platforms
12988
09:10:19,200 --> 09:10:20,200
windows
12989
09:10:20,758 --> 09:10:21,758
and you can go ahead and enable Shader
12990
09:10:23,578 --> 09:10:24,578
Model 6.
12991
09:10:27,258 --> 09:10:28,258
and over here we can go ahead and
12992
09:10:31,820 --> 09:10:32,820
I don't think we'll require Shader Model
12993
09:10:34,200 --> 09:10:35,200
5 so that should be about it and now you
12994
09:10:37,680 --> 09:10:38,680
can go ahead and restart the editor all
12995
09:10:40,378 --> 09:10:41,378
right so now I've restarted the editor
12996
09:10:42,418 --> 09:10:43,418
and now we are using Unreal 5.1 so
12997
09:10:45,960 --> 09:10:46,960
that's about it for installing the
12998
09:10:48,058 --> 09:10:49,058
source and changing your engine version
12999
09:10:50,040 --> 09:10:51,040
now there are a few more ways you can
13000
09:10:52,738 --> 09:10:53,738
handle some of the things such as the
13001
09:10:54,480 --> 09:10:55,480
plugin part but on the whole this is how
13002
09:10:58,140 --> 09:10:59,140
you do it and if you do want any more
13003
09:11:00,660 --> 09:11:01,660
specific references you always have the
13004
09:11:02,640 --> 09:11:03,640
documentation which you can refer and
13005
09:11:04,680 --> 09:11:05,680
the release notes are maybe the unreal
13006
09:11:06,840 --> 09:11:07,840
Slackers Discord server so that's about
13007
09:11:09,418 --> 09:11:10,418
it
13008
09:11:10,438 --> 09:11:11,438
foreign
13009
09:11:16,282 --> 09:11:17,282
ly inside the last section of this
13010
09:11:19,378 --> 09:11:20,378
course and obviously it is about how to
13011
09:11:22,558 --> 09:11:23,558
package your game
13012
09:11:23,878 --> 09:11:24,878
so it used to be very simple before so
13013
09:11:27,180 --> 09:11:28,180
you just go file package project but now
13014
09:11:30,598 --> 09:11:31,598
it will probably have to just do it
13015
09:11:32,578 --> 09:11:33,578
through the project launcher which I
13016
09:11:34,258 --> 09:11:35,258
will show you guys it's really simple so
13017
09:11:36,360 --> 09:11:37,360
head into tools project launcher
13018
09:11:39,438 --> 09:11:40,438
and you can use this but I'm going to be
13019
09:11:42,898 --> 09:11:43,898
using a custom launch profile
13020
09:11:45,300 --> 09:11:46,300
so go ahead and add
13021
09:11:47,578 --> 09:11:48,578
create a custom profile
13022
09:11:49,738 --> 09:11:50,738
and I'll just walk you guys through each
13023
09:11:51,718 --> 09:11:52,718
option you can give a name to this
13024
09:11:53,160 --> 09:11:54,160
profile let's say this is for testing
13025
09:11:55,558 --> 09:11:56,558
let's hit uh you are building this for
13026
09:11:58,320 --> 09:11:59,320
testing so you can name this profile
13027
09:11:59,758 --> 09:12:00,758
testing you can reuse this profile for
13028
09:12:02,398 --> 09:12:03,398
the next time when you package the game
13029
09:12:04,140 --> 09:12:05,140
as well packaging basically means you
13030
09:12:06,540 --> 09:12:07,540
make your game or you turn your game
13031
09:12:08,460 --> 09:12:09,460
into an executable basically
13032
09:12:11,058 --> 09:12:12,058
now project is going to be beginner
13033
09:12:13,500 --> 09:12:14,500
course of course and build configuration
13034
09:12:17,098 --> 09:12:18,098
so debug and development will be used
13035
09:12:21,360 --> 09:12:22,360
when you're actually you know testing
13036
09:12:23,398 --> 09:12:24,398
out your game and you're still not yet
13037
09:12:26,218 --> 09:12:27,218
at a stage where you can
13038
09:12:28,800 --> 09:12:29,800
uh send it to other people so your print
13039
09:12:31,558 --> 09:12:32,558
strings and stuff are gonna work but
13040
09:12:34,200 --> 09:12:35,200
under shipping uh none of your print
13041
09:12:37,078 --> 09:12:38,078
strings and stuff will work but it will
13042
09:12:39,122 --> 09:12:40,122
take a bit longer to build
13043
09:12:41,040 --> 09:12:42,040
and testing is somewhere in between
13044
09:12:44,300 --> 09:12:45,300
debug development and shipping so it's
13045
09:12:48,238 --> 09:12:49,238
below shipping but it's above
13046
09:12:50,700 --> 09:12:51,700
development and debug basically
13047
09:12:53,520 --> 09:12:54,520
so you can select any one of these I
13048
09:12:56,160 --> 09:12:57,160
I'll just select shipping
13049
09:12:58,340 --> 09:12:59,340
and here these are settings you don't
13050
09:13:01,320 --> 09:13:02,320
need to worry about and about cooking
13051
09:13:04,680 --> 09:13:05,680
the content you can do either on the fly
13052
09:13:07,098 --> 09:13:08,098
or buy the book
13053
09:13:09,718 --> 09:13:10,718
uh basically what on the Fly uh and buy
13054
09:13:14,938 --> 09:13:15,938
the book is going to differ in is
13055
09:13:17,160 --> 09:13:18,160
basically if you do buy the book
13056
09:13:18,782 --> 09:13:19,782
everything is going to be cooked uh
13057
09:13:22,438 --> 09:13:23,438
beforehand basically so if you if you're
13058
09:13:25,200 --> 09:13:26,200
packaging your game for shipping most of
13059
09:13:27,058 --> 09:13:28,058
the times you will have buy the book
13060
09:13:29,300 --> 09:13:30,300
and you would select windows
13061
09:13:33,418 --> 09:13:34,418
if you're developing a Windows game
13062
09:13:35,218 --> 09:13:36,218
obviously if you have anything else
13063
09:13:37,200 --> 09:13:38,200
let's say you're making an Android game
13064
09:13:38,820 --> 09:13:39,820
you would select Android and stuff like
13065
09:13:40,378 --> 09:13:41,378
that and undercook cultures you'll find
13066
09:13:43,800 --> 09:13:44,800
English somewhere here so en it should
13067
09:13:46,860 --> 09:13:47,860
be selected by default so en
13068
09:13:49,558 --> 09:13:50,558
and you can select your Maps which
13069
09:13:53,160 --> 09:13:54,160
you want to cook so we're using all so
13070
09:13:55,320 --> 09:13:56,320
we'll just select all but you can choose
13071
09:13:57,418 --> 09:13:58,418
to cook only
13072
09:13:58,980 --> 09:13:59,980
selected Maps but note that if you don't
13073
09:14:02,340 --> 09:14:03,340
cook a certain map you won't be able to
13074
09:14:04,800 --> 09:14:05,800
open it in game you're going to get
13075
09:14:06,480 --> 09:14:07,480
errors your game will probably crash now
13076
09:14:09,360 --> 09:14:10,360
that's one thing to note now the release
13077
09:14:11,758 --> 09:14:12,758
DLC patching settings these are some
13078
09:14:14,218 --> 09:14:15,218
things which I'll not go over and under
13079
09:14:16,800 --> 09:14:17,800
advanced settings as well so you can go
13080
09:14:20,340 --> 09:14:21,340
ahead and mess with these
13081
09:14:22,438 --> 09:14:23,438
so
13082
09:14:24,000 --> 09:14:25,000
you can enable this
13083
09:14:26,282 --> 09:14:27,282
if you want all the content to go in a
13084
09:14:29,520 --> 09:14:30,520
single dot pack file
13085
09:14:31,800 --> 09:14:32,800
stuff like that
13086
09:14:33,558 --> 09:14:34,558
and everything is pretty
13087
09:14:35,520 --> 09:14:36,520
self-explanatory
13088
09:14:38,040 --> 09:14:39,040
next package package and store locally
13089
09:14:42,418 --> 09:14:43,418
then you can go ahead and give it a path
13090
09:14:44,340 --> 09:14:45,340
so generally I'd like to do it in the
13091
09:14:46,738 --> 09:14:47,738
project location
13092
09:14:48,360 --> 09:14:49,360
saved and I'd like to create a folder
13093
09:14:51,238 --> 09:14:52,238
called staged builds
13094
09:14:53,398 --> 09:14:54,398
staged builds have used the project
13095
09:14:56,640 --> 09:14:57,640
launcher in the in the older versions
13096
09:14:58,680 --> 09:14:59,680
you probably already know what this is
13097
09:15:00,898 --> 09:15:01,898
and is this just is this build for
13098
09:15:03,238 --> 09:15:04,238
distribution to the public we have
13099
09:15:04,860 --> 09:15:05,860
selected shipping so I would assume it
13100
09:15:07,200 --> 09:15:08,200
is of course it's again your preference
13101
09:15:10,438 --> 09:15:11,438
do you wish to Archive
13102
09:15:12,840 --> 09:15:13,840
can select yes or no doesn't really
13103
09:15:16,140 --> 09:15:17,140
matter
13104
09:15:17,238 --> 09:15:18,238
and deploy we can select do not deploy
13105
09:15:21,540 --> 09:15:22,540
because we aren't actually launching the
13106
09:15:23,578 --> 09:15:24,578
game
13107
09:15:24,660 --> 09:15:25,660
so if we select do not deploy basically
13108
09:15:27,960 --> 09:15:28,960
you can launch it through the executable
13109
09:15:29,820 --> 09:15:30,820
itself
13110
09:15:31,078 --> 09:15:32,078
so once that's done you can head back
13111
09:15:32,758 --> 09:15:33,758
and you can click on launch this profile
13112
09:15:38,160 --> 09:15:39,160
so now once everything has been
13113
09:15:40,020 --> 09:15:41,020
completed you can head into the
13114
09:15:41,460 --> 09:15:42,460
directory over there you should find a
13115
09:15:43,200 --> 09:15:44,200
Windows folder and you should find your
13116
09:15:45,360 --> 09:15:46,360
executable right there so open it up and
13117
09:15:48,122 --> 09:15:49,122
you should launch your game
13118
09:15:50,098 --> 09:15:51,098
so we will end up in this map right here
13119
09:15:54,000 --> 09:15:55,000
again you can change your project
13120
09:15:55,918 --> 09:15:56,918
settings and you can change the default
13121
09:15:58,078 --> 09:15:59,078
map but anyways our purpose here was to
13122
09:16:01,258 --> 09:16:02,258
check if the game packages and
13123
09:16:02,938 --> 09:16:03,938
everything seems to be working the
13124
09:16:04,918 --> 09:16:05,918
physics simulation works and so on
13125
09:16:08,460 --> 09:16:09,460
so that's pretty much it
13126
09:16:14,949 --> 09:16:15,949
[Music]
13127
09:16:19,980 --> 09:16:20,980
okay guys so this is going to be the
13128
09:16:23,098 --> 09:16:24,098
last segment of the course as you guys
13129
09:16:24,782 --> 09:16:25,782
would know and I hope you guys would
13130
09:16:27,960 --> 09:16:28,960
have enjoyed the course till now and
13131
09:16:30,598 --> 09:16:31,598
congratulations if you have completed
13132
09:16:32,398 --> 09:16:33,398
the course still here
13133
09:16:33,898 --> 09:16:34,898
and the further part is going to be
13134
09:16:37,258 --> 09:16:38,258
two hours of me creating an entire game
13135
09:16:40,020 --> 09:16:41,020
so hopefully you guys will enjoy it uh
13136
09:16:43,078 --> 09:16:44,078
see you in the engine
13137
09:16:44,520 --> 09:16:45,520
alright guys so this is the last section
13138
09:16:47,640 --> 09:16:48,640
of the course and this is not actually
13139
09:16:49,500 --> 09:16:50,500
going to be about you know learning
13140
09:16:51,718 --> 09:16:52,718
anything new however in this part I will
13141
09:16:55,140 --> 09:16:56,140
be live demonstrating without any Cuts
13142
09:16:57,960 --> 09:16:58,960
how to make an endless Runner such as
13143
09:17:00,660 --> 09:17:01,660
Temple Run or Subway Surfers or any
13144
09:17:03,718 --> 09:17:04,718
other which you might have played
13145
09:17:05,938 --> 09:17:06,938
so we'll be taking the most simple
13146
09:17:08,700 --> 09:17:09,700
approach or at least as far as my
13147
09:17:12,000 --> 09:17:13,000
knowledge is concerned if you do have
13148
09:17:13,622 --> 09:17:14,622
anything simpler you can let me know in
13149
09:17:15,238 --> 09:17:16,238
the comments
13150
09:17:16,340 --> 09:17:17,340
and hopefully within an hour we'll be
13151
09:17:19,378 --> 09:17:20,378
able to make the whole game with the
13152
09:17:21,360 --> 09:17:22,360
menu animations and all that kind of
13153
09:17:23,640 --> 09:17:24,640
good stuff
13154
09:17:24,660 --> 09:17:25,660
so let's get started so let me actually
13155
09:17:28,078 --> 09:17:29,078
have a stopwatch here so that we have
13156
09:17:30,000 --> 09:17:31,000
track of our time
13157
09:17:32,578 --> 09:17:33,578
so I'll just create a game it's going to
13158
09:17:35,218 --> 09:17:36,218
be third person because we'll have the
13159
09:17:37,438 --> 09:17:38,438
animation blueprint and stuff but
13160
09:17:39,598 --> 09:17:40,598
anyways I don't think we'll be using
13161
09:17:41,282 --> 09:17:42,282
that not to worry uh we'll go with blank
13162
09:17:44,098 --> 09:17:45,098
actually
13163
09:17:44,820 --> 09:17:45,820
C plus plus and we'll call this one
13164
09:17:47,640 --> 09:17:48,640
endless Runner
13165
09:17:52,140 --> 09:17:53,140
create it
13166
09:17:54,660 --> 09:17:55,660
now this will take a little bit of time
13167
09:17:59,098 --> 09:18:00,098
and I do have a couple of things being
13168
09:18:01,438 --> 09:18:02,438
installed in the background and I also
13169
09:18:03,660 --> 09:18:04,660
have a list of plugins that I'll be
13170
09:18:05,460 --> 09:18:06,460
using
13171
09:18:06,418 --> 09:18:07,418
so you guys will have a pretty good idea
13172
09:18:08,640 --> 09:18:09,640
of what will actually do with plugins
13173
09:18:11,758 --> 09:18:12,758
and stuff because in the course I think
13174
09:18:14,820 --> 09:18:15,820
I just went over these briefly but I
13175
09:18:17,460 --> 09:18:18,460
went in depth about how to actually
13176
09:18:19,378 --> 09:18:20,378
create your own plugins and stuff
13177
09:18:21,718 --> 09:18:22,718
anyways so our project will be created
13178
09:18:25,320 --> 09:18:26,320
soon
13179
09:18:26,340 --> 09:18:27,340
and this will compile so until then we
13180
09:18:29,820 --> 09:18:30,820
can go ahead and open up our epic games
13181
09:18:31,320 --> 09:18:32,320
launcher
13182
09:18:32,700 --> 09:18:33,700
head into Library
13183
09:18:34,680 --> 09:18:35,680
and we can close this editor for now
13184
09:18:37,258 --> 09:18:38,258
until we add everything
13185
09:18:40,438 --> 09:18:41,438
so what I what I'll do is I'll go ahead
13186
09:18:42,360 --> 09:18:43,360
and search these one by one so City
13187
09:18:44,640 --> 09:18:45,640
subway tunnel
13188
09:18:47,520 --> 09:18:48,520
so I have to create a separate project
13189
09:18:49,738 --> 09:18:50,738
for this not going to go over that right
13190
09:18:51,480 --> 09:18:52,480
now
13191
09:18:52,378 --> 09:18:53,378
so we'll go construction volume
13192
09:18:55,140 --> 09:18:56,140
so volume 1 and volume 2 will go ahead
13193
09:18:57,480 --> 09:18:58,480
and add this to endless Runner we'll add
13194
09:18:59,938 --> 09:19:00,938
this to endless Runner I'll CL I'll
13195
09:19:01,918 --> 09:19:02,918
clear the cache later it's just taking
13196
09:19:03,660 --> 09:19:04,660
up storage
13197
09:19:04,918 --> 09:19:05,918
and we want Ellie extended so early
13198
09:19:07,738 --> 09:19:08,738
extend it
13199
09:19:10,320 --> 09:19:11,320
so we have already installed it to 5.0.3
13200
09:19:13,140 --> 09:19:14,140
so nothing to worry about there
13201
09:19:15,540 --> 09:19:16,540
so Adventure character whoops
13202
09:19:20,400 --> 09:19:21,400
so this will be the character which
13203
09:19:22,080 --> 09:19:23,080
we'll be using and it's going to be
13204
09:19:23,580 --> 09:19:24,580
hella fun
13205
09:19:25,080 --> 09:19:26,080
ah we don't have time to actually model
13206
09:19:27,480 --> 09:19:28,480
our own character that's the reason we
13207
09:19:29,220 --> 09:19:30,220
are doing this so I'll just go over this
13208
09:19:30,660 --> 09:19:31,660
real quick so FX variety pack
13209
09:19:33,660 --> 09:19:34,660
not sure if we will get the effect we
13210
09:19:36,120 --> 09:19:37,120
need but I'll just add it just in case
13211
09:19:39,480 --> 09:19:40,480
okay I need to download it yet so we're
13212
09:19:41,880 --> 09:19:42,880
not gonna do that now so window dialog
13213
09:19:44,280 --> 09:19:45,280
box
13214
09:19:46,740 --> 09:19:47,740
so I've already installed it
13215
09:19:50,820 --> 09:19:51,820
so these two
13216
09:19:52,980 --> 09:19:53,980
so we'll use this for obstacles and
13217
09:19:55,080 --> 09:19:56,080
stuff
13218
09:19:58,580 --> 09:19:59,580
and lastly we'll just have some trees
13219
09:20:01,320 --> 09:20:02,320
maybe at the side we could have
13220
09:20:02,700 --> 09:20:03,700
something
13221
09:20:05,280 --> 09:20:06,280
Stone Pine Forest
13222
09:20:09,300 --> 09:20:10,300
and go ahead and add it once everything
13223
09:20:12,120 --> 09:20:13,120
is complete
13224
09:20:13,980 --> 09:20:14,980
now depending on your system if you have
13225
09:20:16,380 --> 09:20:17,380
a hard drive or something this process
13226
09:20:17,936 --> 09:20:18,936
is going to be a little bit slow so this
13227
09:20:20,756 --> 09:20:21,756
is under my unreal project endless
13228
09:20:23,280 --> 09:20:24,280
Runner so we'll be using the file
13229
09:20:25,320 --> 09:20:26,320
explorer for this and I'll just delete
13230
09:20:27,416 --> 09:20:28,416
this later on
13231
09:20:31,256 --> 09:20:32,256
so now once the engine is loaded up we
13232
09:20:33,660 --> 09:20:34,660
can start making our game and we'll go
13233
09:20:36,540 --> 09:20:37,540
ahead and create a Maps folder first so
13234
09:20:38,400 --> 09:20:39,400
right click Maps will have only one and
13235
09:20:41,936 --> 09:20:42,936
all the obstacles will be spawned at
13236
09:20:44,460 --> 09:20:45,460
runtime dynamically when you're playing
13237
09:20:46,080 --> 09:20:47,080
the game so we don't really care about
13238
09:20:48,720 --> 09:20:49,720
having multiple Maps but we'll have two
13239
09:20:50,640 --> 09:20:51,640
so one is going to be your main menu
13240
09:20:53,936 --> 09:20:54,936
and the other one is going to be the
13241
09:20:56,756 --> 09:20:57,756
actual map
13242
09:20:57,780 --> 09:20:58,780
so I'll go ahead and create the map and
13243
09:21:00,596 --> 09:21:01,596
I'll call this one game map
13244
09:21:04,256 --> 09:21:05,256
all right save that and go ahead and
13245
09:21:06,960 --> 09:21:07,960
open the main menu head into project
13246
09:21:08,880 --> 09:21:09,880
settings and just change that as well so
13247
09:21:11,640 --> 09:21:12,640
under your maps and modes you should
13248
09:21:14,220 --> 09:21:15,220
have open world we'll change that to
13249
09:21:16,740 --> 09:21:17,740
main menu
13250
09:21:17,640 --> 09:21:18,640
so editor startup map will be main menu
13251
09:21:19,860 --> 09:21:20,860
and it's going to be main menu again
13252
09:21:23,096 --> 09:21:24,096
so editor we can start with our game map
13253
09:21:25,200 --> 09:21:26,200
actually
13254
09:21:26,880 --> 09:21:27,880
but the game has to start from main menu
13255
09:21:29,640 --> 09:21:30,640
so
13256
09:21:31,436 --> 09:21:32,436
just go ahead and click import doesn't
13257
09:21:34,436 --> 09:21:35,436
really matter
13258
09:21:37,980 --> 09:21:38,980
all right
13259
09:21:39,560 --> 09:21:40,560
now over here we can start making our
13260
09:21:42,660 --> 09:21:43,660
main menu so right click create a new
13261
09:21:45,000 --> 09:21:46,000
folder and we'll call this one content
13262
09:21:47,160 --> 09:21:48,160
once again
13263
09:21:48,720 --> 09:21:49,720
and inside this will actually create
13264
09:21:50,700 --> 09:21:51,700
stuff because the main content folder is
13265
09:21:52,800 --> 09:21:53,800
a bit clogged up
13266
09:21:54,540 --> 09:21:55,540
so we'll call this one UI and we can
13267
09:21:56,520 --> 09:21:57,520
create a main menu right click user
13268
09:21:58,320 --> 09:21:59,320
interface widget blueprint create a user
13269
09:22:00,780 --> 09:22:01,780
widget and we'll call this one main menu
13270
09:22:02,880 --> 09:22:03,880
or BP underscore main menu
13271
09:22:07,460 --> 09:22:08,460
and we'll suffix that with a WB to
13272
09:22:11,160 --> 09:22:12,160
indicate it's a widget
13273
09:22:12,840 --> 09:22:13,840
and it's going to be just quick and
13274
09:22:14,580 --> 09:22:15,580
dirty so we'll add a canvas panel here
13275
09:22:17,460 --> 09:22:18,460
and at the center we'll just have a
13276
09:22:20,096 --> 09:22:21,096
start button and an exit button so we'll
13277
09:22:22,436 --> 09:22:23,436
add in a vertical box
13278
09:22:24,960 --> 09:22:25,960
so vertical box
13279
09:22:27,060 --> 09:22:28,060
and over here we can go ahead and make
13280
09:22:30,720 --> 09:22:31,720
this Center aligned first of all
13281
09:22:33,000 --> 09:22:34,000
Center align position zero
13282
09:22:36,060 --> 09:22:37,060
with 0.5 for the alignment value so this
13283
09:22:39,660 --> 09:22:40,660
is going to make sure everything is
13284
09:22:41,160 --> 09:22:42,160
centered we can go ahead and increase
13285
09:22:43,256 --> 09:22:44,256
the size a bit
13286
09:22:45,000 --> 09:22:46,000
even vertically
13287
09:22:46,980 --> 09:22:47,980
and we can go ahead and add in two
13288
09:22:48,840 --> 09:22:49,840
buttons so button one
13289
09:22:51,180 --> 09:22:52,180
and Ctrl D to duplicate
13290
09:22:53,756 --> 09:22:54,756
we'll make it so that it fills it and we
13291
09:22:56,400 --> 09:22:57,400
obviously want the play button to be
13292
09:22:58,080 --> 09:22:59,080
bigger we don't want our users to exit
13293
09:23:00,120 --> 09:23:01,120
the game
13294
09:23:01,380 --> 09:23:02,380
anyways we'll add in the the text here
13295
09:23:04,680 --> 09:23:05,680
so add in some text add in some text and
13296
09:23:07,916 --> 09:23:08,916
change the background color for both of
13297
09:23:09,540 --> 09:23:10,540
these buttons make it almost black
13298
09:23:13,020 --> 09:23:14,020
maybe not exactly black but almost
13299
09:23:16,560 --> 09:23:17,560
so I like this shade of color
13300
09:23:19,080 --> 09:23:20,080
now rename this to play
13301
09:23:22,320 --> 09:23:23,320
or rather start we can try
13302
09:23:25,800 --> 09:23:26,800
change the font maybe so the font we'll
13303
09:23:29,096 --> 09:23:30,096
use is going to be the light one
13304
09:23:31,680 --> 09:23:32,680
so 40 seems about right
13305
09:23:35,096 --> 09:23:36,096
make this one 40 as well and this one is
13306
09:23:37,916 --> 09:23:38,916
going to be light and this one is going
13307
09:23:40,200 --> 09:23:41,200
to be exit
13308
09:23:41,756 --> 09:23:42,756
so we can add the functionality as well
13309
09:23:43,860 --> 09:23:44,860
because this is pretty simple so on this
13310
09:23:46,680 --> 09:23:47,680
button we'll rename this to exit button
13311
09:23:49,140 --> 09:23:50,140
or it's really not required I guess
13312
09:23:51,960 --> 09:23:52,960
so on click
13313
09:23:54,240 --> 09:23:55,240
and for this one as well we are going to
13314
09:23:56,700 --> 09:23:57,700
add a non-click this is the start button
13315
09:23:58,800 --> 09:23:59,800
so I'll just comment this out
13316
09:24:01,680 --> 09:24:02,680
and for this we can go ahead and execute
13317
09:24:04,020 --> 09:24:05,020
console command and we can type in exit
13318
09:24:07,380 --> 09:24:08,380
now our exit button should work we can
13319
09:24:09,660 --> 09:24:10,660
go ahead and test that first of all we
13320
09:24:11,820 --> 09:24:12,820
haven't even created the widget so under
13321
09:24:13,980 --> 09:24:14,980
content we will go ahead and create a
13322
09:24:17,340 --> 09:24:18,340
new folder and call this one blueprints
13323
09:24:21,060 --> 09:24:22,060
and we'll have two subfolders here we'll
13324
09:24:23,400 --> 09:24:24,400
call one as game and the another one as
13325
09:24:25,560 --> 09:24:26,560
main menu because we'll have different
13326
09:24:27,540 --> 09:24:28,540
player controllers and stuff for the
13327
09:24:29,276 --> 09:24:30,276
main menu and the actual game so under
13328
09:24:31,560 --> 09:24:32,560
main menu right click go ahead and head
13329
09:24:34,256 --> 09:24:35,256
into blueprint class and create a player
13330
09:24:36,240 --> 09:24:37,240
controller
13331
09:24:37,500 --> 09:24:38,500
and we'll call this one BP
13332
09:24:40,860 --> 09:24:41,860
main menu
13333
09:24:42,480 --> 09:24:43,480
player controller so this is basically
13334
09:24:45,000 --> 09:24:46,000
for you know creating the widgets and
13335
09:24:46,860 --> 09:24:47,860
stuff we'll just use the play controller
13336
09:24:49,560 --> 09:24:50,560
now under the event graph we can just do
13337
09:24:51,840 --> 09:24:52,840
it on begin play so we'll create a
13338
09:24:54,120 --> 09:24:55,120
custom event custom event
13339
09:24:56,160 --> 09:24:57,160
create main menu
13340
09:25:00,680 --> 09:25:01,680
and create a widget
13341
09:25:04,436 --> 09:25:05,436
it's going to be BP main menu widget
13342
09:25:06,960 --> 09:25:07,960
blueprint and add this to the viewport
13343
09:25:09,060 --> 09:25:10,060
now we I don't think we really need the
13344
09:25:12,000 --> 09:25:13,000
reference but we'll just store a
13345
09:25:13,740 --> 09:25:14,740
reference to it anyways so
13346
09:25:16,140 --> 09:25:17,140
main menu widget blueprint we'll just
13347
09:25:19,140 --> 09:25:20,140
have a reference to it
13348
09:25:20,936 --> 09:25:21,936
and from this we can go ahead and add it
13349
09:25:22,980 --> 09:25:23,980
to the viewport
13350
09:25:25,020 --> 09:25:26,020
all right and on begin play we can
13351
09:25:27,120 --> 09:25:28,120
create the widget so create widget or
13352
09:25:30,180 --> 09:25:31,180
rather create main menu is the function
13353
09:25:31,800 --> 09:25:32,800
name
13354
09:25:33,000 --> 09:25:34,000
so create main menu
13355
09:25:36,120 --> 09:25:37,120
and now if I compile save it go ahead
13356
09:25:38,400 --> 09:25:39,400
and press play
13357
09:25:39,720 --> 09:25:40,720
as you can see nothing happens because
13358
09:25:41,340 --> 09:25:42,340
we haven't changed the game mode yet so
13359
09:25:43,140 --> 09:25:44,140
over here we'll create a new game mode
13360
09:25:44,660 --> 09:25:45,660
so go ahead all classes
13361
09:25:48,300 --> 09:25:49,300
game mode so we'll create a game mode
13362
09:25:50,580 --> 09:25:51,580
base
13363
09:25:51,416 --> 09:25:52,416
so we'll call this one
13364
09:25:53,096 --> 09:25:54,096
BP underscore main menu game mode
13365
09:25:58,436 --> 09:25:59,436
now under your world settings go ahead
13366
09:26:00,660 --> 09:26:01,660
and change your game mode to BP Main
13367
09:26:02,936 --> 09:26:03,936
menu game mode
13368
09:26:04,320 --> 09:26:05,320
and over here the player controller can
13369
09:26:06,120 --> 09:26:07,120
be our BP main menu player controller
13370
09:26:09,180 --> 09:26:10,180
and now if I go ahead and press play we
13371
09:26:11,096 --> 09:26:12,096
should get a button start won't do
13372
09:26:12,660 --> 09:26:13,660
anything but exit is going to work
13373
09:26:15,596 --> 09:26:16,596
now let's actually head into our game
13374
09:26:17,756 --> 09:26:18,756
map here so Maps game map will worry
13375
09:26:21,180 --> 09:26:22,180
about the main menu a bit later so we
13376
09:26:23,096 --> 09:26:24,096
are in the game up we can go ahead and
13377
09:26:25,200 --> 09:26:26,200
add our sky so Sky atmosphere Skylight
13378
09:26:28,560 --> 09:26:29,560
and we can add in our directional light
13379
09:26:32,220 --> 09:26:33,220
we can also have a fog so we can have
13380
09:26:35,820 --> 09:26:36,820
exponential height fog and we have
13381
09:26:38,040 --> 09:26:39,040
everything set up
13382
09:26:39,960 --> 09:26:40,960
now we could change the time of day as
13383
09:26:42,360 --> 09:26:43,360
well we'll make this one Dynamic for now
13384
09:26:44,936 --> 09:26:45,936
so fully Dynamic light because I don't
13385
09:26:47,700 --> 09:26:48,700
have any time to actually build this so
13386
09:26:51,060 --> 09:26:52,060
go ahead and rotate it to make it like a
13387
09:26:54,596 --> 09:26:55,596
morning or evening scene
13388
09:26:56,340 --> 09:26:57,340
this should be about good not gonna
13389
09:26:58,200 --> 09:26:59,200
spend too much time on it save it up
13390
09:27:00,596 --> 09:27:01,596
and over here under content now we can
13391
09:27:03,480 --> 09:27:04,480
start building the actual level
13392
09:27:05,340 --> 09:27:06,340
so I'll just go to my blueprints folder
13393
09:27:09,120 --> 09:27:10,120
here under game I'm going to create the
13394
09:27:11,580 --> 09:27:12,580
game mode and stuff for this one as well
13395
09:27:13,256 --> 09:27:14,256
so type in game mode
13396
09:27:16,620 --> 09:27:17,620
so I'll create gamma BP game mode
13397
09:27:21,180 --> 09:27:22,180
this one is just going to be called BP
13398
09:27:23,700 --> 09:27:24,700
game mode because this is for the actual
13399
09:27:26,160 --> 09:27:27,160
game itself
13400
09:27:27,300 --> 09:27:28,300
under your world settings go ahead and
13401
09:27:28,980 --> 09:27:29,980
change that once again so BP underscore
13402
09:27:31,800 --> 09:27:32,800
game mode will have a CPP game mode if
13403
09:27:34,140 --> 09:27:35,140
we really require but I'll try to stick
13404
09:27:36,180 --> 09:27:37,180
with blueprint as much
13405
09:27:38,160 --> 09:27:39,160
now let's check our time so 10 minutes
13406
09:27:40,380 --> 09:27:41,380
in
13407
09:27:41,580 --> 09:27:42,580
now under your game mode will also have
13408
09:27:43,980 --> 09:27:44,980
a game state to counter score and stuff
13409
09:27:46,080 --> 09:27:47,080
so game state
13410
09:27:48,900 --> 09:27:49,900
so game stead base
13411
09:27:51,000 --> 09:27:52,000
BP underscore
13412
09:27:53,820 --> 09:27:54,820
game state
13413
09:27:56,220 --> 09:27:57,220
so we have our game mode oops
13414
09:27:59,220 --> 09:28:00,220
and we have our game state
13415
09:28:02,160 --> 09:28:03,160
and now we can also have our character
13416
09:28:04,680 --> 09:28:05,680
and stuff so we can create that first of
13417
09:28:07,500 --> 09:28:08,500
all we can just right click blueprint
13418
09:28:10,680 --> 09:28:11,680
class character and we can type in BP
13419
09:28:13,860 --> 09:28:14,860
character
13420
09:28:17,160 --> 09:28:18,160
open it up and we have some basic things
13421
09:28:20,520 --> 09:28:21,520
already set up for this mesh we'll be
13422
09:28:23,160 --> 09:28:24,160
using one of these which you bought
13423
09:28:24,960 --> 09:28:25,960
under man
13424
09:28:26,340 --> 09:28:27,340
under mesh full we have all these
13425
09:28:29,580 --> 09:28:30,580
various options so we have four options
13426
09:28:32,580 --> 09:28:33,580
so we'll be using these four so these
13427
09:28:34,860 --> 09:28:35,860
four will be the options for the players
13428
09:28:36,480 --> 09:28:37,480
to choose from That's How we'll do it
13429
09:28:39,060 --> 09:28:40,060
so we'll create a derived class for this
13430
09:28:41,756 --> 09:28:42,756
for BP character
13431
09:28:44,160 --> 09:28:45,160
so under our characters what we can do
13432
09:28:46,980 --> 09:28:47,980
is I can type in character
13433
09:28:51,060 --> 09:28:52,060
I'll just move this here
13434
09:28:53,460 --> 09:28:54,460
and go ahead and type in subclasses
13435
09:28:58,080 --> 09:28:59,080
so these with this is like your main
13436
09:29:00,360 --> 09:29:01,360
character
13437
09:29:01,500 --> 09:29:02,500
so every character is going to be a BP
13438
09:29:04,020 --> 09:29:05,020
character but then we'll specifically
13439
09:29:05,880 --> 09:29:06,880
make them choose a mesh
13440
09:29:08,340 --> 09:29:09,340
so go ahead and create a blueprint Class
13441
09:29:10,620 --> 09:29:11,620
Type in character
13442
09:29:13,620 --> 09:29:14,620
and
13443
09:29:15,240 --> 09:29:16,240
over here we can make it of type BP
13444
09:29:17,756 --> 09:29:18,756
character
13445
09:29:18,960 --> 09:29:19,960
and call this one character one we can
13446
09:29:21,596 --> 09:29:22,596
actually just name them maybe we'll call
13447
09:29:23,580 --> 09:29:24,580
one Adam duplicate that we'll call One
13448
09:29:26,580 --> 09:29:27,580
John I'm just giving generic names we
13449
09:29:28,500 --> 09:29:29,500
had four
13450
09:29:30,000 --> 09:29:31,000
so we can call one Json and
13451
09:29:34,020 --> 09:29:35,020
maybe we can call one bill I just chose
13452
09:29:36,720 --> 09:29:37,720
random names
13453
09:29:38,220 --> 09:29:39,220
so open this up and for the mesh we can
13454
09:29:41,160 --> 09:29:42,160
go ahead and start replacing it
13455
09:29:43,256 --> 09:29:44,256
so head into the location where we had
13456
09:29:45,660 --> 09:29:46,660
the mesh so this is going to be a first
13457
09:29:48,000 --> 09:29:49,000
character we'll set up the animation
13458
09:29:50,220 --> 09:29:51,220
blueprint a bit later
13459
09:29:52,256 --> 09:29:53,256
so it's a bit off but not to worry we
13460
09:29:55,680 --> 09:29:56,680
can go ahead and adjust that
13461
09:29:58,560 --> 09:29:59,560
negative 90.
13462
09:30:01,140 --> 09:30:02,140
and we can head into the other classes
13463
09:30:04,560 --> 09:30:05,560
here
13464
09:30:06,000 --> 09:30:07,000
so under content blueprint game
13465
09:30:09,180 --> 09:30:10,180
character subclasses we can head into
13466
09:30:12,540 --> 09:30:13,540
bill
13467
09:30:14,700 --> 09:30:15,700
and this was called SK manful one so
13468
09:30:17,880 --> 09:30:18,880
we'll call this SK Man full 2.
13469
09:30:23,340 --> 09:30:24,340
over here we can select SK Man full
13470
09:30:25,680 --> 09:30:26,680
three
13471
09:30:27,060 --> 09:30:28,060
so SK man
13472
09:30:29,700 --> 09:30:30,700
full three
13473
09:30:31,860 --> 09:30:32,860
and for this one we can have SK Man full
13474
09:30:34,620 --> 09:30:35,620
four so SK man
13475
09:30:37,200 --> 09:30:38,200
full four
13476
09:30:39,660 --> 09:30:40,660
so that's pretty much all set
13477
09:30:43,140 --> 09:30:44,140
so I'm not sure if I should just use the
13478
09:30:45,720 --> 09:30:46,720
default one here so man
13479
09:30:48,180 --> 09:30:49,180
full one
13480
09:30:51,240 --> 09:30:52,240
not sure if it'll inherit the transform
13481
09:30:53,276 --> 09:30:54,276
so I'll just try this I'll compile
13482
09:30:57,360 --> 09:30:58,360
compile this
13483
09:31:00,120 --> 09:31:01,120
so if I open the full blueprint editor
13484
09:31:02,160 --> 09:31:03,160
okay it has inherited the transforms
13485
09:31:04,200 --> 09:31:05,200
that's a good thing
13486
09:31:05,460 --> 09:31:06,460
so we don't have to do everything once
13487
09:31:07,800 --> 09:31:08,800
again
13488
09:31:08,520 --> 09:31:09,520
all right so we have our character set
13489
09:31:10,800 --> 09:31:11,800
up
13490
09:31:11,820 --> 09:31:12,820
uh in our main menu we can go ahead and
13491
09:31:14,220 --> 09:31:15,220
add a character selection option
13492
09:31:16,620 --> 09:31:17,620
so head into content uh our actual
13493
09:31:19,740 --> 09:31:20,740
content folder
13494
09:31:21,180 --> 09:31:22,180
under the main menu we can have a button
13495
09:31:23,880 --> 09:31:24,880
somewhere
13496
09:31:25,500 --> 09:31:26,500
and maybe over here we can type in
13497
09:31:27,840 --> 09:31:28,840
change character
13498
09:31:31,320 --> 09:31:32,320
so I'll change the color of this I'm not
13499
09:31:33,480 --> 09:31:34,480
really worried about the visuals as of
13500
09:31:35,340 --> 09:31:36,340
now
13501
09:31:36,416 --> 09:31:37,416
so I'll just go ahead and change this
13502
09:31:38,700 --> 09:31:39,700
okay I change the color so background
13503
09:31:41,400 --> 09:31:42,400
color I'll just make this dark again
13504
09:31:44,000 --> 09:31:45,000
and we can add in some text
13505
09:31:47,340 --> 09:31:48,340
and we'll call this one
13506
09:31:50,220 --> 09:31:51,220
change character
13507
09:31:52,740 --> 09:31:53,740
all right
13508
09:31:54,776 --> 09:31:55,776
make this a little bit wider
13509
09:31:58,080 --> 09:31:59,080
so that it's visible for our player so
13510
09:32:00,596 --> 09:32:01,596
make this one 45 maybe or 35 35 seems
13511
09:32:05,460 --> 09:32:06,460
good we'll make that one light once
13512
09:32:07,560 --> 09:32:08,560
again
13513
09:32:08,340 --> 09:32:09,340
maybe we could make start a bit
13514
09:32:11,300 --> 09:32:12,300
Bolder so let's start be regular because
13515
09:32:14,160 --> 09:32:15,160
we want our players to deliberately
13516
09:32:16,140 --> 09:32:17,140
click Start
13517
09:32:18,540 --> 09:32:19,540
all right so once you click on the
13518
09:32:20,580 --> 09:32:21,580
change character menu it should just
13519
09:32:22,740 --> 09:32:23,740
give us a list and we will create the
13520
09:32:24,540 --> 09:32:25,540
widget for that
13521
09:32:26,340 --> 09:32:27,340
now we'll also need a game instance
13522
09:32:28,380 --> 09:32:29,380
class
13523
09:32:29,820 --> 09:32:30,820
head into Blueprints and game instances
13524
09:32:33,060 --> 09:32:34,060
General so we'll create one here so game
13525
09:32:35,936 --> 09:32:36,936
instance
13526
09:32:38,040 --> 09:32:39,040
go ahead and call this one main GI or
13527
09:32:41,580 --> 09:32:42,580
something
13528
09:32:42,660 --> 09:32:43,660
and under the project settings we can go
13529
09:32:44,936 --> 09:32:45,936
ahead and change it so game instance
13530
09:32:48,000 --> 09:32:49,000
oops game instance
13531
09:32:50,276 --> 09:32:51,276
change that to main GI
13532
09:32:53,340 --> 09:32:54,340
and over here we can have a variable for
13533
09:32:56,276 --> 09:32:57,276
selected character
13534
09:33:00,740 --> 09:33:01,740
and we can change that actually we can
13535
09:33:03,840 --> 09:33:04,840
change that to be of type BP character
13536
09:33:06,416 --> 09:33:07,416
class
13537
09:33:08,340 --> 09:33:09,340
so we have BP character we should see it
13538
09:33:10,560 --> 09:33:11,560
somewhere here BP character class
13539
09:33:12,300 --> 09:33:13,300
reference
13540
09:33:13,620 --> 09:33:14,620
so this is going to be the the character
13541
09:33:16,080 --> 09:33:17,080
which we have actually selected or we
13542
09:33:18,540 --> 09:33:19,540
could have it in a struct we'll think
13543
09:33:19,980 --> 09:33:20,980
about that a bit later
13544
09:33:21,720 --> 09:33:22,720
now once we have that we can go ahead
13545
09:33:24,660 --> 09:33:25,660
and start making the actual obstacles
13546
09:33:26,756 --> 09:33:27,756
and stuff
13547
09:33:28,020 --> 09:33:29,020
so one thing to note is that we want to
13548
09:33:30,300 --> 09:33:31,300
make this modular in a way we want to be
13549
09:33:33,660 --> 09:33:34,660
able to spawn them one after the other
13550
09:33:36,720 --> 09:33:37,720
let's just go ahead and do that
13551
09:33:39,480 --> 09:33:40,480
so on when the game starts we want to
13552
09:33:42,300 --> 09:33:43,300
have a bunch of obstacles
13553
09:33:44,220 --> 09:33:45,220
and then we'll look at what to do
13554
09:33:47,300 --> 09:33:48,300
uh we'll work on the obstacles after we
13555
09:33:50,276 --> 09:33:51,276
work on the animations actually
13556
09:33:52,680 --> 09:33:53,680
so we'll head into the skeletal mesh we
13557
09:33:55,020 --> 09:33:56,020
have certain animations
13558
09:33:57,776 --> 09:33:58,776
so content content blueprint will add
13559
09:34:01,980 --> 09:34:02,980
into character
13560
09:34:03,300 --> 09:34:04,300
and we'll create the animation blueprint
13561
09:34:05,220 --> 09:34:06,220
right here so animation animation
13562
09:34:08,400 --> 09:34:09,400
blueprint and we'll go ahead and select
13563
09:34:10,916 --> 09:34:11,916
our ue4 mannequin skeleton
13564
09:34:13,380 --> 09:34:14,380
this is the one which comes with the
13565
09:34:16,080 --> 09:34:17,080
pack actually
13566
09:34:17,160 --> 09:34:18,160
so create
13567
09:34:18,720 --> 09:34:19,720
and we'll call this one character and
13568
09:34:21,960 --> 09:34:22,960
MVP
13569
09:34:25,560 --> 09:34:26,560
open it up and inside this we have a
13570
09:34:29,580 --> 09:34:30,580
bunch of things so we'll create a state
13571
09:34:31,620 --> 09:34:32,620
machine
13572
09:34:33,060 --> 09:34:34,060
doesn't really matter now we can go
13573
09:34:35,700 --> 09:34:36,700
ahead and have an idle
13574
09:34:38,756 --> 09:34:39,756
so we'll have idle
13575
09:34:41,220 --> 09:34:42,220
and we can have we'll create a blank
13576
09:34:43,560 --> 09:34:44,560
space for this
13577
09:34:46,140 --> 09:34:47,140
so right click go ahead into animation
13578
09:34:50,400 --> 09:34:51,400
so basically this is for transitioning
13579
09:34:53,160 --> 09:34:54,160
between your idle and walk animations
13580
09:34:56,700 --> 09:34:57,700
blend space
13581
09:34:58,320 --> 09:34:59,320
and we'll call this one walk run
13582
09:35:04,740 --> 09:35:05,740
okay
13583
09:35:06,596 --> 09:35:07,596
over here we'll have few things in the
13584
09:35:09,596 --> 09:35:10,596
horizontal and the vertical axis
13585
09:35:11,300 --> 09:35:12,300
horizontal axis is going to be the
13586
09:35:13,560 --> 09:35:14,560
direction and the vertical axis is going
13587
09:35:16,560 --> 09:35:17,560
to be the speed
13588
09:35:17,880 --> 09:35:18,880
so we'll go between 0 and 600 but we'll
13589
09:35:21,596 --> 09:35:22,596
see if we can do something else a bit
13590
09:35:23,340 --> 09:35:24,340
later on
13591
09:35:25,080 --> 09:35:26,080
now open this and we can have our third
13592
09:35:29,096 --> 09:35:30,096
person walk halfway over here
13593
09:35:31,916 --> 09:35:32,916
we can have our third person run
13594
09:35:34,680 --> 09:35:35,680
full way
13595
09:35:36,960 --> 09:35:37,960
and we can have our third person idle at
13596
09:35:39,720 --> 09:35:40,720
zero
13597
09:35:42,060 --> 09:35:43,060
so we transition between these something
13598
09:35:44,756 --> 09:35:45,756
like this for the direction we'll have a
13599
09:35:47,160 --> 09:35:48,160
negative 180 and positive 180 obviously
13600
09:35:50,040 --> 09:35:51,040
so this will be like your angle from
13601
09:35:52,680 --> 09:35:53,680
your forward Direction that's basically
13602
09:35:54,416 --> 09:35:55,416
what this is
13603
09:35:56,520 --> 09:35:57,520
now we can change the animation
13604
09:35:58,380 --> 09:35:59,380
blueprint after we actually set it up
13605
09:36:00,960 --> 09:36:01,960
first so for the idle we have our idle
13606
09:36:03,960 --> 09:36:04,960
animation playing and we should already
13607
09:36:05,520 --> 09:36:06,520
have this working
13608
09:36:07,560 --> 09:36:08,560
and we can have this as a new state so
13609
09:36:10,380 --> 09:36:11,380
walk run
13610
09:36:12,180 --> 09:36:13,180
we will set up the conditions not to
13611
09:36:14,400 --> 09:36:15,400
worry
13612
09:36:16,256 --> 09:36:17,256
oops go ahead and do that
13613
09:36:19,936 --> 09:36:20,936
so on begin play
13614
09:36:23,580 --> 09:36:24,580
begin play
13615
09:36:26,460 --> 09:36:27,460
we can go ahead and get the pawn owner
13616
09:36:29,276 --> 09:36:30,276
and cast to BP character
13617
09:36:32,880 --> 09:36:33,880
and we can make this a pure cast because
13618
09:36:34,980 --> 09:36:35,980
this will succeed
13619
09:36:36,416 --> 09:36:37,416
or if it doesn't we can go ahead and
13620
09:36:38,460 --> 09:36:39,460
pull it
13621
09:36:40,740 --> 09:36:41,740
and once we get access to our character
13622
09:36:44,700 --> 09:36:45,700
what we can do is we can get access to
13623
09:36:47,640 --> 09:36:48,640
the speed so get velocity
13624
09:36:52,740 --> 09:36:53,740
so get velocity
13625
09:36:57,900 --> 09:36:58,900
and we want the vector length
13626
09:37:01,740 --> 09:37:02,740
right now we have a vector and we want
13627
09:37:04,256 --> 09:37:05,256
the magnitude of this vector
13628
09:37:06,480 --> 09:37:07,480
and we can promote that variable and
13629
09:37:09,060 --> 09:37:10,060
obviously the magnitude of the Velocity
13630
09:37:10,916 --> 09:37:11,916
is nothing but speed so speed
13631
09:37:14,640 --> 09:37:15,640
and we can also have Direction so get
13632
09:37:18,180 --> 09:37:19,180
actor rotation we'll set it up a bit
13633
09:37:20,756 --> 09:37:21,756
later actually
13634
09:37:22,140 --> 09:37:23,140
okay so under the update animation
13635
09:37:25,380 --> 09:37:26,380
what we can do is
13636
09:37:27,596 --> 09:37:28,596
we'll need this on every frame so we'll
13637
09:37:29,936 --> 09:37:30,936
use a reference instead so promote this
13638
09:37:32,040 --> 09:37:33,040
to a variable
13639
09:37:33,240 --> 09:37:34,240
and call this one character ref
13640
09:37:37,620 --> 09:37:38,620
we'll be using this multiple times
13641
09:37:41,520 --> 09:37:42,520
so we can drag this over there
13642
09:37:44,400 --> 09:37:45,400
so this will be our speed
13643
09:37:48,436 --> 09:37:49,436
and also
13644
09:37:50,820 --> 09:37:51,820
what we can do is we can also get the
13645
09:37:53,276 --> 09:37:54,276
direction
13646
09:37:54,720 --> 09:37:55,720
so we can use this function known as
13647
09:37:56,880 --> 09:37:57,880
calculate Direction
13648
09:37:59,936 --> 09:38:00,936
and that is what will set the direction
13649
09:38:02,096 --> 09:38:03,096
to be set Direction
13650
09:38:04,500 --> 09:38:05,500
so we'll create a new variable called
13651
09:38:07,320 --> 09:38:08,320
Direction
13652
09:38:09,000 --> 09:38:10,000
it's going to be a float once again
13653
09:38:11,640 --> 09:38:12,640
and we're going to set the direction
13654
09:38:15,120 --> 09:38:16,120
to be equal to whatever this is
13655
09:38:18,596 --> 09:38:19,596
for the velocity we can just uh grab in
13656
09:38:22,740 --> 09:38:23,740
or get velocity here
13657
09:38:24,900 --> 09:38:25,900
and base rotation is going to be the
13658
09:38:27,416 --> 09:38:28,416
actor's rotation itself
13659
09:38:29,580 --> 09:38:30,580
so get actor rotation
13660
09:38:35,640 --> 09:38:36,640
and we can plug this into the velocity
13661
09:38:37,680 --> 09:38:38,680
as well now what we are basically doing
13662
09:38:39,660 --> 09:38:40,660
is we're calculating the direction so
13663
09:38:42,300 --> 09:38:43,300
that we actually input the value
13664
09:38:44,096 --> 09:38:45,096
correctly in our blend space basically
13665
09:38:46,560 --> 09:38:47,560
we are not using this value anywhere
13666
09:38:48,540 --> 09:38:49,540
else so here we can plug in our
13667
09:38:50,820 --> 09:38:51,820
direction and speed so Direction
13668
09:38:53,160 --> 09:38:54,160
and speed so these were our vertical and
13669
09:38:55,916 --> 09:38:56,916
horizontal axis values in our blend
13670
09:38:58,200 --> 09:38:59,200
space
13671
09:38:59,640 --> 09:39:00,640
we can also have jump which we will do
13672
09:39:02,580 --> 09:39:03,580
we have we don't have a state transition
13673
09:39:05,700 --> 09:39:06,700
so if speed is greater than let's say 10
13674
09:39:09,840 --> 09:39:10,840
we can go ahead and transition
13675
09:39:12,480 --> 09:39:13,480
and over here as well if the speed is
13676
09:39:14,756 --> 09:39:15,756
less than 10 we can transition so
13677
09:39:17,520 --> 09:39:18,520
rather speed
13678
09:39:19,140 --> 09:39:20,140
so speed is less than or equal to 10.
13679
09:39:23,096 --> 09:39:24,096
we can go ahead and transition into this
13680
09:39:25,620 --> 09:39:26,620
state
13681
09:39:27,180 --> 09:39:28,180
so now we shouldn't have any of those
13682
09:39:29,040 --> 09:39:30,040
warnings
13683
09:39:30,596 --> 09:39:31,596
all right now if I actually create
13684
09:39:33,360 --> 09:39:34,360
something here
13685
09:39:35,040 --> 09:39:36,040
so I'll just create a player start so
13686
09:39:37,080 --> 09:39:38,080
we'll know where to start so player
13687
09:39:39,000 --> 09:39:40,000
start
13688
09:39:39,900 --> 09:39:40,900
and I'll just go ahead and box out a
13689
09:39:42,300 --> 09:39:43,300
simple level
13690
09:39:43,620 --> 09:39:44,620
so shapes
13691
09:39:45,776 --> 09:39:46,776
so I'll have a cube
13692
09:39:48,000 --> 09:39:49,000
and I'll just make this really really
13693
09:39:50,160 --> 09:39:51,160
big
13694
09:39:52,320 --> 09:39:53,320
so this is just for testing purposes and
13695
09:39:55,200 --> 09:39:56,200
for the default Pawn class I'm going to
13696
09:39:57,180 --> 09:39:58,180
select BP character
13697
09:39:59,936 --> 09:40:00,936
and let's set up the animation blueprint
13698
09:40:03,840 --> 09:40:04,840
over here if we go ahead and select our
13699
09:40:08,160 --> 09:40:09,160
character anime nmbp
13700
09:40:10,740 --> 09:40:11,740
in theory everything should work fine
13701
09:40:14,640 --> 09:40:15,640
so our camera is a bit off that's
13702
09:40:17,220 --> 09:40:18,220
nothing to worry about
13703
09:40:21,000 --> 09:40:22,000
so under our BP character we need to set
13704
09:40:24,596 --> 09:40:25,596
up a camera so add a component and this
13705
09:40:27,540 --> 09:40:28,540
will be of type camera
13706
09:40:30,960 --> 09:40:31,960
go ahead and add it
13707
09:40:33,060 --> 09:40:34,060
we can adjust the view that's nothing to
13708
09:40:35,520 --> 09:40:36,520
worry about
13709
09:40:36,900 --> 09:40:37,900
and if I go ahead and press play we have
13710
09:40:39,060 --> 09:40:40,060
our camera here
13711
09:40:40,620 --> 09:40:41,620
so we can make that a little bit
13712
09:40:43,980 --> 09:40:44,980
further back
13713
09:40:46,560 --> 09:40:47,560
maybe tilt it down a bit
13714
09:40:48,960 --> 09:40:49,960
and I hope this looks good okay so this
13715
09:40:51,596 --> 09:40:52,596
looks good
13716
09:40:52,860 --> 09:40:53,860
so we have access none in our character
13717
09:40:56,040 --> 09:40:57,040
animation blueprint
13718
09:40:58,436 --> 09:40:59,436
so that's only
13719
09:41:01,320 --> 09:41:02,320
in the first frame which is happening
13720
09:41:03,416 --> 09:41:04,416
basically so we can convert this to a
13721
09:41:06,360 --> 09:41:07,360
validated get
13722
09:41:08,340 --> 09:41:09,340
that's a simple fix
13723
09:41:12,300 --> 09:41:13,300
you can go ahead and turn that into
13724
09:41:13,916 --> 09:41:14,916
validated get go ahead and press play
13725
09:41:18,060 --> 09:41:19,060
and now we shouldn't get those errors
13726
09:41:20,640 --> 09:41:21,640
you can set up our moment logic real
13727
09:41:22,500 --> 09:41:23,500
quick here
13728
09:41:23,880 --> 09:41:24,880
so if the characters always going to be
13729
09:41:27,300 --> 09:41:28,300
moving
13730
09:41:28,936 --> 09:41:29,936
and I think we might have to change the
13731
09:41:31,740 --> 09:41:32,740
animation blueprint here because we
13732
09:41:33,596 --> 09:41:34,596
always want him to be running
13733
09:41:35,580 --> 09:41:36,580
because we don't want him to stop so
13734
09:41:38,400 --> 09:41:39,400
we'll always have running actually
13735
09:41:42,120 --> 09:41:43,120
so sorry for that but anyways
13736
09:41:45,000 --> 09:41:46,000
something we can do
13737
09:41:47,520 --> 09:41:48,520
so he'll always be running
13738
09:41:52,620 --> 09:41:53,620
so this is how he'll always be
13739
09:41:55,020 --> 09:41:56,020
and we can also have you know a copy of
13740
09:41:57,900 --> 09:41:58,900
this
13741
09:42:00,720 --> 09:42:01,720
so we'll just copy this over and we can
13742
09:42:03,120 --> 09:42:04,120
type in run fast we can make this go at
13743
09:42:07,020 --> 09:42:08,020
a higher speed
13744
09:42:08,700 --> 09:42:09,700
so there should be a speed multiplier
13745
09:42:10,980 --> 09:42:11,980
somewhere here
13746
09:42:12,840 --> 09:42:13,840
so playback speed is what it's called I
13747
09:42:15,360 --> 09:42:16,360
assume
13748
09:42:16,620 --> 09:42:17,620
so playback speed
13749
09:42:22,320 --> 09:42:23,320
so nothing under the details
13750
09:42:25,800 --> 09:42:26,800
we'll look into that so there's actually
13751
09:42:28,020 --> 09:42:29,020
an option called playback speed so we
13752
09:42:30,300 --> 09:42:31,300
are going to increase the speed and make
13753
09:42:32,040 --> 09:42:33,040
it so that
13754
09:42:33,540 --> 09:42:34,540
it's actually as if he's running
13755
09:42:37,980 --> 09:42:38,980
now what we can do
13756
09:42:42,360 --> 09:42:43,360
is
13757
09:42:44,340 --> 09:42:45,340
we can head into the character once
13758
09:42:47,040 --> 09:42:48,040
again
13759
09:42:48,360 --> 09:42:49,360
and now that we have him running
13760
09:42:50,936 --> 09:42:51,936
continuously we'll actually do it so
13761
09:42:53,580 --> 09:42:54,580
that the obstacles in the world actually
13762
09:42:56,520 --> 09:42:57,520
go backward
13763
09:42:58,500 --> 09:42:59,500
you can create the blueprint for that
13764
09:43:00,120 --> 09:43:01,120
now so we're finally heading into the
13765
09:43:02,160 --> 09:43:03,160
obstacles so
13766
09:43:03,960 --> 09:43:04,960
we'll spend 25 minutes not done really
13767
09:43:06,596 --> 09:43:07,596
really that much
13768
09:43:08,756 --> 09:43:09,756
and again
13769
09:43:11,460 --> 09:43:12,460
in the blueprints folder we can go ahead
13770
09:43:13,980 --> 09:43:14,980
and create a new blueprint class we'll
13771
09:43:16,256 --> 09:43:17,256
do it in the new folder so we'll call
13772
09:43:18,660 --> 09:43:19,660
this one course rather this will be the
13773
09:43:22,256 --> 09:43:23,256
obstacle course basically
13774
09:43:24,060 --> 09:43:25,060
and we'll create a new actor
13775
09:43:27,480 --> 09:43:28,480
and we'll call this one
13776
09:43:30,416 --> 09:43:31,416
obstacle
13777
09:43:32,460 --> 09:43:33,460
underscore base
13778
09:43:34,740 --> 09:43:35,740
and we can go ahead and create a child
13779
09:43:37,020 --> 09:43:38,020
blueprint class and we'll call this one
13780
09:43:38,820 --> 09:43:39,820
obstacle one obstacle 2 and so on
13781
09:43:41,820 --> 09:43:42,820
so obstacle 2
13782
09:43:44,096 --> 09:43:45,096
duplicate that duplicate that duplicate
13783
09:43:47,220 --> 09:43:48,220
that will have five
13784
09:43:49,020 --> 09:43:50,020
we'll see if it if it gets too hectic
13785
09:43:51,300 --> 09:43:52,300
we'll reduce this number
13786
09:43:54,120 --> 09:43:55,120
over here we'll need some sort of a base
13787
09:43:56,936 --> 09:43:57,936
so we can try using some of the things
13788
09:43:59,220 --> 09:44:00,220
which we got from the content packs
13789
09:44:01,560 --> 09:44:02,560
so under hanger I guess we had a road I
13790
09:44:04,980 --> 09:44:05,980
believe
13791
09:44:05,880 --> 09:44:06,880
I type in Road
13792
09:44:08,096 --> 09:44:09,096
we have this which is pretty tileable I
13793
09:44:10,800 --> 09:44:11,800
believe
13794
09:44:13,256 --> 09:44:14,256
over here Road set
13795
09:44:17,460 --> 09:44:18,460
we have this so we can use this
13796
09:44:22,436 --> 09:44:23,436
just that we'll need to know what's the
13797
09:44:24,720 --> 09:44:25,720
length of this and stuff
13798
09:44:26,220 --> 09:44:27,220
I don't think we'll go for nanite or
13799
09:44:28,680 --> 09:44:29,680
anything
13800
09:44:30,000 --> 09:44:31,000
this is fine
13801
09:44:32,580 --> 09:44:33,580
so close some of these which we are not
13802
09:44:34,560 --> 09:44:35,560
using
13803
09:44:36,120 --> 09:44:37,120
head back into the obstacle base
13804
09:44:40,080 --> 09:44:41,080
over here we can go ahead and add in a
13805
09:44:42,596 --> 09:44:43,596
static mesh
13806
09:44:44,040 --> 09:44:45,040
and this will be common for everything
13807
09:44:45,776 --> 09:44:46,776
so head back select that
13808
09:44:49,436 --> 09:44:50,436
and go ahead and
13809
09:44:52,020 --> 09:44:53,020
put that in
13810
09:44:55,256 --> 09:44:56,256
so this is there at the origin
13811
09:44:58,620 --> 09:44:59,620
but not to worry we'll find a way to fix
13812
09:45:01,916 --> 09:45:02,916
that
13813
09:45:03,360 --> 09:45:04,360
so it would have been nice if we had
13814
09:45:04,860 --> 09:45:05,860
multiple Lanes
13815
09:45:06,596 --> 09:45:07,596
but we have to live with this right now
13816
09:45:10,740 --> 09:45:11,740
so I'll just go ahead and re-center this
13817
09:45:14,400 --> 09:45:15,400
I'm not sure how
13818
09:45:17,276 --> 09:45:18,276
big this is going to be
13819
09:45:20,460 --> 09:45:21,460
so I think that is pretty well centered
13820
09:45:23,340 --> 09:45:24,340
we can go ahead and add an arrow
13821
09:45:25,680 --> 09:45:26,680
component just for a reference
13822
09:45:28,500 --> 09:45:29,500
so add in an arrow component
13823
09:45:31,860 --> 09:45:32,860
attached to the root
13824
09:45:35,520 --> 09:45:36,520
this one is going to be at the origin
13825
09:45:37,680 --> 09:45:38,680
obviously
13826
09:45:39,000 --> 09:45:40,000
just rotate that for our reference
13827
09:45:43,436 --> 09:45:44,436
or we'll keep the rotation to zero we'll
13828
09:45:45,540 --> 09:45:46,540
look into the rotation and stuff so
13829
09:45:47,756 --> 09:45:48,756
we'll duplicate this once again
13830
09:45:50,220 --> 09:45:51,220
so Ctrl D to duplicate
13831
09:45:54,180 --> 09:45:55,180
and we'll just have one over there I
13832
09:45:57,480 --> 09:45:58,480
think one is enough but we'll just have
13833
09:45:59,520 --> 09:46:00,520
it just in case
13834
09:46:02,580 --> 09:46:03,580
all right so this is exactly at the end
13835
09:46:06,360 --> 09:46:07,360
now at first we can spawn for example 10
13836
09:46:09,596 --> 09:46:10,596
of these
13837
09:46:11,040 --> 09:46:12,040
and then we can later see what to do
13838
09:46:15,660 --> 09:46:16,660
we can have something in the side by the
13839
09:46:17,580 --> 09:46:18,580
way we don't have anything
13840
09:46:19,436 --> 09:46:20,436
so we'll just add in a plane
13841
09:46:24,560 --> 09:46:25,560
and for this we can increase the scale
13842
09:46:28,080 --> 09:46:29,080
of this
13843
09:46:29,640 --> 09:46:30,640
maybe we can make this 100 I guess
13844
09:46:34,020 --> 09:46:35,020
okay that's a little too big 50.
13845
09:46:36,960 --> 09:46:37,960
maybe change it on the Y 50 is a bit too
13846
09:46:39,596 --> 09:46:40,596
much 40.
13847
09:46:41,340 --> 09:46:42,340
Maybe 30.
13848
09:46:43,200 --> 09:46:44,200
35
13849
09:46:46,400 --> 09:46:47,400
2 seems to be about right
13850
09:46:49,620 --> 09:46:50,620
so it aligned perfectly here
13851
09:46:52,020 --> 09:46:53,020
and it aligned almost perfectly here as
13852
09:46:54,596 --> 09:46:55,596
well
13853
09:46:55,620 --> 09:46:56,620
I can have 32.
13854
09:47:01,860 --> 09:47:02,860
now this is approximate you can do it
13855
09:47:04,080 --> 09:47:05,080
accurately when you actually do it
13856
09:47:09,596 --> 09:47:10,596
so go ahead and duplicate this once
13857
09:47:12,240 --> 09:47:13,240
again we'll attach it to the root
13858
09:47:16,140 --> 09:47:17,140
duplicate this will be for the other
13859
09:47:18,840 --> 09:47:19,840
side
13860
09:47:23,756 --> 09:47:24,756
all right
13861
09:47:30,776 --> 09:47:31,776
so we have something on both the sides
13862
09:47:35,040 --> 09:47:36,040
now if we head into a derived classes we
13863
09:47:37,620 --> 09:47:38,620
should also have all of those
13864
09:47:41,580 --> 09:47:42,580
well we can spawn this first of all just
13865
09:47:43,916 --> 09:47:44,916
for testing it out
13866
09:47:46,020 --> 09:47:47,020
so open the level blueprint
13867
09:47:48,720 --> 09:47:49,720
and we can just do a for Loop
13868
09:47:54,596 --> 09:47:55,596
so for Loop
13869
09:47:58,200 --> 09:47:59,200
and we can have a loop of length 10
13870
09:48:01,980 --> 09:48:02,980
let's say
13871
09:48:06,480 --> 09:48:07,480
we'll select An Origin
13872
09:48:08,880 --> 09:48:09,880
we'll start from a certain point
13873
09:48:14,700 --> 09:48:15,700
so Target point
13874
09:48:17,220 --> 09:48:18,220
we can start here maybe we'll make the Z
13875
09:48:19,800 --> 09:48:20,800
value of this zero
13876
09:48:21,960 --> 09:48:22,960
will make the X and Y 0 as well
13877
09:48:25,916 --> 09:48:26,916
so this is going to be where we start
13878
09:48:31,200 --> 09:48:32,200
and we can go ahead and start spawning
13879
09:48:33,240 --> 09:48:34,240
this further on
13880
09:48:35,756 --> 09:48:36,756
so we'll have access to this target
13881
09:48:37,560 --> 09:48:38,560
point now so create a reference to
13882
09:48:39,660 --> 09:48:40,660
Target point
13883
09:48:41,276 --> 09:48:42,276
so we are going to spawn actor from
13884
09:48:43,620 --> 09:48:44,620
class and it's going to be BP obstacle
13885
09:48:49,200 --> 09:48:50,200
I'm not sure what we called it obstacle
13886
09:48:52,320 --> 09:48:53,320
base
13887
09:48:53,220 --> 09:48:54,220
this is for testing so it's fine
13888
09:48:57,060 --> 09:48:58,060
so it can get active location it's going
13889
09:48:59,756 --> 09:49:00,756
to be zero I'm aware but in case we
13890
09:49:02,340 --> 09:49:03,340
wanted to change it the logic should
13891
09:49:04,020 --> 09:49:05,020
still work that's why I'm using the
13892
09:49:05,400 --> 09:49:06,400
target point
13893
09:49:07,436 --> 09:49:08,436
so get actor location
13894
09:49:09,840 --> 09:49:10,840
we'll break this down actually
13895
09:49:13,320 --> 09:49:14,320
split the struct PIN
13896
09:49:15,300 --> 09:49:16,300
now the Y and the Z are going to remain
13897
09:49:18,660 --> 09:49:19,660
zero
13898
09:49:20,460 --> 09:49:21,460
so I have to see which is the forward
13899
09:49:22,200 --> 09:49:23,200
axis here actually
13900
09:49:24,360 --> 09:49:25,360
so in the obstacle base
13901
09:49:26,756 --> 09:49:27,756
we have y as the forward axis
13902
09:49:30,540 --> 09:49:31,540
we can rotate everything by 90 degrees
13903
09:49:32,820 --> 09:49:33,820
if we don't mind
13904
09:49:34,436 --> 09:49:35,436
you can just rotate everything by 90.
13905
09:49:38,340 --> 09:49:39,340
oops we change the location
13906
09:49:43,436 --> 09:49:44,436
so we can change this to 90.
13907
09:49:48,860 --> 09:49:49,860
and stuff doesn't seem to be working
13908
09:49:51,840 --> 09:49:52,840
we'll have y as the forward axis in our
13909
09:49:54,240 --> 09:49:55,240
case don't mind
13910
09:49:57,900 --> 09:49:58,900
so the x value is going to be 0.
13911
09:50:01,740 --> 09:50:02,740
we are going to split the struct PIN
13912
09:50:05,096 --> 09:50:06,096
so we're going to multiply this
13913
09:50:07,380 --> 09:50:08,380
multiply this by the index
13914
09:50:10,980 --> 09:50:11,980
and we can go ahead and split this and
13915
09:50:14,220 --> 09:50:15,220
the Y is going to be this
13916
09:50:16,500 --> 09:50:17,500
X and the Z are going to remain zero
13917
09:50:19,436 --> 09:50:20,436
let's go ahead and just test this out so
13918
09:50:23,096 --> 09:50:24,096
go ahead
13919
09:50:24,240 --> 09:50:25,240
selected viewport
13920
09:50:26,520 --> 09:50:27,520
so if I click f8 and if I were to notice
13921
09:50:32,820 --> 09:50:33,820
we don't have anything
13922
09:50:37,620 --> 09:50:38,620
so we should have our
13923
09:50:41,340 --> 09:50:42,340
Target okay we are taking the target
13924
09:50:43,560 --> 09:50:44,560
points Y location
13925
09:50:45,660 --> 09:50:46,660
but
13926
09:50:47,096 --> 09:50:48,096
we need the last obstacles location
13927
09:50:51,360 --> 09:50:52,360
so we need the value of this actually
13928
09:50:54,960 --> 09:50:55,960
we need the location of
13929
09:50:57,480 --> 09:50:58,480
this Arrow
13930
09:51:00,416 --> 09:51:01,416
so this Arrow
13931
09:51:03,900 --> 09:51:04,900
so this arrow is going to be located
13932
09:51:08,700 --> 09:51:09,700
at negative 3200.
13933
09:51:12,416 --> 09:51:13,416
so we'll just copy the number we'll just
13934
09:51:14,460 --> 09:51:15,460
brute force it here
13935
09:51:19,200 --> 09:51:20,200
so we have the target point
13936
09:51:21,596 --> 09:51:22,596
that's where we start
13937
09:51:25,256 --> 09:51:26,256
and into
13938
09:51:28,020 --> 09:51:29,020
3200
13939
09:51:31,800 --> 09:51:32,800
so it's negative 3200
13940
09:51:37,560 --> 09:51:38,560
so I'm not sure if we really need this
13941
09:51:39,840 --> 09:51:40,840
this is going to be 0 anyways
13942
09:51:42,776 --> 09:51:43,776
so this into 3200
13943
09:51:48,060 --> 09:51:49,060
index into 3200 now let's try this
13944
09:51:54,120 --> 09:51:55,120
okay so our obstacle course is spawned
13945
09:51:57,840 --> 09:51:58,840
successfully
13946
09:52:03,660 --> 09:52:04,660
so a bit of an issue with the direction
13947
09:52:06,360 --> 09:52:07,360
over there but that's totally okay
13948
09:52:12,596 --> 09:52:13,596
all right so we have
13949
09:52:15,776 --> 09:52:16,776
that completed so we spawned our initial
13950
09:52:19,860 --> 09:52:20,860
course
13951
09:52:21,720 --> 09:52:22,720
so we can grab in our player start first
13952
09:52:24,180 --> 09:52:25,180
of all and we can rotate that we can
13953
09:52:27,596 --> 09:52:28,596
delete one of them
13954
09:52:30,240 --> 09:52:31,240
we can maybe rotate that negative 90
13955
09:52:32,936 --> 09:52:33,936
degrees
13956
09:52:35,520 --> 09:52:36,520
so now we should face the right
13957
09:52:37,500 --> 09:52:38,500
direction
13958
09:52:39,060 --> 09:52:40,060
now move this a little bit to the left
13959
09:52:43,256 --> 09:52:44,256
so for reference we'll just have one
13960
09:52:45,240 --> 09:52:46,240
obstacle
13961
09:52:50,580 --> 09:52:51,580
so we'll just have obstacle base we'll
13962
09:52:53,096 --> 09:52:54,096
set everything to zero zero zero zero
13963
09:52:57,240 --> 09:52:58,240
and we'll base the player start
13964
09:52:59,400 --> 09:53:00,400
accordingly
13965
09:53:00,916 --> 09:53:01,916
so our player start just disappeared
13966
09:53:03,540 --> 09:53:04,540
somewhere
13967
09:53:05,340 --> 09:53:06,340
okay it's up there
13968
09:53:07,980 --> 09:53:08,980
so we'll click end to Snap It to the
13969
09:53:10,620 --> 09:53:11,620
Ground
13970
09:53:12,300 --> 09:53:13,300
go ahead and do that
13971
09:53:17,460 --> 09:53:18,460
and now we should in theory be centered
13972
09:53:20,580 --> 09:53:21,580
hopefully
13973
09:53:22,500 --> 09:53:23,500
yep we will be centered now
13974
09:53:25,860 --> 09:53:26,860
now if I go ahead and press play as you
13975
09:53:28,560 --> 09:53:29,560
can see we are centered
13976
09:53:30,480 --> 09:53:31,480
now we can also set up the logic to move
13977
09:53:33,720 --> 09:53:34,720
sideways
13978
09:53:36,960 --> 09:53:37,960
so we can linear interpolate actually
13979
09:53:39,596 --> 09:53:40,596
so we'll add in Target points
13980
09:53:43,520 --> 09:53:44,520
so copy the server we'll copy the
13981
09:53:47,756 --> 09:53:48,756
X location of this
13982
09:53:50,580 --> 09:53:51,580
so X is going to be 20.
13983
09:53:54,000 --> 09:53:55,000
we need 20 here
13984
09:53:57,060 --> 09:53:58,060
and the Y location
13985
09:53:59,580 --> 09:54:00,580
really should be the same actually again
13986
09:54:04,560 --> 09:54:05,560
so Y location should be the same
13987
09:54:07,860 --> 09:54:08,860
now we have got these in the same spot
13988
09:54:10,980 --> 09:54:11,980
now we can have few more
13989
09:54:14,640 --> 09:54:15,640
so these two are equally spaced now we
13990
09:54:17,820 --> 09:54:18,820
can set up some logic
13991
09:54:19,560 --> 09:54:20,560
so that we slide between these basically
13992
09:54:23,880 --> 09:54:24,880
head back into the character to set that
13993
09:54:25,916 --> 09:54:26,916
logic
13994
09:54:27,660 --> 09:54:28,660
under your BP character if we press the
13995
09:54:30,776 --> 09:54:31,776
right arrow we won't do changeable
13996
09:54:33,300 --> 09:54:34,300
controls so right
13997
09:54:36,000 --> 09:54:37,000
Arrow
13998
09:54:37,256 --> 09:54:38,256
so right
13999
09:54:39,840 --> 09:54:40,840
and we can have left as well
14000
09:54:42,416 --> 09:54:43,416
so keyboard events left
14001
09:54:44,936 --> 09:54:45,936
under right and left we can change them
14002
09:54:48,300 --> 09:54:49,300
so if we press right
14003
09:54:51,240 --> 09:54:52,240
we also need access to which Target
14004
09:54:53,580 --> 09:54:54,580
point we are at right now
14005
09:54:56,640 --> 09:54:57,640
we can have all of these in a blueprint
14006
09:54:59,700 --> 09:55:00,700
we can have these in the game state
14007
09:55:03,060 --> 09:55:04,060
content blueprints game game state
14008
09:55:08,340 --> 09:55:09,340
we can type in
14009
09:55:10,320 --> 09:55:11,320
will have an enum
14010
09:55:12,720 --> 09:55:13,720
it's going to be simple
14011
09:55:14,880 --> 09:55:15,880
so content
14012
09:55:16,680 --> 09:55:17,680
will create enums so enum
14013
09:55:21,840 --> 09:55:22,840
right click create an enumeration
14014
09:55:25,256 --> 09:55:26,256
and over here we'll call this one
14015
09:55:28,500 --> 09:55:29,500
which side of the road you're in
14016
09:55:30,060 --> 09:55:31,060
basically so I don't I don't even know
14017
09:55:31,740 --> 09:55:32,740
what to call this e
14018
09:55:34,860 --> 09:55:35,860
which side I guess
14019
09:55:37,080 --> 09:55:38,080
I mean which is kind of stupid but at
14020
09:55:40,436 --> 09:55:41,436
the same time it's descriptive
14021
09:55:43,436 --> 09:55:44,436
so it's either going to be left okay or
14022
09:55:45,960 --> 09:55:46,960
at the center by default so I'll have
14023
09:55:47,756 --> 09:55:48,756
Center first center left and right
14024
09:55:53,460 --> 09:55:54,460
so if I save that and head back into my
14025
09:55:56,160 --> 09:55:57,160
game State now I should be able to
14026
09:55:57,840 --> 09:55:58,840
create a variable of type which side
14027
09:56:01,200 --> 09:56:02,200
which side e which side so just my
14028
09:56:04,256 --> 09:56:05,256
naming convention
14029
09:56:07,080 --> 09:56:08,080
so we'll call this one
14030
09:56:10,256 --> 09:56:11,256
with side Maybe
14031
09:56:14,040 --> 09:56:15,040
all right
14032
09:56:15,660 --> 09:56:16,660
so we'll have access to this at any
14033
09:56:18,240 --> 09:56:19,240
given instance
14034
09:56:19,680 --> 09:56:20,680
and on begin play we can store a
14035
09:56:21,480 --> 09:56:22,480
reference to this
14036
09:56:23,040 --> 09:56:24,040
get game state
14037
09:56:26,096 --> 09:56:27,096
we can go ahead and cast to our BP game
14038
09:56:29,460 --> 09:56:30,460
state
14039
09:56:31,560 --> 09:56:32,560
and we'll have a reference to that
14040
09:56:34,500 --> 09:56:35,500
promote that two variable and call this
14041
09:56:36,776 --> 09:56:37,776
one game State ref
14042
09:56:42,840 --> 09:56:43,840
okay
14043
09:56:44,460 --> 09:56:45,460
now from here when we press right we can
14044
09:56:48,060 --> 09:56:49,060
first of all get access to the variables
14045
09:56:50,880 --> 09:56:51,880
the first variable which we need is the
14046
09:56:53,880 --> 09:56:54,880
only variable which we have right now
14047
09:56:55,320 --> 09:56:56,320
basically which is the side
14048
09:56:57,960 --> 09:56:58,960
so we'll type in side
14049
09:57:01,320 --> 09:57:02,320
and we'll do a simple switch
14050
09:57:05,936 --> 09:57:06,936
so if we are at the center right now
14051
09:57:09,180 --> 09:57:10,180
we can go to the right
14052
09:57:11,520 --> 09:57:12,520
if we are at the left right now
14053
09:57:15,180 --> 09:57:16,180
we can go ahead and head to
14054
09:57:18,540 --> 09:57:19,540
the left basically
14055
09:57:20,480 --> 09:57:21,480
uh if we are at the left we can head
14056
09:57:23,220 --> 09:57:24,220
into the center if we are at the right
14057
09:57:25,436 --> 09:57:26,436
we don't need to do anything so
14058
09:57:27,060 --> 09:57:28,060
basically on Center and left we can do
14059
09:57:29,096 --> 09:57:30,096
that
14060
09:57:30,720 --> 09:57:31,720
again we'll copy over this logic
14061
09:57:38,520 --> 09:57:39,520
depending on which side we don't want to
14062
09:57:40,980 --> 09:57:41,980
do anything if we are on the left side
14063
09:57:42,416 --> 09:57:43,416
here in this case
14064
09:57:45,200 --> 09:57:46,200
and we can linear interpolate on tick
14065
09:57:51,416 --> 09:57:52,416
so a linear interpolate is what we'll
14066
09:57:53,756 --> 09:57:54,756
just do so we'll type in lurp
14067
09:57:56,640 --> 09:57:57,640
and we should find a linear interpolate
14068
09:58:00,660 --> 09:58:01,660
and we should be able to feed in the
14069
09:58:02,936 --> 09:58:03,936
alpha we'll think about a logic for that
14070
09:58:08,040 --> 09:58:09,040
now we'll have access to where we are by
14071
09:58:11,276 --> 09:58:12,276
default we are at the center
14072
09:58:19,500 --> 09:58:20,500
just took a small break there now over
14073
09:58:22,680 --> 09:58:23,680
here we can continue with our side
14074
09:58:25,680 --> 09:58:26,680
switching logic so we'll actually get
14075
09:58:28,916 --> 09:58:29,916
hold of all the locations and stuff
14076
09:58:32,580 --> 09:58:33,580
so by default we are over here
14077
09:58:35,936 --> 09:58:36,936
so if I press play we are over here
14078
09:58:38,520 --> 09:58:39,520
but when we want to move we want to move
14079
09:58:41,460 --> 09:58:42,460
to either this or this
14080
09:58:45,720 --> 09:58:46,720
so we'll actually have a few variables
14081
09:58:48,480 --> 09:58:49,480
for this I'm going to be hard coding
14082
09:58:50,460 --> 09:58:51,460
this but you can have a more elegant
14083
09:58:52,560 --> 09:58:53,560
solution for all of these
14084
09:58:55,080 --> 09:58:56,080
so I can go ahead and under my game
14085
09:58:57,720 --> 09:58:58,720
State itself I can have right location
14086
09:59:02,820 --> 09:59:03,820
right location
14087
09:59:04,980 --> 09:59:05,980
center location and left location so
14088
09:59:07,740 --> 09:59:08,740
I'll duplicate this
14089
09:59:10,256 --> 09:59:11,256
so I'll call this one left location
14090
09:59:16,020 --> 09:59:17,020
and I'll call this one Center location
14091
09:59:22,980 --> 09:59:23,980
and we'll manually set these values
14092
09:59:28,020 --> 09:59:29,020
so this value over here is negative 230
14093
09:59:31,320 --> 09:59:32,320
negative 270 and 0. this is the left
14094
09:59:34,980 --> 09:59:35,980
location so negative 230
14095
09:59:38,936 --> 09:59:39,936
negative 270
14096
09:59:43,320 --> 09:59:44,320
to 70 and 0.
14097
09:59:47,460 --> 09:59:48,460
we can actually save some data I Believe
14098
09:59:49,860 --> 09:59:50,860
by using floats we only need the we only
14099
09:59:52,680 --> 09:59:53,680
need to linear interpolate the X
14100
09:59:54,776 --> 09:59:55,776
Direction so
14101
09:59:56,700 --> 09:59:57,700
we'll just store the X values of this
14102
10:00:01,256 --> 10:00:02,256
so
14103
10:00:04,140 --> 10:00:05,140
this is 270
14104
10:00:08,400 --> 10:00:09,400
20 and negative 230 not sure if they're
14105
10:00:12,300 --> 10:00:13,300
spaced equally I'll just have a look at
14106
10:00:14,220 --> 10:00:15,220
the top view
14107
10:00:15,776 --> 10:00:16,776
I want them to be spaced equally
14108
10:00:18,300 --> 10:00:19,300
so between this and this there is a
14109
10:00:21,960 --> 10:00:22,960
difference of 250
14110
10:00:24,660 --> 10:00:25,660
between this and this there is a
14111
10:00:27,120 --> 10:00:28,120
difference of 250 so yep they are spaced
14112
10:00:30,180 --> 10:00:31,180
equally
14113
10:00:33,060 --> 10:00:34,060
okay so the right location is going to
14114
10:00:36,300 --> 10:00:37,300
be 270.
14115
10:00:39,776 --> 10:00:40,776
left location is negative 230
14116
10:00:42,840 --> 10:00:43,840
and this is going to be 20.
14117
10:00:45,840 --> 10:00:46,840
so I'll just store these like this
14118
10:00:50,936 --> 10:00:51,936
now what I can do is I can go ahead and
14119
10:00:54,540 --> 10:00:55,540
actually
14120
10:00:56,220 --> 10:00:57,220
move the character so I'll try set actor
14121
10:00:59,580 --> 10:01:00,580
location not sure if this is going to
14122
10:01:01,800 --> 10:01:02,800
work
14123
10:01:02,756 --> 10:01:03,756
so if we are at the center we'll try
14124
10:01:05,096 --> 10:01:06,096
this to try to set this to the right
14125
10:01:07,256 --> 10:01:08,256
location so we're going left so left
14126
10:01:11,400 --> 10:01:12,400
left location
14127
10:01:13,436 --> 10:01:14,436
so we only want to change the X
14128
10:01:16,620 --> 10:01:17,620
so go ahead and split the struct pin
14129
10:01:18,776 --> 10:01:19,776
change the left location
14130
10:01:21,180 --> 10:01:22,180
and the rest is going to be the actors
14131
10:01:24,000 --> 10:01:25,000
location itself so get actor location
14132
10:01:27,480 --> 10:01:28,480
go ahead and split this Y and Z will
14133
10:01:30,840 --> 10:01:31,840
just remain access
14134
10:01:33,540 --> 10:01:34,540
all right so we can go ahead and try
14135
10:01:36,480 --> 10:01:37,480
this
14136
10:01:37,436 --> 10:01:38,436
so if I press the left Arrow
14137
10:01:41,160 --> 10:01:42,160
so nothing is really happening here
14138
10:01:44,700 --> 10:01:45,700
so we can see by printing if something
14139
10:01:47,820 --> 10:01:48,820
is happening
14140
10:01:50,220 --> 10:01:51,220
so nope we are not actually taking the
14141
10:01:52,680 --> 10:01:53,680
input something has to do
14142
10:01:55,140 --> 10:01:56,140
with the input so Arrow
14143
10:02:01,916 --> 10:02:02,916
left keyboard not really sure I'll I'll
14144
10:02:04,916 --> 10:02:05,916
try to use a and d for now
14145
10:02:07,500 --> 10:02:08,500
so a on the keyboard
14146
10:02:10,256 --> 10:02:11,256
so we'll use wasd
14147
10:02:14,640 --> 10:02:15,640
so when I press a on the keyboard we can
14148
10:02:17,220 --> 10:02:18,220
try that a is going to be instead of the
14149
10:02:19,320 --> 10:02:20,320
left Arrow
14150
10:02:24,300 --> 10:02:25,300
all right so we did we don't have access
14151
10:02:27,596 --> 10:02:28,596
to the game State according to this
14152
10:02:30,240 --> 10:02:31,240
that's mostly because we didn't set it
14153
10:02:33,660 --> 10:02:34,660
so that's pretty simple to handle so we
14154
10:02:36,416 --> 10:02:37,416
can change that to BP game instead
14155
10:02:39,480 --> 10:02:40,480
now over here we can try the left Arrow
14156
10:02:43,020 --> 10:02:44,020
logic itself
14157
10:02:45,540 --> 10:02:46,540
so if I type in left
14158
10:02:47,640 --> 10:02:48,640
not sure what else we have
14159
10:02:50,276 --> 10:02:51,276
so left is the only thing we have
14160
10:02:54,900 --> 10:02:55,900
so we can go ahead and try this so left
14161
10:02:57,180 --> 10:02:58,180
Arrow doesn't seem to work
14162
10:03:00,416 --> 10:03:01,416
okay left Arrow works
14163
10:03:02,340 --> 10:03:03,340
so that was the game State issue not
14164
10:03:05,880 --> 10:03:06,880
our thing
14165
10:03:08,096 --> 10:03:09,096
so we can use this logic
14166
10:03:14,340 --> 10:03:15,340
we can linear interpolate instead
14167
10:03:19,020 --> 10:03:20,020
or we have our
14168
10:03:21,320 --> 10:03:22,320
interrupt nodes anyways
14169
10:03:26,340 --> 10:03:27,340
we can have a variable for the Target
14170
10:03:28,680 --> 10:03:29,680
location so this is where you know we
14171
10:03:30,960 --> 10:03:31,960
want to get our character so Target X
14172
10:03:33,720 --> 10:03:34,720
location just to be precise
14173
10:03:38,160 --> 10:03:39,160
so linear interpolate is going to be a
14174
10:03:40,500 --> 10:03:41,500
little tough so F in term 2 is what
14175
10:03:42,900 --> 10:03:43,900
we'll use
14176
10:03:44,700 --> 10:03:45,700
it's a pure function so F enter up to
14177
10:03:49,140 --> 10:03:50,140
f f interrupt to constant because we
14178
10:03:53,160 --> 10:03:54,160
want it to interpolate in a constant
14179
10:03:55,560 --> 10:03:56,560
rate so Delta time is going to be Delta
14180
10:03:58,436 --> 10:03:59,436
seconds interrupt speed we can adjust
14181
10:04:00,660 --> 10:04:01,660
that
14182
10:04:01,800 --> 10:04:02,800
so we can promote this to a variable and
14183
10:04:04,320 --> 10:04:05,320
we can call him
14184
10:04:05,776 --> 10:04:06,776
sideways speed
14185
10:04:09,776 --> 10:04:10,776
over here we can
14186
10:04:12,660 --> 10:04:13,660
replace this with the target X location
14187
10:04:16,800 --> 10:04:17,800
that's going to be the X
14188
10:04:19,800 --> 10:04:20,800
oh this is an integer we'll make this
14189
10:04:21,720 --> 10:04:22,720
float
14190
10:04:25,500 --> 10:04:26,500
so Target X location
14191
10:04:29,240 --> 10:04:30,240
and
14192
10:04:31,200 --> 10:04:32,200
current is going to be our current X
14193
10:04:34,020 --> 10:04:35,020
location
14194
10:04:38,880 --> 10:04:39,880
so Target is our Target X
14195
10:04:41,820 --> 10:04:42,820
current is our current X location so
14196
10:04:45,000 --> 10:04:46,000
current X location
14197
10:04:47,220 --> 10:04:48,220
so we can get the actors X location
14198
10:04:50,096 --> 10:04:51,096
again
14199
10:04:53,460 --> 10:04:54,460
all right
14200
10:04:55,140 --> 10:04:56,140
so this should be it for the sideways
14201
10:04:57,416 --> 10:04:58,416
movement
14202
10:05:00,320 --> 10:05:01,320
and over here we can go ahead and set
14203
10:05:03,240 --> 10:05:04,240
these
14204
10:05:05,220 --> 10:05:06,220
if we want to go left we don't want to
14205
10:05:07,560 --> 10:05:08,560
do anything when we are on the left side
14206
10:05:10,740 --> 10:05:11,740
all right we can get the game State and
14207
10:05:14,936 --> 10:05:15,936
we want to go left so left location
14208
10:05:21,540 --> 10:05:22,540
and we can duplicate that and if we are
14209
10:05:24,540 --> 10:05:25,540
right we can get the center location
14210
10:05:30,540 --> 10:05:31,540
okay but the logic isn't done yet I'll
14211
10:05:33,000 --> 10:05:34,000
get back to it
14212
10:05:35,520 --> 10:05:36,520
so we can use a select to just make
14213
10:05:37,560 --> 10:05:38,560
things a little bit more simple
14214
10:05:42,060 --> 10:05:43,060
so if we are at the center we'll go left
14215
10:05:44,880 --> 10:05:45,880
if we are at the right we'll go to the
14216
10:05:47,040 --> 10:05:48,040
center
14217
10:05:48,540 --> 10:05:49,540
so the logic should make a lot more
14218
10:05:50,756 --> 10:05:51,756
sense now
14219
10:05:53,820 --> 10:05:54,820
and we can set
14220
10:05:56,220 --> 10:05:57,220
this over there
14221
10:05:58,620 --> 10:05:59,620
move it in
14222
10:06:05,756 --> 10:06:06,756
similarly we can copy over this Logic
14223
10:06:08,936 --> 10:06:09,936
for our
14224
10:06:10,860 --> 10:06:11,860
right
14225
10:06:17,220 --> 10:06:18,220
so that it simplifies things a bit so if
14226
10:06:19,380 --> 10:06:20,380
we are on the right we don't want to do
14227
10:06:20,820 --> 10:06:21,820
anything
14228
10:06:21,596 --> 10:06:22,596
we'll go to the center if we are on the
14229
10:06:24,120 --> 10:06:25,120
left
14230
10:06:24,840 --> 10:06:25,840
and we'll go to the right if we are on
14231
10:06:27,840 --> 10:06:28,840
the center so get the right location
14232
10:06:32,936 --> 10:06:33,936
so this is what we'll set it to
14233
10:06:37,380 --> 10:06:38,380
all right now our logic should work once
14234
10:06:41,520 --> 10:06:42,520
if I go ahead and press play so if I put
14235
10:06:44,640 --> 10:06:45,640
put the left Arrow nothing really seems
14236
10:06:47,700 --> 10:06:48,700
to be happening let's just check out why
14237
10:06:51,120 --> 10:06:52,120
okay our end of speed is zero
14238
10:06:54,120 --> 10:06:55,120
okay so now if I try
14239
10:07:00,240 --> 10:07:01,240
all right nothing really happens so
14240
10:07:04,256 --> 10:07:05,256
let's try 100.
14241
10:07:08,460 --> 10:07:09,460
so our actor location
14242
10:07:12,180 --> 10:07:13,180
seems to be fine
14243
10:07:14,220 --> 10:07:15,220
so current
14244
10:07:16,200 --> 10:07:17,200
and Target is okay
14245
10:07:21,120 --> 10:07:22,120
and now we can go ahead and print hello
14246
10:07:27,776 --> 10:07:28,776
so we are not changing the location I
14247
10:07:30,000 --> 10:07:31,000
assume that's what's happening
14248
10:07:36,180 --> 10:07:37,180
so when I press the left
14249
10:07:39,240 --> 10:07:40,240
key on the keyboard
14250
10:07:41,220 --> 10:07:42,220
and when I press the right key so we are
14251
10:07:43,800 --> 10:07:44,800
changing the target X and the target Y
14252
10:07:46,080 --> 10:07:47,080
location
14253
10:07:49,620 --> 10:07:50,620
so we'll try it without the inter first
14254
10:07:55,740 --> 10:07:56,740
a little bit of debugging will
14255
10:08:03,360 --> 10:08:04,360
so we can just copy this in
14256
10:08:09,720 --> 10:08:10,720
so I'll just remove this logic from tick
14257
10:08:15,840 --> 10:08:16,840
if I hit left or right nothing really is
14258
10:08:19,560 --> 10:08:20,560
happening
14259
10:08:23,460 --> 10:08:24,460
so we can print it and check what's
14260
10:08:25,740 --> 10:08:26,740
going on
14261
10:08:29,520 --> 10:08:30,520
all right once again
14262
10:08:31,640 --> 10:08:32,640
the input isn't working we'll use a
14263
10:08:39,120 --> 10:08:40,120
so we'll go ahead and use a on the
14264
10:08:41,096 --> 10:08:42,096
keyboard Maybe
14265
10:08:44,520 --> 10:08:45,520
go ahead and use a
14266
10:08:48,720 --> 10:08:49,720
so if I type in a
14267
10:08:51,596 --> 10:08:52,596
the input okay it's just about the
14268
10:08:54,240 --> 10:08:55,240
window being in focus
14269
10:08:57,540 --> 10:08:58,540
all right so if I go ahead and run this
14270
10:09:00,720 --> 10:09:01,720
okay this works now we can try it with
14271
10:09:03,776 --> 10:09:04,776
the interp logic
14272
10:09:09,800 --> 10:09:10,800
so now we don't need this
14273
10:09:20,096 --> 10:09:21,096
okay the speed is just way too less
14274
10:09:25,200 --> 10:09:26,200
so we can go a bit crazy on this 50
14275
10:09:27,596 --> 10:09:28,596
Maybe
14276
10:09:32,640 --> 10:09:33,640
nope still very slow 200
14277
10:09:40,620 --> 10:09:41,620
okay it's still really slow so 500
14278
10:09:50,276 --> 10:09:51,276
.
14279
10:09:53,096 --> 10:09:54,096
okay this is not going to help
14280
10:09:55,860 --> 10:09:56,860
whoops it's going 50. so if I make this
14281
10:09:59,640 --> 10:10:00,640
500
14282
10:10:03,540 --> 10:10:04,540
okay this is a lot better but maybe 1000
14283
10:10:06,416 --> 10:10:07,416
would be fine
14284
10:10:12,596 --> 10:10:13,596
all right so this seems about right
14285
10:10:18,360 --> 10:10:19,360
but now we need to change our actual
14286
10:10:20,096 --> 10:10:21,096
State itself
14287
10:10:21,840 --> 10:10:22,840
so again we'll use this select node
14288
10:10:24,416 --> 10:10:25,416
right there
14289
10:10:28,500 --> 10:10:29,500
so if we are in the center
14290
10:10:36,300 --> 10:10:37,300
we have to set our side so we'll grab a
14291
10:10:39,840 --> 10:10:40,840
reference to the game state
14292
10:10:41,580 --> 10:10:42,580
and we'll set the side
14293
10:10:46,680 --> 10:10:47,680
depending on where we are
14294
10:10:51,120 --> 10:10:52,120
so if we were at the center and we moved
14295
10:10:53,400 --> 10:10:54,400
left we'll set our side to left
14296
10:10:56,400 --> 10:10:57,400
so Center will set it to the left if we
14297
10:10:58,560 --> 10:10:59,560
were at the left it's going to be left
14298
10:11:00,660 --> 10:11:01,660
itself if we are at the right we'll make
14299
10:11:02,700 --> 10:11:03,700
the center
14300
10:11:05,040 --> 10:11:06,040
copy over the logic
14301
10:11:09,300 --> 10:11:10,300
Okay so
14302
10:11:12,060 --> 10:11:13,060
for this
14303
10:11:14,040 --> 10:11:15,040
so everything will remain the same
14304
10:11:16,080 --> 10:11:17,080
except when we are on the left and we go
14305
10:11:19,800 --> 10:11:20,800
right it's going to be Center if we are
14306
10:11:21,720 --> 10:11:22,720
on the right it's going to remain right
14307
10:11:23,220 --> 10:11:24,220
if we are at the center it's going to go
14308
10:11:25,560 --> 10:11:26,560
right
14309
10:11:29,880 --> 10:11:30,880
okay so now we can go ahead and try this
14310
10:11:31,916 --> 10:11:32,916
out
14311
10:11:33,416 --> 10:11:34,416
so something happened with our logic
14312
10:11:37,140 --> 10:11:38,140
right there
14313
10:11:39,596 --> 10:11:40,596
okay so we had to get the actors
14314
10:11:42,060 --> 10:11:43,060
location instead
14315
10:11:44,340 --> 10:11:45,340
we made it zero so we just sunk under
14316
10:11:46,380 --> 10:11:47,380
the ground
14317
10:11:47,700 --> 10:11:48,700
so go ahead right left right left right
14318
10:11:59,340 --> 10:12:00,340
okay so it is a bit glitchy
14319
10:12:06,416 --> 10:12:07,416
it is a bit glitchy at times
14320
10:12:10,860 --> 10:12:11,860
so let's try enabling teleport sometimes
14321
10:12:13,680 --> 10:12:14,680
that should fix the issue
14322
10:12:18,120 --> 10:12:19,120
okay when I'm at the right he's moving
14323
10:12:21,120 --> 10:12:22,120
to the Center for some reason
14324
10:12:23,220 --> 10:12:24,220
so when I'm at the right and I click
14325
10:12:25,620 --> 10:12:26,620
right again
14326
10:12:27,416 --> 10:12:28,416
so the logic is when I'm at the right
14327
10:12:30,120 --> 10:12:31,120
and I click right again I should still
14328
10:12:32,276 --> 10:12:33,276
remain at the right when I am at the
14329
10:12:34,436 --> 10:12:35,436
left I move to the center
14330
10:12:37,680 --> 10:12:38,680
so let's try that
14331
10:12:40,436 --> 10:12:41,436
so I go to the right
14332
10:12:42,660 --> 10:12:43,660
click right again I go to the Center for
14333
10:12:45,060 --> 10:12:46,060
some reason
14334
10:12:46,620 --> 10:12:47,620
so when I'm on the right the target
14335
10:12:50,400 --> 10:12:51,400
shouldn't actually be this it should be
14336
10:12:52,560 --> 10:12:53,560
the right location itself
14337
10:12:54,300 --> 10:12:55,300
when I'm on the left this shouldn't be 0
14338
10:12:56,276 --> 10:12:57,276
this should be the left location itself
14339
10:12:59,820 --> 10:13:00,820
because you're doing the inter Pawn tick
14340
10:13:01,800 --> 10:13:02,800
so that's why it's happening
14341
10:13:03,540 --> 10:13:04,540
left right and Center
14342
10:13:08,400 --> 10:13:09,400
all right so now our logic is working
14343
10:13:10,500 --> 10:13:11,500
totally fine and we can stop printing
14344
10:13:13,140 --> 10:13:14,140
hello it's just annoying at this point
14345
10:13:17,096 --> 10:13:18,096
okay then I think we exceeded one hour
14346
10:13:19,320 --> 10:13:20,320
okay we're pretty close
14347
10:13:21,120 --> 10:13:22,120
but we are left with our last few steps
14348
10:13:24,000 --> 10:13:25,000
now we have to make the obstacle move
14349
10:13:26,700 --> 10:13:27,700
which is pretty simple
14350
10:13:29,700 --> 10:13:30,700
now we can spawn it dynamically instead
14351
10:13:32,276 --> 10:13:33,276
rather than spawning it or rather just
14352
10:13:35,276 --> 10:13:36,276
using this
14353
10:13:36,540 --> 10:13:37,540
I think we are spawning it yep we are
14354
10:13:40,500 --> 10:13:41,500
so I can press f8 head into my
14355
10:13:43,680 --> 10:13:44,680
perspective View
14356
10:13:46,200 --> 10:13:47,200
and now for the magic
14357
10:13:50,160 --> 10:13:51,160
head to the obstacle blueprint itself
14358
10:13:54,540 --> 10:13:55,540
course obstacle base
14359
10:13:57,240 --> 10:13:58,240
we can try this on tick
14360
10:13:59,820 --> 10:14:00,820
so on tick we want to set the actor's
14361
10:14:03,660 --> 10:14:04,660
location so we want to change the
14362
10:14:06,180 --> 10:14:07,180
location of this actor
14363
10:14:08,400 --> 10:14:09,400
we will get the current location so get
14364
10:14:11,220 --> 10:14:12,220
the location of this actor so get actor
14365
10:14:13,560 --> 10:14:14,560
location
14366
10:14:14,580 --> 10:14:15,580
and
14367
10:14:16,620 --> 10:14:17,620
when we move forward we are increasing
14368
10:14:19,320 --> 10:14:20,320
the y basically
14369
10:14:22,680 --> 10:14:23,680
so when we move forward we are
14370
10:14:25,140 --> 10:14:26,140
increasing the Y
14371
10:14:27,960 --> 10:14:28,960
so the logic was wrong okay when we move
14372
10:14:31,560 --> 10:14:32,560
forward we are going more towards the
14373
10:14:34,020 --> 10:14:35,020
negative y direction
14374
10:14:39,120 --> 10:14:40,120
so
14375
10:14:41,640 --> 10:14:42,640
what we can do is we can go ahead and
14376
10:14:43,860 --> 10:14:44,860
move it backwards so we want to increase
14377
10:14:46,680 --> 10:14:47,680
the Y
14378
10:14:49,080 --> 10:14:50,080
so the x is going to remain constant
14379
10:14:52,916 --> 10:14:53,916
the X will be as is
14380
10:14:56,640 --> 10:14:57,640
delete that
14381
10:14:58,200 --> 10:14:59,200
split the strut pin Z is going to remain
14382
10:15:01,140 --> 10:15:02,140
constant but Y is going to be y Plus
14383
10:15:06,776 --> 10:15:07,776
let's just say 1
14384
10:15:09,300 --> 10:15:10,300
times Delta time Delta seconds let's try
14385
10:15:12,900 --> 10:15:13,900
Delta seconds itself first this should
14386
10:15:15,596 --> 10:15:16,596
remain constant for All actors because
14387
10:15:17,640 --> 10:15:18,640
this is tied to frame rate
14388
10:15:21,720 --> 10:15:22,720
so I think it's moving but it's moving
14389
10:15:24,300 --> 10:15:25,300
very very slowly
14390
10:15:26,880 --> 10:15:27,880
yep it is moving as you can see but it's
14391
10:15:30,360 --> 10:15:31,360
moving very very slowly
14392
10:15:32,700 --> 10:15:33,700
so we can just go ahead and multiply
14393
10:15:34,436 --> 10:15:35,436
this so multiply this by some value
14394
10:15:39,060 --> 10:15:40,060
let's just say we multiply this by 100
14395
10:15:45,900 --> 10:15:46,900
so not sure if
14396
10:15:48,416 --> 10:15:49,416
yep there we have it
14397
10:15:52,436 --> 10:15:53,436
so as you can notice it's not actually
14398
10:15:55,020 --> 10:15:56,020
the character that's moving it's the
14399
10:15:57,060 --> 10:15:58,060
whole obstacle course which is moving
14400
10:16:01,320 --> 10:16:02,320
and what's weird is our characters
14401
10:16:03,180 --> 10:16:04,180
actually following it even though we
14402
10:16:05,160 --> 10:16:06,160
haven't actually attached him over there
14403
10:16:13,080 --> 10:16:14,080
okay so we can fix the
14404
10:16:15,596 --> 10:16:16,596
uh X location of the character as well
14405
10:16:18,660 --> 10:16:19,660
because he seems to be just sliding
14406
10:16:21,360 --> 10:16:22,360
along
14407
10:16:24,120 --> 10:16:25,120
so there is actually a setting somewhere
14408
10:16:26,096 --> 10:16:27,096
here
14409
10:16:29,580 --> 10:16:30,580
so it shouldn't slide along the surface
14410
10:16:33,596 --> 10:16:34,596
so something or there
14411
10:16:37,320 --> 10:16:38,320
character movement Maybe
14412
10:16:40,756 --> 10:16:41,756
and there is
14413
10:16:43,380 --> 10:16:44,380
something over here okay ground friction
14414
10:16:45,480 --> 10:16:46,480
let's try zero on that
14415
10:16:49,800 --> 10:16:50,800
okay we are just still moving back so if
14416
10:16:52,620 --> 10:16:53,620
it if I hit f8 actually the whole thing
14417
10:16:56,220 --> 10:16:57,220
is moving back
14418
10:16:59,520 --> 10:17:00,520
so instead of that we will just set the
14419
10:17:01,916 --> 10:17:02,916
uh location the X location every time to
14420
10:17:05,580 --> 10:17:06,580
be constant
14421
10:17:07,800 --> 10:17:08,800
or rather the Y location
14422
10:17:10,140 --> 10:17:11,140
I'm not sure what it was so we'll copy
14423
10:17:13,080 --> 10:17:14,080
it
14424
10:17:14,096 --> 10:17:15,096
so Y is negative 270 so negative to 70.
14425
10:17:19,256 --> 10:17:20,256
I don't want that to change
14426
10:17:22,436 --> 10:17:23,436
and as you can see our logic is working
14427
10:17:27,120 --> 10:17:28,120
and it seems like we are moving forward
14428
10:17:29,160 --> 10:17:30,160
the speed is something which we can
14429
10:17:31,080 --> 10:17:32,080
worry about a bit later so maybe make
14430
10:17:33,000 --> 10:17:34,000
this 300
14431
10:17:36,060 --> 10:17:37,060
and as you can see it feels like
14432
10:17:38,700 --> 10:17:39,700
they're actually moving but what's
14433
10:17:40,500 --> 10:17:41,500
actually happening is the whole course
14434
10:17:42,360 --> 10:17:43,360
is just moving the character is actually
14435
10:17:45,300 --> 10:17:46,300
standing still
14436
10:17:47,580 --> 10:17:48,580
so
14437
10:17:49,020 --> 10:17:50,020
now our man is going forward
14438
10:17:51,776 --> 10:17:52,776
we can finally go ahead and set up the
14439
10:17:54,416 --> 10:17:55,416
obstacles itself I guess
14440
10:17:56,700 --> 10:17:57,700
and add in a jump State obviously
14441
10:17:59,160 --> 10:18:00,160
because right now he doesn't jump so we
14442
10:18:01,320 --> 10:18:02,320
can adjust the speed maybe 350 a little
14443
10:18:03,776 --> 10:18:04,776
more quick would have been nice
14444
10:18:08,220 --> 10:18:09,220
go ahead
14445
10:18:11,640 --> 10:18:12,640
okay with that something we'll worry
14446
10:18:13,200 --> 10:18:14,200
about later
14447
10:18:16,500 --> 10:18:17,500
now
14448
10:18:18,060 --> 10:18:19,060
uh for our next step
14449
10:18:20,520 --> 10:18:21,520
so I don't think we really require
14450
10:18:22,080 --> 10:18:23,080
teleport so our X Y and Z is all set
14451
10:18:26,820 --> 10:18:27,820
so for this we'll be using the jump as
14452
10:18:29,700 --> 10:18:30,700
well so we'll go ahead and create a
14453
10:18:33,000 --> 10:18:34,000
binding for our space bar
14454
10:18:35,936 --> 10:18:36,936
space bar and we'll call this one jump
14455
10:18:41,820 --> 10:18:42,820
and when I release this we are going to
14456
10:18:43,800 --> 10:18:44,800
stop jumping
14457
10:18:47,700 --> 10:18:48,700
okay
14458
10:18:49,560 --> 10:18:50,560
so now we should in theory just go up
14459
10:18:54,480 --> 10:18:55,480
we can adjust the settings of the jump
14460
10:18:56,700 --> 10:18:57,700
under our character movement component
14461
10:18:59,700 --> 10:19:00,700
and we can also have animations so
14462
10:19:04,200 --> 10:19:05,200
under our animation blueprint we can set
14463
10:19:06,360 --> 10:19:07,360
it up
14464
10:19:07,436 --> 10:19:08,436
so content blueprints game character
14465
10:19:11,460 --> 10:19:12,460
and MVP
14466
10:19:14,096 --> 10:19:15,096
we can ignore this and we can add a
14467
10:19:16,620 --> 10:19:17,620
state and this is going to be jump
14468
10:19:20,240 --> 10:19:21,240
jump start
14469
10:19:22,980 --> 10:19:23,980
and jump Loop
14470
10:19:26,700 --> 10:19:27,700
jump Loop
14471
10:19:29,700 --> 10:19:30,700
all right so jump start
14472
10:19:33,300 --> 10:19:34,300
jump Loop
14473
10:19:35,936 --> 10:19:36,936
and we'll see what animations we have
14474
10:19:40,320 --> 10:19:41,320
and from our jump Loop
14475
10:19:43,740 --> 10:19:44,740
we want to go back to our run animation
14476
10:19:46,620 --> 10:19:47,620
basically
14477
10:19:48,960 --> 10:19:49,960
so jump start is going to be a third
14478
10:19:51,720 --> 10:19:52,720
person jump
14479
10:19:54,180 --> 10:19:55,180
and for the transition we'll have we'll
14480
10:19:58,080 --> 10:19:59,080
check if we are jumping
14481
10:20:01,040 --> 10:20:02,040
so if we have our character reference
14482
10:20:03,776 --> 10:20:04,776
here
14483
10:20:06,596 --> 10:20:07,596
so
14484
10:20:09,060 --> 10:20:10,060
is there any variable
14485
10:20:13,380 --> 10:20:14,380
not sure
14486
10:20:15,300 --> 10:20:16,300
we can try this
14487
10:20:20,700 --> 10:20:21,700
okay nothing's really happening
14488
10:20:23,640 --> 10:20:24,640
okay we are getting a runtime error
14489
10:20:27,360 --> 10:20:28,360
saying we don't have
14490
10:20:30,240 --> 10:20:31,240
the character ref
14491
10:20:33,960 --> 10:20:34,960
so we'll only access this in the anim
14492
10:20:36,240 --> 10:20:37,240
graph
14493
10:20:39,240 --> 10:20:40,240
so go ahead if this is valid we will go
14494
10:20:42,416 --> 10:20:43,416
ahead and okay we can check if it is not
14495
10:20:45,660 --> 10:20:46,660
valid first of all
14496
10:20:51,000 --> 10:20:52,000
so we only get it once
14497
10:20:53,580 --> 10:20:54,580
and occasionally it's going not valid
14498
10:20:57,596 --> 10:20:58,596
so we can promote this two variable and
14499
10:21:00,240 --> 10:21:01,240
call this one jumping
14500
10:21:07,096 --> 10:21:08,096
and
14501
10:21:08,820 --> 10:21:09,820
in our transition
14502
10:21:12,180 --> 10:21:13,180
you can set it up
14503
10:21:16,320 --> 10:21:17,320
okay so the variable isn't doing
14504
10:21:18,240 --> 10:21:19,240
anything
14505
10:21:23,276 --> 10:21:24,276
so we can head back to the character and
14506
10:21:27,000 --> 10:21:28,000
create a variable for it in the first
14507
10:21:28,860 --> 10:21:29,860
place
14508
10:21:30,300 --> 10:21:31,300
so jumping
14509
10:21:36,300 --> 10:21:37,300
now we can go ahead and set this to true
14510
10:21:40,436 --> 10:21:41,436
we can go ahead and set this to false as
14511
10:21:42,900 --> 10:21:43,900
soon as we release it
14512
10:21:48,360 --> 10:21:49,360
get jumping
14513
10:21:54,060 --> 10:21:55,060
okay this logic should work
14514
10:21:57,120 --> 10:21:58,120
uh this is jump start to jump Loop so
14515
10:22:00,240 --> 10:22:01,240
when
14516
10:22:01,080 --> 10:22:02,080
our time remaining for our jump
14517
10:22:07,200 --> 10:22:08,200
is less than let's say 0.05 seconds
14518
10:22:11,276 --> 10:22:12,276
we'll enter this transition
14519
10:22:14,580 --> 10:22:15,580
and jump Loop to third person run when
14520
10:22:17,756 --> 10:22:18,756
this jumping is false basically
14521
10:22:21,596 --> 10:22:22,596
so not
14522
10:22:25,560 --> 10:22:26,560
not Boolean I guess it's called
14523
10:22:28,916 --> 10:22:29,916
so we'll just invert the value
14524
10:22:31,980 --> 10:22:32,980
now if I go ahead and press space okay
14525
10:22:34,980 --> 10:22:35,980
the animation is weird
14526
10:22:41,880 --> 10:22:42,880
so we can
14527
10:22:45,120 --> 10:22:46,120
again do and maybe and
14528
10:22:49,200 --> 10:22:50,200
if the jump Loop has at least played
14529
10:22:51,480 --> 10:22:52,480
once so jump Loop
14530
10:22:56,640 --> 10:22:57,640
so we can get access to the jump Loop
14531
10:22:59,096 --> 10:23:00,096
here
14532
10:23:01,560 --> 10:23:02,560
so time remaining time
14533
10:23:04,276 --> 10:23:05,276
remaining for the jump Loop
14534
10:23:08,096 --> 10:23:09,096
is less than 0.05 we can try this logic
14535
10:23:17,276 --> 10:23:18,276
okay we just went into a completely
14536
10:23:19,620 --> 10:23:20,620
random State there again probably some
14537
10:23:22,860 --> 10:23:23,860
logical error
14538
10:23:27,900 --> 10:23:28,900
okay so in our jump Loop we haven't fed
14539
10:23:30,180 --> 10:23:31,180
the animation
14540
10:23:37,680 --> 10:23:38,680
okay
14541
10:23:40,140 --> 10:23:41,140
so our jumping logic is working
14542
10:23:47,580 --> 10:23:48,580
so we can change this to maybe something
14543
10:23:50,040 --> 10:23:51,040
a little more smaller
14544
10:23:53,180 --> 10:23:54,180
0.02 so this is going to feel a lot
14545
10:23:56,400 --> 10:23:57,400
smoother
14546
10:24:00,776 --> 10:24:01,776
okay
14547
10:24:02,880 --> 10:24:03,880
so we are jumping
14548
10:24:07,320 --> 10:24:08,320
now we can start adding the actual
14549
10:24:09,480 --> 10:24:10,480
obstacles
14550
10:24:14,580 --> 10:24:15,580
under the course we can
14551
10:24:18,360 --> 10:24:19,360
head into obstacle base and over here we
14552
10:24:20,936 --> 10:24:21,936
don't want anything this is not
14553
10:24:22,200 --> 10:24:23,200
something we'll actually be spawning
14554
10:24:24,000 --> 10:24:25,000
obviously
14555
10:24:25,680 --> 10:24:26,680
obviously what will spawn is going to be
14556
10:24:28,080 --> 10:24:29,080
these
14557
10:24:30,060 --> 10:24:31,060
so
14558
10:24:33,120 --> 10:24:34,120
under obstacle one we can have stuff
14559
10:24:36,720 --> 10:24:37,720
I'm not even sure at this point if
14560
10:24:38,340 --> 10:24:39,340
you're able to see the sides we're
14561
10:24:40,080 --> 10:24:41,080
barely able to see it
14562
10:24:44,340 --> 10:24:45,340
and we also need to destroy it once we
14563
10:24:47,096 --> 10:24:48,096
actually reach a certain point
14564
10:24:49,256 --> 10:24:50,256
and we also need to keep spawning it
14565
10:24:52,020 --> 10:24:53,020
basically
14566
10:24:56,520 --> 10:24:57,520
so wherever our player start is
14567
10:25:02,160 --> 10:25:03,160
so let's go ahead and add a trigger
14568
10:25:05,220 --> 10:25:06,220
volume
14569
10:25:09,300 --> 10:25:10,300
so trigger box
14570
10:25:18,960 --> 10:25:19,960
so the x is going to be 20.
14571
10:25:24,900 --> 10:25:25,900
the Y is going to be
14572
10:25:27,840 --> 10:25:28,840
whatever this is and Z is going to be
14573
10:25:31,380 --> 10:25:32,380
0 let's say
14574
10:25:34,320 --> 10:25:35,320
and we'll just increase the extent of
14575
10:25:37,140 --> 10:25:38,140
the box maybe 500
14576
10:25:41,340 --> 10:25:42,340
500 and 500.
14577
10:25:45,776 --> 10:25:46,776
okay and we'll set the hidden in game to
14578
10:25:48,360 --> 10:25:49,360
false so hidden in game is false
14579
10:25:52,140 --> 10:25:53,140
so f8
14580
10:25:56,540 --> 10:25:57,540
so this can go way ahead
14581
10:26:07,020 --> 10:26:08,020
so a little more
14582
10:26:11,936 --> 10:26:12,936
so we can select this trigger box
14583
10:26:15,840 --> 10:26:16,840
and we can do
14584
10:26:17,820 --> 10:26:18,820
times two
14585
10:26:20,936 --> 10:26:21,936
by the way that's a pretty handy thing
14586
10:26:22,560 --> 10:26:23,560
which you can do in Blueprint
14587
10:26:25,800 --> 10:26:26,800
so just a little bit more
14588
10:26:36,480 --> 10:26:37,480
so more
14589
10:26:44,520 --> 10:26:45,520
okay I want to simulate now
14590
10:26:46,740 --> 10:26:47,740
so go ahead and simulate
14591
10:26:56,756 --> 10:26:57,756
okay so as soon as we end overlap on
14592
10:27:00,900 --> 10:27:01,900
this we want to spawn a new one so
14593
10:27:03,900 --> 10:27:04,900
go ahead
14594
10:27:05,640 --> 10:27:06,640
on actor and overlap
14595
10:27:12,416 --> 10:27:13,416
on actor and develop trigger box we'll
14596
10:27:14,820 --> 10:27:15,820
try to print first
14597
10:27:20,220 --> 10:27:21,220
okay
14598
10:27:21,596 --> 10:27:22,596
so as soon as we go out of this
14599
10:27:24,596 --> 10:27:25,596
first of all for the last index we'll go
14600
10:27:27,960 --> 10:27:28,960
ahead and promote this to a variable
14601
10:27:30,480 --> 10:27:31,480
so we'll call this one last spawn
14602
10:27:33,720 --> 10:27:34,720
obstacle
14603
10:27:37,980 --> 10:27:38,980
so we'll always have a reference to that
14604
10:27:42,120 --> 10:27:43,120
go ahead copy this over
14605
10:27:45,060 --> 10:27:46,060
so spawn actor
14606
10:27:47,220 --> 10:27:48,220
we will make use of this
14607
10:27:50,040 --> 10:27:51,040
remember we had our Arrow component
14608
10:27:54,596 --> 10:27:55,596
so
14609
10:27:55,860 --> 10:27:56,860
the the arrow which is there opposite to
14610
10:27:59,040 --> 10:28:00,040
the origin is what we need
14611
10:28:00,960 --> 10:28:01,960
game course obstacle base
14612
10:28:03,596 --> 10:28:04,596
so near the origin we have an arrow and
14613
10:28:06,300 --> 10:28:07,300
over here as well we have an arrow we'll
14614
10:28:08,880 --> 10:28:09,880
make use of this Arrow
14615
10:28:11,700 --> 10:28:12,700
so the location of this Arrow so this is
14616
10:28:14,580 --> 10:28:15,580
called Arrow one so we'll call this one
14617
10:28:16,500 --> 10:28:17,500
end
14618
10:28:17,936 --> 10:28:18,936
so that's a little more descriptive
14619
10:28:20,936 --> 10:28:21,936
under the level blueprint now
14620
10:28:24,000 --> 10:28:25,000
so we'll get the end
14621
10:28:27,840 --> 10:28:28,840
so get and
14622
10:28:31,916 --> 10:28:32,916
so get and
14623
10:28:34,436 --> 10:28:35,436
and from end we can
14624
10:28:37,740 --> 10:28:38,740
get
14625
10:28:40,020 --> 10:28:41,020
uh get the location
14626
10:28:42,596 --> 10:28:43,596
so get World location
14627
10:28:45,960 --> 10:28:46,960
and we can probably copy this over just
14628
10:28:49,080 --> 10:28:50,080
like that
14629
10:28:51,000 --> 10:28:52,000
and we can change this to this
14630
10:28:55,436 --> 10:28:56,436
and the rest of the logic should
14631
10:28:57,120 --> 10:28:58,120
actually work just like that
14632
10:29:01,200 --> 10:29:02,200
okay so now
14633
10:29:04,256 --> 10:29:05,256
if we actually wait for this
14634
10:29:06,720 --> 10:29:07,720
as soon as this goes away one more is
14635
10:29:10,256 --> 10:29:11,256
going to be spawned
14636
10:29:12,416 --> 10:29:13,416
but there's another thing uh we want to
14637
10:29:15,180 --> 10:29:16,180
destroy it uh once we actually
14638
10:29:19,020 --> 10:29:20,020
go after a certain point we want to
14639
10:29:21,000 --> 10:29:22,000
actually just destroy it like once we
14640
10:29:23,276 --> 10:29:24,276
are behind the player we have no reason
14641
10:29:25,020 --> 10:29:26,020
to still have it so we can have a
14642
10:29:27,720 --> 10:29:28,720
trigger box for that once again so 500
14643
10:29:31,140 --> 10:29:32,140
maybe 500
14644
10:29:34,620 --> 10:29:35,620
and 500
14645
10:29:38,400 --> 10:29:39,400
go ahead and over here as well we'll set
14646
10:29:41,160 --> 10:29:42,160
up begin overlap for this instead
14647
10:29:44,096 --> 10:29:45,096
so on actor beginner
14648
10:29:47,640 --> 10:29:48,640
so begin overlap
14649
10:29:51,540 --> 10:29:52,540
on active begin overlap destroy Act
14650
10:29:58,140 --> 10:29:59,140
okay let's try this out
14651
10:30:04,140 --> 10:30:05,140
so I'm not sure where this box is
14652
10:30:14,700 --> 10:30:15,700
let's unhide it so hidden game
14653
10:30:18,416 --> 10:30:19,416
set to false
14654
10:30:22,740 --> 10:30:23,740
okay so in theory we should be
14655
10:30:24,900 --> 10:30:25,900
destroying it okay we destroyed
14656
10:30:28,436 --> 10:30:29,436
the Box itself
14657
10:30:30,120 --> 10:30:31,120
so other actors what we have to destroy
14658
10:30:37,256 --> 10:30:38,256
whoops
14659
10:30:38,640 --> 10:30:39,640
we need to take this a little more
14660
10:30:40,200 --> 10:30:41,200
further back
14661
10:30:50,220 --> 10:30:51,220
so now if we wait for it to reach there
14662
10:30:56,416 --> 10:30:57,416
so we are continuously spawning the box
14663
10:30:59,700 --> 10:31:00,700
over there
14664
10:31:01,800 --> 10:31:02,800
and if I actually head back into my view
14665
10:31:04,860 --> 10:31:05,860
I cannot see anything happening
14666
10:31:07,980 --> 10:31:08,980
and our world is spawning normally
14667
10:31:10,916 --> 10:31:11,916
how cool
14668
10:31:15,120 --> 10:31:16,120
so over here we can add a couple of
14669
10:31:17,096 --> 10:31:18,096
things so obstacle one we can add a few
14670
10:31:19,620 --> 10:31:20,620
shipping containers Maybe
14671
10:31:22,680 --> 10:31:23,680
oh we can make it random actually that
14672
10:31:25,620 --> 10:31:26,620
would be nice
14673
10:31:27,180 --> 10:31:28,180
if we just make this completely random
14674
10:31:37,620 --> 10:31:38,620
so somewhere at the center
14675
10:31:40,320 --> 10:31:41,320
I'm not sure where the center is I think
14676
10:31:42,480 --> 10:31:43,480
it's negative 1600
14677
10:31:47,040 --> 10:31:48,040
so this is where the center is going to
14678
10:31:48,900 --> 10:31:49,900
be
14679
10:31:52,020 --> 10:31:53,020
oops I moved the end itself so first
14680
10:31:54,900 --> 10:31:55,900
duplicate it
14681
10:31:56,520 --> 10:31:57,520
and this is going to be negative 1600
14682
10:32:00,300 --> 10:32:01,300
this going to be Center obstacle
14683
10:32:06,900 --> 10:32:07,900
and
14684
10:32:10,500 --> 10:32:11,500
we can go ahead and duplicate this
14685
10:32:13,740 --> 10:32:14,740
and this is not going to be called
14686
10:32:15,540 --> 10:32:16,540
Center obstacle this is going to be
14687
10:32:17,040 --> 10:32:18,040
called Left obstacle
14688
10:32:20,040 --> 10:32:21,040
and we can call this one right obstacle
14689
10:32:26,160 --> 10:32:27,160
so our right obstacle is going to be to
14690
10:32:29,756 --> 10:32:30,756
the right obviously
14691
10:32:31,740 --> 10:32:32,740
and our left obstacle is going to be to
14692
10:32:34,320 --> 10:32:35,320
the left obviously
14693
10:32:36,060 --> 10:32:37,060
so this is 250 this negative 250.
14694
10:32:42,360 --> 10:32:43,360
okay
14695
10:32:44,400 --> 10:32:45,400
so we have set that up we should have
14696
10:32:46,320 --> 10:32:47,320
done this in the base actually
14697
10:32:48,120 --> 10:32:49,120
so we'll cut this and we'll paste this
14698
10:32:50,040 --> 10:32:51,040
in a base
14699
10:32:54,416 --> 10:32:55,416
so
14700
10:32:56,460 --> 10:32:57,460
don't mind that
14701
10:33:00,660 --> 10:33:01,660
now we should have our obstacle both in
14702
10:33:02,640 --> 10:33:03,640
the base and the others and obviously
14703
10:33:05,276 --> 10:33:06,276
the logic is going to be in base itself
14704
10:33:09,596 --> 10:33:10,596
so since we are randomly spawning it
14705
10:33:11,880 --> 10:33:12,880
it's totally fine
14706
10:33:13,680 --> 10:33:14,680
we can use the base itself I assume
14707
10:33:17,580 --> 10:33:18,580
now in the event graph
14708
10:33:20,040 --> 10:33:21,040
on event begin play
14709
10:33:24,416 --> 10:33:25,416
we can go ahead and create
14710
10:33:28,320 --> 10:33:29,320
a static mesh or rather spawn a static
14711
10:33:30,660 --> 10:33:31,660
mesh at that location
14712
10:33:32,820 --> 10:33:33,820
for that we'll need a few actor classes
14713
10:33:35,220 --> 10:33:36,220
so obstacles
14714
10:33:37,080 --> 10:33:38,080
over here we can delete this
14715
10:33:41,340 --> 10:33:42,340
and
14716
10:33:44,096 --> 10:33:45,096
if we play everything should work
14717
10:33:49,256 --> 10:33:50,256
however
14718
10:33:51,740 --> 10:33:52,740
under r
14719
10:33:54,840 --> 10:33:55,840
under this folder we can
14720
10:33:57,480 --> 10:33:58,480
make a few actors actually
14721
10:34:00,776 --> 10:34:01,776
so obstacles
14722
10:34:04,380 --> 10:34:05,380
we'll call this path actually
14723
10:34:08,220 --> 10:34:09,220
path underscore base in case we need any
14724
10:34:11,220 --> 10:34:12,220
derived classes
14725
10:34:14,520 --> 10:34:15,520
now click on blueprint class actor
14726
10:34:18,660 --> 10:34:19,660
and this is just going to be obstacle
14727
10:34:21,240 --> 10:34:22,240
one
14728
10:34:23,480 --> 10:34:24,480
uh few will be dodgable few will be not
14729
10:34:26,276 --> 10:34:27,276
so we'll make a dodgeable and
14730
10:34:29,400 --> 10:34:30,400
non-dodgeable obstacles
14731
10:34:32,520 --> 10:34:33,520
dot double
14732
10:34:36,120 --> 10:34:37,120
I will just have three for each
14733
10:34:40,620 --> 10:34:41,620
will create Childs
14734
10:34:44,040 --> 10:34:45,040
so child
14735
10:34:45,900 --> 10:34:46,900
Ctrl D Ctrl d
14736
10:34:49,520 --> 10:34:50,520
and we'll name this one child three so
14737
10:34:53,160 --> 10:34:54,160
one two three
14738
10:34:55,020 --> 10:34:56,020
so this one is going to be non-dodgeable
14739
10:35:00,776 --> 10:35:01,776
so we'll go ahead and create a child
14740
10:35:03,660 --> 10:35:04,660
Ctrl D Ctrl d
14741
10:35:07,436 --> 10:35:08,436
and this is going to be Child 3
14742
10:35:09,596 --> 10:35:10,596
obviously
14743
10:35:12,240 --> 10:35:13,240
okay
14744
10:35:13,560 --> 10:35:14,560
so finally we can go ahead and add stuff
14745
10:35:16,860 --> 10:35:17,860
to these obstacles
14746
10:35:19,380 --> 10:35:20,380
so optic obstacle dodgeable child one
14747
10:35:24,720 --> 10:35:25,720
we can instead of the default scene root
14748
10:35:27,480 --> 10:35:28,480
obviously
14749
10:35:28,680 --> 10:35:29,680
obstacle dodgable here as well
14750
10:35:31,320 --> 10:35:32,320
we'll simply have a static mesh
14751
10:35:34,740 --> 10:35:35,740
so static mesh
14752
10:35:37,436 --> 10:35:38,436
so that's done
14753
10:35:40,740 --> 10:35:41,740
I will leave the root it's fine
14754
10:35:44,096 --> 10:35:45,096
and we can look for some stuff here
14755
10:35:48,320 --> 10:35:49,320
so we have quite a few meshes so we can
14756
10:35:51,300 --> 10:35:52,300
have a barrel
14757
10:35:52,436 --> 10:35:53,436
in one place
14758
10:35:54,060 --> 10:35:55,060
so we can have boxes we can have barrels
14759
10:35:56,220 --> 10:35:57,220
we have so many options here
14760
10:35:58,380 --> 10:35:59,380
so we're going to select this let's say
14761
10:36:06,240 --> 10:36:07,240
let's try this
14762
10:36:10,436 --> 10:36:11,436
so in path
14763
10:36:12,360 --> 10:36:13,360
you want to spawn actor from class
14764
10:36:22,680 --> 10:36:23,680
so for the class we'll make this
14765
10:36:24,960 --> 10:36:25,960
obstacle dodgeable
14766
10:36:30,000 --> 10:36:31,000
so spawn transform is going to be this
14767
10:36:33,416 --> 10:36:34,416
so oops
14768
10:36:35,820 --> 10:36:36,820
uh Center obstacle let's try this first
14769
10:36:38,276 --> 10:36:39,276
so Center obstacle
14770
10:36:41,400 --> 10:36:42,400
and get word transform
14771
10:36:46,680 --> 10:36:47,680
go ahead and try this out
14772
10:36:52,436 --> 10:36:53,436
okay it's just sliding along for some
14773
10:36:55,140 --> 10:36:56,140
reason
14774
10:36:59,520 --> 10:37:00,520
and we want to attach it yeah that's the
14775
10:37:01,916 --> 10:37:02,916
reason so
14776
10:37:04,500 --> 10:37:05,500
attached to component
14777
10:37:08,460 --> 10:37:09,460
we want to attach this to our actual
14778
10:37:11,936 --> 10:37:12,936
plane or we can just uh do it for the
14779
10:37:17,160 --> 10:37:18,160
root component
14780
10:37:22,020 --> 10:37:23,020
so now
14781
10:37:23,160 --> 10:37:24,160
in theory this should work
14782
10:37:29,220 --> 10:37:30,220
okay so this seems to be working fine
14783
10:37:33,840 --> 10:37:34,840
uh one more thing we can make this a bit
14784
10:37:35,936 --> 10:37:36,936
faster actually
14785
10:37:38,220 --> 10:37:39,220
now we can promote this to variable
14786
10:37:40,620 --> 10:37:41,620
so speed
14787
10:37:44,820 --> 10:37:45,820
so we'll make this one 500.
14788
10:37:51,416 --> 10:37:52,416
okay as soon as we hit something uh we
14789
10:37:54,776 --> 10:37:55,776
should stop
14790
10:37:56,756 --> 10:37:57,756
and our game should get over
14791
10:38:02,880 --> 10:38:03,880
so we'll have event hit here
14792
10:38:06,240 --> 10:38:07,240
first we'll print something
14793
10:38:11,220 --> 10:38:12,220
go ahead and test this out
14794
10:38:17,936 --> 10:38:18,936
so if the other actor is an obstacle
14795
10:38:22,436 --> 10:38:23,436
pass to obstacle
14796
10:38:25,080 --> 10:38:26,080
uh we should have made a base class to
14797
10:38:27,240 --> 10:38:28,240
be honest
14798
10:38:29,700 --> 10:38:30,700
go ahead and
14799
10:38:31,860 --> 10:38:32,860
head into content blueprint game
14800
10:38:35,160 --> 10:38:36,160
course obstacles
14801
10:38:37,916 --> 10:38:38,916
we'll create one called
14802
10:38:40,320 --> 10:38:41,320
actor of
14803
10:38:43,140 --> 10:38:44,140
type obstacle
14804
10:38:46,860 --> 10:38:47,860
obstacle base
14805
10:38:49,020 --> 10:38:50,020
and will inherit these from
14806
10:38:51,720 --> 10:38:52,720
the base classes
14807
10:38:54,916 --> 10:38:55,916
so class settings
14808
10:38:58,256 --> 10:38:59,256
so obstacle
14809
10:39:01,380 --> 10:39:02,380
obstacle base
14810
10:39:06,060 --> 10:39:07,060
and these will also change
14811
10:39:09,840 --> 10:39:10,840
so We'll Inherit this from obstacle base
14812
10:39:12,720 --> 10:39:13,720
so obstacle base
14813
10:39:16,380 --> 10:39:17,380
obstacle base
14814
10:39:19,680 --> 10:39:20,680
all right so we can go ahead and cast to
14815
10:39:22,980 --> 10:39:23,980
obstacle base
14816
10:39:26,096 --> 10:39:27,096
and we're going to print
14817
10:39:29,276 --> 10:39:30,276
or rather we can just exit the game
14818
10:39:30,960 --> 10:39:31,960
execute console command
14819
10:39:33,776 --> 10:39:34,776
and we'll type in exit let's try this
14820
10:39:40,200 --> 10:39:41,200
okay our logic is working
14821
10:39:45,060 --> 10:39:46,060
okay we still hit it
14822
10:39:47,700 --> 10:39:48,700
so we need a better jumping logic
14823
10:39:51,300 --> 10:39:52,300
that's that's the problem with our
14824
10:39:52,860 --> 10:39:53,860
jumping logic it's not our
14825
10:39:55,740 --> 10:39:56,740
obstacles
14826
10:39:58,980 --> 10:39:59,980
so
14827
10:40:00,416 --> 10:40:01,416
under this
14828
10:40:03,660 --> 10:40:04,660
we can go ahead and change stuff in the
14829
10:40:07,140 --> 10:40:08,140
character moment so under jump
14830
10:40:11,096 --> 10:40:12,096
we should
14831
10:40:13,800 --> 10:40:14,800
have this parameter here so if we change
14832
10:40:17,520 --> 10:40:18,520
this to 500 for example
14833
10:40:21,120 --> 10:40:22,120
so now we are able to dodge this
14834
10:40:22,740 --> 10:40:23,740
obstacle successfully
14835
10:40:25,740 --> 10:40:26,740
and there are a little bit too far apart
14836
10:40:28,680 --> 10:40:29,680
I believe
14837
10:40:30,416 --> 10:40:31,416
these obstacles
14838
10:40:33,776 --> 10:40:34,776
so what we can do is
14839
10:40:36,660 --> 10:40:37,660
we can have two actually in each one
14840
10:40:42,960 --> 10:40:43,960
so go ahead and select all three of
14841
10:40:45,240 --> 10:40:46,240
these
14842
10:40:47,756 --> 10:40:48,756
foreign
14843
10:40:53,900 --> 10:40:54,900
of 3200 so 0.75 into 3200
14844
10:40:59,220 --> 10:41:00,220
it's going to be 2400 so at negative
14845
10:41:02,460 --> 10:41:03,460
2400 we'll have it
14846
10:41:05,460 --> 10:41:06,460
and we'll go ahead and duplicate this
14847
10:41:10,620 --> 10:41:11,620
so
14848
10:41:12,360 --> 10:41:13,360
these
14849
10:41:13,980 --> 10:41:14,980
and we'll have these at 800.
14850
10:41:19,080 --> 10:41:20,080
so we'll have a gap of 1600
14851
10:41:22,436 --> 10:41:23,436
between each obstacle
14852
10:41:27,480 --> 10:41:28,480
and now if I go ahead and press play
14853
10:41:31,276 --> 10:41:32,276
we have to set up more logic actually
14854
10:41:36,540 --> 10:41:37,540
so we are spawning the obstacle
14855
10:41:38,220 --> 10:41:39,220
dodgeable here now we'll make some
14856
10:41:41,640 --> 10:41:42,640
non-dodgeable obstacles as well so
14857
10:41:44,756 --> 10:41:45,756
set up the non-dodgeable one we can have
14858
10:41:47,096 --> 10:41:48,096
something like a shipping container or
14859
10:41:48,960 --> 10:41:49,960
something
14860
10:41:49,980 --> 10:41:50,980
hmm
14861
10:41:51,480 --> 10:41:52,480
so the way I do it
14862
10:41:54,660 --> 10:41:55,660
is going to be
14863
10:41:58,320 --> 10:41:59,320
if I add in a static mesh once again
14864
10:42:04,916 --> 10:42:05,916
and we'll have
14865
10:42:07,080 --> 10:42:08,080
a shipping container maybe container
14866
10:42:12,596 --> 10:42:13,596
okay we have quite a few that's nice
14867
10:42:20,700 --> 10:42:21,700
let's try with
14868
10:42:22,800 --> 10:42:23,800
only the non-dodgeable one
14869
10:42:28,680 --> 10:42:29,680
non-dodgeable
14870
10:42:34,860 --> 10:42:35,860
other rotations of
14871
10:42:41,400 --> 10:42:42,400
go ahead and rotate it by 90 degrees
14872
10:42:55,500 --> 10:42:56,500
okay
14873
10:42:59,700 --> 10:43:00,700
so this is not exactly on the floor but
14874
10:43:04,256 --> 10:43:05,256
we can fix that
14875
10:43:07,380 --> 10:43:08,380
head into the left view okay it is on
14876
10:43:10,860 --> 10:43:11,860
the floor
14877
10:43:11,936 --> 10:43:12,936
not sure why
14878
10:43:16,620 --> 10:43:17,620
it's not on the floor over there
14879
10:43:23,096 --> 10:43:24,096
you can try just moving it a bit
14880
10:43:27,720 --> 10:43:28,720
that about fixed our problem
14881
10:43:30,596 --> 10:43:31,596
and we obviously should be able to move
14882
10:43:33,480 --> 10:43:34,480
aside and dodge it
14883
10:43:42,180 --> 10:43:43,180
so
14884
10:43:43,860 --> 10:43:44,860
we are spawning obstacles
14885
10:43:48,540 --> 10:43:49,540
and
14886
10:43:50,596 --> 10:43:51,596
now we can set up a little bit of logic
14887
10:43:55,020 --> 10:43:56,020
to make this random a little bit
14888
10:43:58,200 --> 10:43:59,200
uh for dodgeable we can have few more
14889
10:44:03,000 --> 10:44:04,000
so for dot double
14890
10:44:05,096 --> 10:44:06,096
we'll leave it as is child one let it be
14891
10:44:07,380 --> 10:44:08,380
as is child two we can make something
14892
10:44:09,480 --> 10:44:10,480
else
14893
10:44:14,340 --> 10:44:15,340
so this static mesh can be
14894
10:44:18,060 --> 10:44:19,060
we can look over what we have here can
14895
10:44:21,416 --> 10:44:22,416
have this roadblock thing
14896
10:44:26,400 --> 10:44:27,400
and change the logic obviously so
14897
10:44:29,820 --> 10:44:30,820
dot double
14898
10:44:32,936 --> 10:44:33,936
I think it was child one so child one
14899
10:44:42,240 --> 10:44:43,240
child two rather child two
14900
10:44:51,596 --> 10:44:52,596
open it up I mean it is
14901
10:44:54,720 --> 10:44:55,720
a bit down
14902
10:44:57,720 --> 10:44:58,720
but you get the point
14903
10:45:03,596 --> 10:45:04,596
so change that
14904
10:45:06,300 --> 10:45:07,300
10 20 we'll just move all of those by 20
14905
10:45:10,020 --> 10:45:11,020
units
14906
10:45:22,020 --> 10:45:23,020
and for the third one as well we'll just
14907
10:45:24,360 --> 10:45:25,360
add one now obviously you can go ahead
14908
10:45:26,276 --> 10:45:27,276
and
14909
10:45:28,380 --> 10:45:29,380
make more of this
14910
10:45:31,200 --> 10:45:32,200
I feel like if we have some sort of a
14911
10:45:33,300 --> 10:45:34,300
traffic cone or something like that so
14912
10:45:37,680 --> 10:45:38,680
I'm just looking for what I can have so
14913
10:45:41,880 --> 10:45:42,880
okay these seem like the perfect choice
14914
10:45:46,436 --> 10:45:47,436
let's try that
14915
10:45:48,360 --> 10:45:49,360
again forgot to change it
14916
10:45:54,180 --> 10:45:55,180
so under my
14917
10:45:57,000 --> 10:45:58,000
path
14918
10:45:58,256 --> 10:45:59,256
so course path base
14919
10:46:02,880 --> 10:46:03,880
we can go ahead and change this to child
14920
10:46:05,160 --> 10:46:06,160
three
14921
10:46:07,436 --> 10:46:08,436
to test it
14922
10:46:09,596 --> 10:46:10,596
again it's a bit low but that's not an
14923
10:46:12,480 --> 10:46:13,480
issue okay I forgot to get the window in
14924
10:46:14,880 --> 10:46:15,880
Focus once again
14925
10:46:16,256 --> 10:46:17,256
that's my fault
14926
10:46:19,500 --> 10:46:20,500
and we have to move it down I believe
14927
10:46:26,936 --> 10:46:27,936
so move it down by 20 units
14928
10:46:37,436 --> 10:46:38,436
okay
14929
10:46:39,416 --> 10:46:40,416
so we have our dodgable obstacles let's
14930
10:46:41,820 --> 10:46:42,820
set up our non-dodgeable obstacles as
14931
10:46:43,860 --> 10:46:44,860
well
14932
10:46:45,240 --> 10:46:46,240
so in our child one we can again look
14933
10:46:48,596 --> 10:46:49,596
for what else we have maybe if we have a
14934
10:46:50,340 --> 10:46:51,340
truck or something
14935
10:46:52,200 --> 10:46:53,200
nope
14936
10:46:54,360 --> 10:46:55,360
uh we can look for what we have so
14937
10:46:56,700 --> 10:46:57,700
construction volume one meshes
14938
10:47:02,400 --> 10:47:03,400
so
14939
10:47:04,140 --> 10:47:05,140
can have a fence
14940
10:47:06,180 --> 10:47:07,180
yeah that's not a bad idea
14941
10:47:09,720 --> 10:47:10,720
so this is child one so let's child one
14942
10:47:13,500 --> 10:47:14,500
be the same
14943
10:47:16,436 --> 10:47:17,436
let's actually open up child two and
14944
10:47:19,800 --> 10:47:20,800
let's actually open up child three so
14945
10:47:22,200 --> 10:47:23,200
these are the ones which we'll try to
14946
10:47:23,520 --> 10:47:24,520
change
14947
10:47:25,140 --> 10:47:26,140
over here meshes we will select the
14948
10:47:28,080 --> 10:47:29,080
fence for one
14949
10:47:33,500 --> 10:47:34,500
uh the rotation can be zero
14950
10:47:40,916 --> 10:47:41,916
uh change this
14951
10:47:45,380 --> 10:47:46,380
non-dodgeable child three
14952
10:47:50,520 --> 10:47:51,520
so it's a little too big
14953
10:47:57,540 --> 10:47:58,540
so we can scale this down maybe 0.8
14954
10:48:12,720 --> 10:48:13,720
okay so I don't think you can dodge this
14955
10:48:15,000 --> 10:48:16,000
one
14956
10:48:20,580 --> 10:48:21,580
okay we can dodge it when we move aside
14957
10:48:24,060 --> 10:48:25,060
so we'll just have one last one
14958
10:48:26,640 --> 10:48:27,640
so for this one so obstacle Child 2
14959
10:48:30,300 --> 10:48:31,300
I will change it right now so child two
14960
10:48:33,840 --> 10:48:34,840
these are the various obstacles
14961
10:48:35,340 --> 10:48:36,340
basically
14962
10:48:37,040 --> 10:48:38,040
non-dodgeable child to
14963
10:48:39,840 --> 10:48:40,840
select that and this is child two I
14964
10:48:42,596 --> 10:48:43,596
assume yeah
14965
10:48:44,460 --> 10:48:45,460
so we can look for something else which
14966
10:48:46,140 --> 10:48:47,140
we may have
14967
10:48:47,276 --> 10:48:48,276
okay this looks like something
14968
10:48:48,900 --> 10:48:49,900
interesting
14969
10:48:51,480 --> 10:48:52,480
or light generator whatever this is
14970
10:48:54,660 --> 10:48:55,660
let's try that
14971
10:48:57,960 --> 10:48:58,960
I don't think this should be something
14972
10:49:00,596 --> 10:49:01,596
which you should be able to dodge
14973
10:49:07,560 --> 10:49:08,560
okay
14974
10:49:10,680 --> 10:49:11,680
so that works
14975
10:49:15,300 --> 10:49:16,300
now we can set up some randomizing logic
14976
10:49:19,700 --> 10:49:20,700
so that we spawn everything in random
14977
10:49:23,520 --> 10:49:24,520
so this logic is the same we need to
14978
10:49:26,340 --> 10:49:27,340
select the class basically first we can
14979
10:49:28,620 --> 10:49:29,620
select a random integer So Random
14980
10:49:31,200 --> 10:49:32,200
integer
14981
10:49:32,580 --> 10:49:33,580
so this is going to be
14982
10:49:34,560 --> 10:49:35,560
the number of random integer in range
14983
10:49:37,860 --> 10:49:38,860
actually
14984
10:49:41,640 --> 10:49:42,640
so this is going to be the number of
14985
10:49:43,860 --> 10:49:44,860
dodgeable obstacles so we need at least
14986
10:49:46,680 --> 10:49:47,680
one dodgeable obstacle otherwise the
14987
10:49:48,596 --> 10:49:49,596
game is going to get unplayable so we
14988
10:49:50,700 --> 10:49:51,700
can either have one or we can have all
14989
10:49:52,436 --> 10:49:53,436
the way up to three
14990
10:49:54,436 --> 10:49:55,436
and what we can do
14991
10:49:57,360 --> 10:49:58,360
is
14992
10:49:58,620 --> 10:49:59,620
depending on the number now this is
14993
10:50:00,960 --> 10:50:01,960
going to be number of dodgeable
14994
10:50:03,000 --> 10:50:04,000
obstacles what we have so promote this
14995
10:50:05,580 --> 10:50:06,580
to a variable
14996
10:50:07,380 --> 10:50:08,380
so number of
14997
10:50:09,900 --> 10:50:10,900
dodgeable
14998
10:50:11,460 --> 10:50:12,460
obstacles
14999
10:50:15,960 --> 10:50:16,960
okay so now that we have this if we have
15000
10:50:20,340 --> 10:50:21,340
only one
15001
10:50:22,380 --> 10:50:23,380
what we can do is we can select one so
15002
10:50:26,400 --> 10:50:27,400
number of dodgable obstacles
15003
10:50:29,096 --> 10:50:30,096
so we can switch on int
15004
10:50:33,240 --> 10:50:34,240
and we can select something
15005
10:50:41,400 --> 10:50:42,400
so
15006
10:50:43,256 --> 10:50:44,256
so we can start at one so start pin type
15007
10:50:47,400 --> 10:50:48,400
one
15008
10:50:49,080 --> 10:50:50,080
if we have only one obstacle our logic
15009
10:50:52,020 --> 10:50:53,020
is going to be really simple so we'll
15010
10:50:54,360 --> 10:50:55,360
just select a random one over there
15011
10:50:58,256 --> 10:50:59,256
we need to do this Two Times by the way
15012
10:51:02,460 --> 10:51:03,460
or multiple times probably I'm not sure
15013
10:51:08,820 --> 10:51:09,820
so
15014
10:51:10,320 --> 10:51:11,320
uh we'll have we'll have more obstacles
15015
10:51:12,900 --> 10:51:13,900
to be honest these are not enough
15016
10:51:15,900 --> 10:51:16,900
so we'll space them a little more closer
15017
10:51:21,960 --> 10:51:22,960
copy these
15018
10:51:24,300 --> 10:51:25,300
right obstacle left obstacle Center
15019
10:51:28,020 --> 10:51:29,020
obstacle
15020
10:51:29,756 --> 10:51:30,756
Ctrl D to duplicate and
15021
10:51:33,900 --> 10:51:34,900
left obstacle two
15022
10:51:37,740 --> 10:51:38,740
press Center obstacle to okay we didn't
15023
10:51:39,840 --> 10:51:40,840
duplicate everything
15024
10:51:41,400 --> 10:51:42,400
so Center
15025
10:51:43,740 --> 10:51:44,740
left and right
15026
10:51:46,680 --> 10:51:47,680
so Center left and right
15027
10:51:49,020 --> 10:51:50,020
Ctrl D to duplicate
15028
10:51:51,596 --> 10:51:52,596
okay wait we aren't duplicating anything
15029
10:51:53,460 --> 10:51:54,460
we'll just duplicate this so okay left
15030
10:51:56,096 --> 10:51:57,096
Center and right
15031
10:51:59,400 --> 10:52:00,400
you can move this somewhere in the
15032
10:52:01,500 --> 10:52:02,500
center
15033
10:52:03,240 --> 10:52:04,240
right at the center
15034
10:52:06,180 --> 10:52:07,180
and we can space these two equally apart
15035
10:52:10,620 --> 10:52:11,620
which I believe they already are
15036
10:52:15,900 --> 10:52:16,900
are they equally spaced yep but
15037
10:52:19,140 --> 10:52:20,140
we need to space them out a bit more
15038
10:52:23,820 --> 10:52:24,820
we have 800 for the spacing here
15039
10:52:29,400 --> 10:52:30,400
so we can select our obstacle one
15040
10:52:36,720 --> 10:52:37,720
we can try
15041
10:52:39,720 --> 10:52:40,720
giving you know negative
15042
10:52:42,960 --> 10:52:43,960
600 maybe so if I do negative 400
15043
10:52:48,960 --> 10:52:49,960
so that will be way too much space 500
15044
10:52:51,720 --> 10:52:52,720
maybe we can try 600.
15045
10:52:57,120 --> 10:52:58,120
so I have 3200 let's divide it let's
15046
10:53:00,596 --> 10:53:01,596
take 33 percent of that so calculator
15047
10:53:09,900 --> 10:53:10,900
so it's somewhere around 1066.
15048
10:53:16,256 --> 10:53:17,256
so we'll have 600. it's fine if they're
15049
10:53:19,436 --> 10:53:20,436
not equidistant
15050
10:53:21,000 --> 10:53:22,000
you can obviously do the math yourself
15051
10:53:28,020 --> 10:53:29,020
so obstacle
15052
10:53:30,960 --> 10:53:31,960
this is what we need so one
15053
10:53:36,480 --> 10:53:37,480
whoops
15054
10:53:38,096 --> 10:53:39,096
two and three
15055
10:53:44,820 --> 10:53:45,820
so 3200 minus 600 is going to be 2600.
15056
10:53:51,480 --> 10:53:52,480
okay now let's see if this works
15057
10:53:54,300 --> 10:53:55,300
yeah obviously we are not spawning it
15058
10:53:56,040 --> 10:53:57,040
that's different
15059
10:54:00,180 --> 10:54:01,180
but now
15060
10:54:04,620 --> 10:54:05,620
in theory we our logic should work
15061
10:54:08,460 --> 10:54:09,460
so we can actually Loop through
15062
10:54:11,160 --> 10:54:12,160
so we can select the number of dodgeable
15063
10:54:13,380 --> 10:54:14,380
obstacles for each level so we'll have
15064
10:54:16,320 --> 10:54:17,320
an array of this
15065
10:54:18,900 --> 10:54:19,900
so we'll create an array so change the
15066
10:54:21,240 --> 10:54:22,240
type it's fine
15067
10:54:24,596 --> 10:54:25,596
so we can do for each Loop
15068
10:54:30,540 --> 10:54:31,540
and for each index we can try
15069
10:54:34,140 --> 10:54:35,140
and get a random integer
15070
10:54:40,140 --> 10:54:41,140
so we can
15071
10:54:41,756 --> 10:54:42,756
set array element
15072
10:54:45,300 --> 10:54:46,300
so this is the index
15073
10:54:47,580 --> 10:54:48,580
we can do a simple for Loop so for Loop
15074
10:54:53,220 --> 10:54:54,220
so from 0 to 2
15075
10:54:56,756 --> 10:54:57,756
so size to fit we'll do that
15076
10:55:00,300 --> 10:55:01,300
and we'd actually want to reserve
15077
10:55:05,040 --> 10:55:06,040
three locations so one two three
15078
10:55:08,880 --> 10:55:09,880
so we don't need size to fit so
15079
10:55:12,416 --> 10:55:13,416
in this index we are going to set this
15080
10:55:15,300 --> 10:55:16,300
item
15081
10:55:17,820 --> 10:55:18,820
so for all our three levels we have we
15082
10:55:20,756 --> 10:55:21,756
know the number of obstacles which will
15083
10:55:22,680 --> 10:55:23,680
be dodgable
15084
10:55:25,200 --> 10:55:26,200
once we have that number we can go ahead
15085
10:55:27,180 --> 10:55:28,180
and spawn them
15086
10:55:31,740 --> 10:55:32,740
so we can have this in an array and
15087
10:55:33,596 --> 10:55:34,596
randomize them actually
15088
10:55:37,320 --> 10:55:38,320
anyways don't worry too much about the
15089
10:55:39,120 --> 10:55:40,120
logic
15090
10:55:40,080 --> 10:55:41,080
just my logic which I'm making up
15091
10:55:44,160 --> 10:55:45,160
um
15092
10:55:45,480 --> 10:55:46,480
we can select this
15093
10:55:50,700 --> 10:55:51,700
so we can store these in an array
15094
10:55:54,436 --> 10:55:55,436
so create an array so
15095
10:55:58,320 --> 10:55:59,320
promote to variable
15096
10:56:01,680 --> 10:56:02,680
or you can actually just have an array
15097
10:56:03,596 --> 10:56:04,596
so what are we using this for we're just
15098
10:56:05,160 --> 10:56:06,160
using this for the location
15099
10:56:07,560 --> 10:56:08,560
so we can get the transform of this
15100
10:56:11,120 --> 10:56:12,120
we can only have the transforms in the
15101
10:56:13,980 --> 10:56:14,980
array that's that would work I guess
15102
10:56:26,300 --> 10:56:27,300
so first we'll
15103
10:56:29,520 --> 10:56:30,520
have the transforms go ahead and create
15104
10:56:33,560 --> 10:56:34,560
an array for
15105
10:56:36,060 --> 10:56:37,060
transforms
15106
10:56:41,660 --> 10:56:42,660
transforms one transforms to transforms
15107
10:56:45,120 --> 10:56:46,120
three we'll need three arrays so
15108
10:56:48,020 --> 10:56:49,020
will the location is enough for us so
15109
10:56:51,660 --> 10:56:52,660
array of vectors
15110
10:56:53,720 --> 10:56:54,720
transforms to
15111
10:56:56,480 --> 10:56:57,480
transforms three
15112
10:56:59,276 --> 10:57:00,276
I know I shouldn't be calling them
15113
10:57:00,900 --> 10:57:01,900
transforms but we'll take a look at the
15114
10:57:03,416 --> 10:57:04,416
right obstacle
15115
10:57:04,800 --> 10:57:05,800
uh the first level ones basically
15116
10:57:08,040 --> 10:57:09,040
so we have this selected so right
15117
10:57:10,080 --> 10:57:11,080
obstacle one will will go according to
15118
10:57:13,460 --> 10:57:14,460
naming order
15119
10:57:16,276 --> 10:57:17,276
transforms one
15120
10:57:18,660 --> 10:57:19,660
we'll compile this blueprint
15121
10:57:21,900 --> 10:57:22,900
so we have three elements
15122
10:57:26,460 --> 10:57:27,460
we can access it right here
15123
10:57:30,840 --> 10:57:31,840
so the first one is going to be this I'm
15124
10:57:33,776 --> 10:57:34,776
not sure if we can
15125
10:57:35,340 --> 10:57:36,340
paste this see if we can
15126
10:57:37,860 --> 10:57:38,860
we have right obstacle copy this
15127
10:57:41,580 --> 10:57:42,580
okay we took that so left obstacle
15128
10:57:44,580 --> 10:57:45,580
copy this and
15129
10:57:48,240 --> 10:57:49,240
okay
15130
10:57:49,320 --> 10:57:50,320
the right and the left have okay they
15131
10:57:51,900 --> 10:57:52,900
don't
15132
10:57:56,936 --> 10:57:57,936
so paste one has negative 250
15133
10:58:01,140 --> 10:58:02,140
and the center one will have probably
15134
10:58:03,416 --> 10:58:04,416
will have probably have zero so we'll
15135
10:58:05,160 --> 10:58:06,160
paste it we'll have zero over here
15136
10:58:11,220 --> 10:58:12,220
okay and now that we have this
15137
10:58:14,340 --> 10:58:15,340
let's grab our obstacle tools or
15138
10:58:17,460 --> 10:58:18,460
obstacle ones
15139
10:58:19,140 --> 10:58:20,140
so this is negative 600.
15140
10:58:22,020 --> 10:58:23,020
one two three negative 600 this will be
15141
10:58:25,320 --> 10:58:26,320
constant so 1 is going to be 250 another
15142
10:58:28,800 --> 10:58:29,800
one is going to be negative 250.
15143
10:58:32,340 --> 10:58:33,340
similarly we can grab our two
15144
10:58:35,276 --> 10:58:36,276
so negative 1600 this is basically our
15145
10:58:38,160 --> 10:58:39,160
midpoint
15146
10:58:40,140 --> 10:58:41,140
negative 1600 250 negative 250
15147
10:58:47,040 --> 10:58:48,040
and this is about it
15148
10:58:49,916 --> 10:58:50,916
no
15149
10:58:52,020 --> 10:58:53,020
once this is done we'll collapse the
15150
10:58:54,540 --> 10:58:55,540
function
15151
10:58:55,680 --> 10:58:56,680
so determine
15152
10:58:58,980 --> 10:58:59,980
number of
15153
10:59:01,200 --> 10:59:02,200
dodgeable
15154
10:59:03,960 --> 10:59:04,960
obstacles
15155
10:59:08,096 --> 10:59:09,096
okay
15156
10:59:09,416 --> 10:59:10,416
we have the number of dodgeable
15157
10:59:11,220 --> 10:59:12,220
obstacles now
15158
10:59:12,776 --> 10:59:13,776
now what we can do is we can Loop
15159
10:59:15,120 --> 10:59:16,120
through this
15160
10:59:17,460 --> 10:59:18,460
so for each loop I really wish we could
15161
10:59:19,680 --> 10:59:20,680
have a two dimensional array for this
15162
10:59:21,840 --> 10:59:22,840
that would have helped us a lot
15163
10:59:26,520 --> 10:59:27,520
now
15164
10:59:28,020 --> 10:59:29,020
what we can do is
15165
10:59:30,360 --> 10:59:31,360
we can go ahead and randomize this
15166
10:59:38,340 --> 10:59:39,340
can we not randomize this
15167
10:59:41,820 --> 10:59:42,820
okay we cannot so we have a plugin which
15168
10:59:46,140 --> 10:59:47,140
will help us so low entry
15169
10:59:50,880 --> 10:59:51,880
I can restart
15170
10:59:52,500 --> 10:59:53,500
save everything
15171
11:00:13,320 --> 11:00:14,320
all right so
15172
11:00:15,300 --> 11:00:16,300
back here I think now we should have
15173
11:00:17,756 --> 11:00:18,756
okay we're coming close to two hours I
15174
11:00:20,340 --> 11:00:21,340
think this will be done in two hours not
15175
11:00:22,436 --> 11:00:23,436
one
15176
11:00:23,880 --> 11:00:24,880
blueprints game uh course pathways
15177
11:00:29,936 --> 11:00:30,936
and we should have a randomize
15178
11:00:34,680 --> 11:00:35,680
oops nope we don't
15179
11:00:38,540 --> 11:00:39,540
so I think we might need a few functions
15180
11:00:42,180 --> 11:00:43,180
so
15181
11:00:44,880 --> 11:00:45,880
how do we go about randomizing this we
15182
11:00:46,860 --> 11:00:47,860
can look at the epic games launcher if
15183
11:00:48,720 --> 11:00:49,720
we have any plugins
15184
11:00:51,540 --> 11:00:52,540
so array helpers I guess I had one
15185
11:00:55,740 --> 11:00:56,740
so we'll go ahead and install this to
15186
11:00:57,596 --> 11:00:58,596
the engine we can simultaneously use it
15187
11:01:02,580 --> 11:01:03,580
once we have this so once we actually
15188
11:01:04,560 --> 11:01:05,560
randomize this
15189
11:01:06,776 --> 11:01:07,776
uh depending on this
15190
11:01:09,840 --> 11:01:10,840
we can go ahead and set this so switch
15191
11:01:14,040 --> 11:01:15,040
on end
15192
11:01:19,256 --> 11:01:20,256
and
15193
11:01:21,120 --> 11:01:22,120
will you select for this
15194
11:01:27,180 --> 11:01:28,180
so just close the editor just to let
15195
11:01:29,580 --> 11:01:30,580
that happen
15196
11:01:32,340 --> 11:01:33,340
and now if we go ahead and launch Our
15197
11:01:35,580 --> 11:01:36,580
Endless Runner
15198
11:01:45,240 --> 11:01:46,240
okay go to edit
15199
11:01:50,096 --> 11:01:51,096
plugins so edit plugins
15200
11:01:54,320 --> 11:01:55,320
and array array helper
15201
11:01:58,800 --> 11:01:59,800
go ahead and restart
15202
11:02:05,040 --> 11:02:06,040
so this is the sort of stuff I just hope
15203
11:02:06,900 --> 11:02:07,900
it doesn't take too long
15204
11:02:09,240 --> 11:02:10,240
right hopefully we have some sort of a
15205
11:02:11,520 --> 11:02:12,520
randomized function so randomize
15206
11:02:15,180 --> 11:02:16,180
okay we still do not have a randomized
15207
11:02:18,240 --> 11:02:19,240
option option
15208
11:02:20,400 --> 11:02:21,400
so let's just look for it so randomize
15209
11:02:24,436 --> 11:02:25,436
array unreal
15210
11:02:26,520 --> 11:02:27,520
I don't know
15211
11:02:28,620 --> 11:02:29,620
is it called is it just called something
15212
11:02:31,140 --> 11:02:32,140
else so okay never mind
15213
11:02:34,436 --> 11:02:35,436
it's called Shuffle
15214
11:02:36,596 --> 11:02:37,596
so first of all we'll Shuffle the arrays
15215
11:02:39,240 --> 11:02:40,240
we'll shuffle all the three we'll do
15216
11:02:41,400 --> 11:02:42,400
that before we actually set this
15217
11:02:45,000 --> 11:02:46,000
we'll go ahead Shuffle this
15218
11:02:49,380 --> 11:02:50,380
go ahead and Shuffle this once again
15219
11:02:58,256 --> 11:02:59,256
uh we'll put that in the previous
15220
11:03:00,000 --> 11:03:01,000
function itself
15221
11:03:03,240 --> 11:03:04,240
so we can go ahead and Shuffle
15222
11:03:09,720 --> 11:03:10,720
generally I don't recommend you guys uh
15223
11:03:12,900 --> 11:03:13,900
do array operations in Blueprint but
15224
11:03:16,080 --> 11:03:17,080
anyways
15225
11:03:17,276 --> 11:03:18,276
once the slope is completed we can do
15226
11:03:19,436 --> 11:03:20,436
that
15227
11:03:20,400 --> 11:03:21,400
and this will go to the return node
15228
11:03:24,480 --> 11:03:25,480
just for you to understand the flow of
15229
11:03:27,180 --> 11:03:28,180
logic
15230
11:03:29,936 --> 11:03:30,936
and now
15231
11:03:31,620 --> 11:03:32,620
depending on this
15232
11:03:34,020 --> 11:03:35,020
we can go ahead and spawn them
15233
11:03:38,096 --> 11:03:39,096
so the array element is going to be the
15234
11:03:41,460 --> 11:03:42,460
number of obstacles so this switch is
15235
11:03:44,340 --> 11:03:45,340
going to start from 1 so start index is
15236
11:03:48,416 --> 11:03:49,416
one
15237
11:03:49,560 --> 11:03:50,560
you will either have one two or three
15238
11:03:54,596 --> 11:03:55,596
so if you have one or two way can you
15239
11:03:58,080 --> 11:03:59,080
select probably
15240
11:03:59,820 --> 11:04:00,820
copy the server
15241
11:04:06,416 --> 11:04:07,416
so
15242
11:04:07,800 --> 11:04:08,800
everything else is zero so we can just
15243
11:04:09,900 --> 11:04:10,900
leave it as is
15244
11:04:15,120 --> 11:04:16,120
so we can go ahead and over here
15245
11:04:18,776 --> 11:04:19,776
if this is one
15246
11:04:21,240 --> 11:04:22,240
if we have one dot zipper obstacle
15247
11:04:25,020 --> 11:04:26,020
we can go ahead and spawn
15248
11:04:27,480 --> 11:04:28,480
just one of them
15249
11:04:29,880 --> 11:04:30,880
as dodgable so dot double
15250
11:04:36,180 --> 11:04:37,180
so 1 is going to be dodgable and the
15251
11:04:38,880 --> 11:04:39,880
spawn transform will just use the first
15252
11:04:41,936 --> 11:04:42,936
index
15253
11:04:45,060 --> 11:04:46,060
so we will select
15254
11:04:51,720 --> 11:04:52,720
so depending on which index it is
15255
11:04:55,020 --> 11:04:56,020
so transform 1 transform to transform
15256
11:04:58,740 --> 11:04:59,740
three
15257
11:04:59,580 --> 11:05:00,580
so option one
15258
11:05:02,220 --> 11:05:03,220
option two and option three
15259
11:05:06,540 --> 11:05:07,540
so we'll select any one of these arrays
15260
11:05:10,160 --> 11:05:11,160
and if we have to spawn only one dot
15261
11:05:13,500 --> 11:05:14,500
zipple so we can get
15262
11:05:16,880 --> 11:05:17,880
uh we can get a copy of the first one
15263
11:05:19,860 --> 11:05:20,860
we'll split the struct pin here and
15264
11:05:22,560 --> 11:05:23,560
we'll just get this location
15265
11:05:25,140 --> 11:05:26,140
now we we need to just repeat this logic
15266
11:05:28,560 --> 11:05:29,560
so Ctrl d
15267
11:05:33,916 --> 11:05:34,916
and we want to do two non-dodgeable ones
15268
11:05:41,220 --> 11:05:42,220
so dodgeable and index 1 and 2 are going
15269
11:05:44,700 --> 11:05:45,700
to be Non DOT triple so non dodgable
15270
11:05:49,200 --> 11:05:50,200
uh we have to spawn a child class of
15271
11:05:51,720 --> 11:05:52,720
this so
15272
11:05:54,120 --> 11:05:55,120
you can use the select once again
15273
11:05:58,200 --> 11:05:59,200
so Random
15274
11:06:01,020 --> 11:06:02,020
integer
15275
11:06:02,936 --> 11:06:03,936
and Max is going to be 2.
15276
11:06:05,936 --> 11:06:06,936
so it's going to be
15277
11:06:09,416 --> 11:06:10,416
Max S2 so
15278
11:06:12,596 --> 11:06:13,596
1 and 2.
15279
11:06:15,900 --> 11:06:16,900
so it's random number between 0 and Max
15280
11:06:19,860 --> 11:06:20,860
minus 1 let's just use random integer
15281
11:06:22,020 --> 11:06:23,020
and range
15282
11:06:23,220 --> 11:06:24,220
it's a little bit confusing so minimum
15283
11:06:25,436 --> 11:06:26,436
is zero maximum is 2.
15284
11:06:29,340 --> 11:06:30,340
okay
15285
11:06:31,320 --> 11:06:32,320
and this is going to be dodgable so
15286
11:06:33,596 --> 11:06:34,596
dodgeable
15287
11:06:35,460 --> 11:06:36,460
obstacle dot double child one child two
15288
11:06:40,200 --> 11:06:41,200
and child three
15289
11:06:45,180 --> 11:06:46,180
this is what we have
15290
11:06:49,080 --> 11:06:50,080
done
15291
11:06:52,860 --> 11:06:53,860
and for this one this is non-dodgeable
15292
11:06:56,400 --> 11:06:57,400
so we'll copy the logic
15293
11:06:59,580 --> 11:07:00,580
but instead of dodgeable we'll have
15294
11:07:01,680 --> 11:07:02,680
non-dodgeable
15295
11:07:03,840 --> 11:07:04,840
so child one
15296
11:07:08,220 --> 11:07:09,220
child one
15297
11:07:11,220 --> 11:07:12,220
child two and child three
15298
11:07:16,916 --> 11:07:17,916
okay
15299
11:07:18,360 --> 11:07:19,360
and we need this once again so copy over
15300
11:07:21,360 --> 11:07:22,360
this entire logic
15301
11:07:28,200 --> 11:07:29,200
all right so this is going to be the
15302
11:07:30,840 --> 11:07:31,840
same this is going to be for index 2.
15303
11:07:34,380 --> 11:07:35,380
now if we have 2 we can go ahead and
15304
11:07:37,680 --> 11:07:38,680
copy this over so Ctrl C and Ctrl V
15305
11:07:42,540 --> 11:07:43,540
and we can just move this aside
15306
11:07:46,256 --> 11:07:47,256
so for index 0 it's going to remain the
15307
11:07:48,540 --> 11:07:49,540
same
15308
11:07:50,340 --> 11:07:51,340
whoops Ctrl V
15309
11:07:52,860 --> 11:07:53,860
oops uh copy this
15310
11:07:56,160 --> 11:07:57,160
Ctrl C and Ctrl V
15311
11:07:59,340 --> 11:08:00,340
index is still going to remain the same
15312
11:08:04,800 --> 11:08:05,800
once this is done we need the attach as
15313
11:08:07,620 --> 11:08:08,620
well we didn't copy over the attach
15314
11:08:14,700 --> 11:08:15,700
okay so we have to duplicate this whole
15315
11:08:17,040 --> 11:08:18,040
thing
15316
11:08:21,480 --> 11:08:22,480
so index is this
15317
11:08:25,500 --> 11:08:26,500
and index is going to remain the same
15318
11:08:27,660 --> 11:08:28,660
everywhere
15319
11:08:28,980 --> 11:08:29,980
so now we need two dot double obstacles
15320
11:08:31,140 --> 11:08:32,140
so for this one as well we have dodgable
15321
11:08:33,540 --> 11:08:34,540
and this is going to be index one
15322
11:08:35,220 --> 11:08:36,220
obviously
15323
11:08:36,776 --> 11:08:37,776
and for index 2 we can go ahead and have
15324
11:08:40,080 --> 11:08:41,080
this
15325
11:08:44,936 --> 11:08:45,936
all right so copy this
15326
11:08:47,756 --> 11:08:48,756
and again we can pass the index
15327
11:08:51,416 --> 11:08:52,416
so array index
15328
11:08:54,000 --> 11:08:55,000
go ahead and pass that in
15329
11:08:57,480 --> 11:08:58,480
and when we have all three dodgable
15330
11:09:00,060 --> 11:09:01,060
obstacles
15331
11:09:01,860 --> 11:09:02,860
uh we'll just go ahead and copy this
15332
11:09:03,840 --> 11:09:04,840
much Ctrl C and Ctrl V
15333
11:09:11,160 --> 11:09:12,160
so in case of three this is what we'll
15334
11:09:13,380 --> 11:09:14,380
do
15335
11:09:14,580 --> 11:09:15,580
so index is still going to remain the
15336
11:09:17,096 --> 11:09:18,096
array index
15337
11:09:18,900 --> 11:09:19,900
Ctrl d
15338
11:09:20,936 --> 11:09:21,936
and Ctrl d
15339
11:09:24,120 --> 11:09:25,120
copy this over move the execution pins
15340
11:09:28,560 --> 11:09:29,560
and the index will obviously just remain
15341
11:09:31,380 --> 11:09:32,380
the same
15342
11:09:32,820 --> 11:09:33,820
so the last one is going to remain the
15343
11:09:35,160 --> 11:09:36,160
same and this is going to be 2 this is
15344
11:09:37,800 --> 11:09:38,800
going to be 1.
15345
11:09:39,596 --> 11:09:40,596
and this is going to be 0. so make sure
15346
11:09:41,820 --> 11:09:42,820
you have 0 1 and 2.
15347
11:09:46,020 --> 11:09:47,020
okay
15348
11:09:47,756 --> 11:09:48,756
so now our logic should work
15349
11:09:50,936 --> 11:09:51,936
and if I were to go ahead and press play
15350
11:09:55,560 --> 11:09:56,560
okay
15351
11:09:56,700 --> 11:09:57,700
everything works okay
15352
11:10:02,820 --> 11:10:03,820
all right so
15353
11:10:05,360 --> 11:10:06,360
okay we stepped onto something
15354
11:10:08,520 --> 11:10:09,520
uh we need to make sure this doesn't
15355
11:10:10,680 --> 11:10:11,680
happen in our first one so
15356
11:10:16,980 --> 11:10:17,980
okay we have to just ensure that the
15357
11:10:19,980 --> 11:10:20,980
obstacles aren't spawned in the first
15358
11:10:22,080 --> 11:10:23,080
one basically
15359
11:10:27,360 --> 11:10:28,360
so we'll create a Boolean
15360
11:10:31,256 --> 11:10:32,256
first box
15361
11:10:35,640 --> 11:10:36,640
so if this is not the first box
15362
11:10:39,596 --> 11:10:40,596
we'll go ahead and do this
15363
11:10:45,140 --> 11:10:46,140
so inside the level blueprint
15364
11:10:49,460 --> 11:10:50,460
under this
15365
11:10:52,436 --> 11:10:53,436
if we go ahead and refresh nodes uh we
15366
11:10:55,436 --> 11:10:56,436
have to pass this in so expose on spawn
15367
11:11:01,740 --> 11:11:02,740
all right so now if I refresh
15368
11:11:04,680 --> 11:11:05,680
I should get this
15369
11:11:08,520 --> 11:11:09,520
so only if this is uh index 0
15370
11:11:13,020 --> 11:11:14,020
so double equal to zero then this is the
15371
11:11:16,436 --> 11:11:17,436
first box otherwise it's not
15372
11:11:20,400 --> 11:11:21,400
okay so now our logic is working
15373
11:11:23,820 --> 11:11:24,820
let's go ahead and play the game now
15374
11:11:29,340 --> 11:11:30,340
all right
15375
11:11:32,580 --> 11:11:33,580
so as you guys can see our game is
15376
11:11:35,160 --> 11:11:36,160
working as expected
15377
11:11:41,220 --> 11:11:42,220
we don't have a score yet we'll just set
15378
11:11:43,256 --> 11:11:44,256
it up quickly
15379
11:11:56,936 --> 11:11:57,936
so as you can see our logic is working
15380
11:12:03,840 --> 11:12:04,840
so we can set up a scoring system real
15381
11:12:06,660 --> 11:12:07,660
quick and dirty here
15382
11:12:09,060 --> 11:12:10,060
content
15383
11:12:10,680 --> 11:12:11,680
I will do the start thing also it's
15384
11:12:13,860 --> 11:12:14,860
really simple so
15385
11:12:15,596 --> 11:12:16,596
go ahead and open level
15386
11:12:21,240 --> 11:12:22,240
um we call this one game map I believe
15387
11:12:23,520 --> 11:12:24,520
so Maps
15388
11:12:25,620 --> 11:12:26,620
game up go ahead and paste that in
15389
11:12:32,700 --> 11:12:33,700
or we can start from the main menu
15390
11:12:36,060 --> 11:12:37,060
go ahead and play start
15391
11:12:38,520 --> 11:12:39,520
and we started the game
15392
11:12:48,180 --> 11:12:49,180
so as you can see everything is working
15393
11:12:50,096 --> 11:12:51,096
as expected you could have some stuff at
15394
11:12:52,200 --> 11:12:53,200
the side
15395
11:12:53,400 --> 11:12:54,400
and we'll have a scoring system we can
15396
11:12:55,740 --> 11:12:56,740
have a time-based scoring system
15397
11:12:58,080 --> 11:12:59,080
so it's the score is going to go up at a
15398
11:13:00,180 --> 11:13:01,180
constant rate
15399
11:13:03,776 --> 11:13:04,776
content
15400
11:13:05,820 --> 11:13:06,820
will create a widget further so
15401
11:13:11,160 --> 11:13:12,160
user widget
15402
11:13:13,980 --> 11:13:14,980
and we'll call this one HUD
15403
11:13:22,980 --> 11:13:23,980
and we'll we'll just simply have a text
15404
11:13:28,500 --> 11:13:29,500
so we'll wrap this with a canvas panel
15405
11:13:34,916 --> 11:13:35,916
and this is going to be our score
15406
11:13:39,776 --> 11:13:40,776
once we will set the game mode and stuff
15407
11:13:42,320 --> 11:13:43,320
so game map
15408
11:13:45,416 --> 11:13:46,416
over here we'll have BP uh we don't have
15409
11:13:48,660 --> 11:13:49,660
a black controller we'll create that
15410
11:13:51,300 --> 11:13:52,300
game
15411
11:13:53,096 --> 11:13:54,096
go ahead head into blueprint class
15412
11:13:54,960 --> 11:13:55,960
player controller BP underscore player
15413
11:13:58,380 --> 11:13:59,380
controller
15414
11:14:03,596 --> 11:14:04,596
so you should have BP player controller
15415
11:14:08,580 --> 11:14:09,580
so on begin play we can go ahead and
15416
11:14:11,756 --> 11:14:12,756
create the widget
15417
11:14:13,436 --> 11:14:14,436
so create widget
15418
11:14:16,500 --> 11:14:17,500
it's going to be HUD
15419
11:14:19,380 --> 11:14:20,380
and we can go ahead and add to viewport
15420
11:14:23,096 --> 11:14:24,096
right so let's look at our time we don't
15421
11:14:25,500 --> 11:14:26,500
have much I think it'll take probably
15422
11:14:27,360 --> 11:14:28,360
just a little lower two hours but
15423
11:14:29,640 --> 11:14:30,640
it'll be done
15424
11:14:32,160 --> 11:14:33,160
so once we create this we can grab a
15425
11:14:34,256 --> 11:14:35,256
reference
15426
11:14:35,640 --> 11:14:36,640
so promote this to a variable and we'll
15427
11:14:38,700 --> 11:14:39,700
call this one HUD now I don't recommend
15428
11:14:40,500 --> 11:14:41,500
you guys use bindings but I think in
15429
11:14:43,020 --> 11:14:44,020
this case just to make this real quick
15430
11:14:45,720 --> 11:14:46,720
I'll use bindings
15431
11:14:47,936 --> 11:14:48,936
so we can have game State uh on
15432
11:14:51,960 --> 11:14:52,960
construct we can get reference to the
15433
11:14:53,880 --> 11:14:54,880
game state so get game state
15434
11:14:58,620 --> 11:14:59,620
cast to BP game state
15435
11:15:02,340 --> 11:15:03,340
and what we can do is we can grab a
15436
11:15:04,140 --> 11:15:05,140
reference to it
15437
11:15:09,060 --> 11:15:10,060
and we can create a score variable
15438
11:15:14,096 --> 11:15:15,096
content blueprint
15439
11:15:16,980 --> 11:15:17,980
uh blueprint main menu I guess no game
15440
11:15:23,360 --> 11:15:24,360
so game
15441
11:15:26,820 --> 11:15:27,820
game state
15442
11:15:29,096 --> 11:15:30,096
and we can have a score
15443
11:15:32,160 --> 11:15:33,160
so we'll make this an INT 64. so that we
15444
11:15:35,220 --> 11:15:36,220
can have larger scores so integer 64.
15445
11:15:39,000 --> 11:15:40,000
and we can have a timer so set timer by
15446
11:15:43,500 --> 11:15:44,500
function name
15447
11:15:46,256 --> 11:15:47,256
and
15448
11:15:48,416 --> 11:15:49,416
it's going to be something which
15449
11:15:51,300 --> 11:15:52,300
happens every 0.5 seconds let's say
15450
11:15:55,256 --> 11:15:56,256
and we are going to increment the score
15451
11:15:57,596 --> 11:15:58,596
so promote to variable
15452
11:15:59,700 --> 11:16:00,700
score timer
15453
11:16:01,800 --> 11:16:02,800
and we can have a custom event
15454
11:16:05,460 --> 11:16:06,460
increment score
15455
11:16:08,700 --> 11:16:09,700
or increase I'll call it
15456
11:16:10,800 --> 11:16:11,800
doesn't matter we'll not worry about
15457
11:16:12,660 --> 11:16:13,660
that
15458
11:16:13,740 --> 11:16:14,740
we are going to get the score and we'll
15459
11:16:15,900 --> 11:16:16,900
set it to score plus 2 maybe
15460
11:16:18,180 --> 11:16:19,180
Plus
15461
11:16:21,660 --> 11:16:22,660
set score
15462
11:16:25,500 --> 11:16:26,500
so we'll go ahead and do that copy this
15463
11:16:27,596 --> 11:16:28,596
put it in the function name make this
15464
11:16:29,460 --> 11:16:30,460
looping
15465
11:16:30,900 --> 11:16:31,900
and we can use a binding here so we can
15466
11:16:34,620 --> 11:16:35,620
bind this
15467
11:16:36,300 --> 11:16:37,300
you can get the game state
15468
11:16:38,580 --> 11:16:39,580
you can make this a validated git
15469
11:16:41,160 --> 11:16:42,160
this is a little more expensive on your
15470
11:16:43,200 --> 11:16:44,200
computer so don't do this
15471
11:16:45,480 --> 11:16:46,480
so we can get the score
15472
11:16:47,520 --> 11:16:48,520
and we can convert this to text
15473
11:16:52,140 --> 11:16:53,140
you can use a format text node and stuff
15474
11:16:54,416 --> 11:16:55,416
I'm not really going over that so we'll
15475
11:16:56,700 --> 11:16:57,700
just do that actually so format text
15476
11:17:13,080 --> 11:17:14,080
all right
15477
11:17:15,540 --> 11:17:16,540
and we don't need to convert this
15478
11:17:19,320 --> 11:17:20,320
if we press play
15479
11:17:21,060 --> 11:17:22,060
as you can see our score is increasing
15480
11:17:23,340 --> 11:17:24,340
at a constant rate and you can see it on
15481
11:17:26,160 --> 11:17:27,160
the top left hand side for those of you
15482
11:17:28,680 --> 11:17:29,680
on mobile phones and who are not able to
15483
11:17:31,380 --> 11:17:32,380
see it I'll just make this text a little
15484
11:17:34,320 --> 11:17:35,320
bigger so 40
15485
11:17:37,140 --> 11:17:38,140
make this one regular we don't need bold
15486
11:17:41,400 --> 11:17:42,400
and this should be good
15487
11:17:45,720 --> 11:17:46,720
so as you can see everything is working
15488
11:17:48,416 --> 11:17:49,416
fine
15489
11:17:51,360 --> 11:17:52,360
and you can go ahead and set up any
15490
11:17:53,460 --> 11:17:54,460
logic if you want if you want to like
15491
11:17:55,500 --> 11:17:56,500
you know save it or whatever
15492
11:17:57,720 --> 11:17:58,720
but for now I'm happy with this
15493
11:18:01,580 --> 11:18:02,580
so that's it for this video guys thanks
15494
11:18:04,620 --> 11:18:05,620
for watching we do have a complete game
15495
11:18:06,720 --> 11:18:07,720
and instead of exit you can just show
15496
11:18:10,320 --> 11:18:11,320
the score on a widget or something I
15497
11:18:12,840 --> 11:18:13,840
will do that let's not leave it halfway
15498
11:18:15,360 --> 11:18:16,360
the last part before we just complete it
15499
11:18:19,320 --> 11:18:20,320
so we'll create a widget
15500
11:18:22,980 --> 11:18:23,980
and we'll call this one end screen
15501
11:18:28,500 --> 11:18:29,500
okay we'll add a border
15502
11:18:31,380 --> 11:18:32,380
wrap this with the canvas panel
15503
11:18:34,916 --> 11:18:35,916
so we can go ahead and wrap with canvas
15504
11:18:37,740 --> 11:18:38,740
panel
15505
11:18:38,820 --> 11:18:39,820
and this border should take up the whole
15506
11:18:41,096 --> 11:18:42,096
thing so offsets are going to be zero
15507
11:18:43,380 --> 11:18:44,380
and the brush color is going to be
15508
11:18:45,480 --> 11:18:46,480
something black black Maybe
15509
11:18:48,240 --> 11:18:49,240
and we can just go ahead and add some
15510
11:18:50,880 --> 11:18:51,880
text
15511
11:18:54,720 --> 11:18:55,720
so we need to align it right at the
15512
11:18:56,880 --> 11:18:57,880
center so
15513
11:18:59,096 --> 11:19:00,096
vertical box
15514
11:19:03,776 --> 11:19:04,776
uh
15515
11:19:06,240 --> 11:19:07,240
we can use an overlay
15516
11:19:08,400 --> 11:19:09,400
rather
15517
11:19:10,436 --> 11:19:11,436
overlay is going to be helpful here
15518
11:19:13,256 --> 11:19:14,256
so overlay
15519
11:19:16,680 --> 11:19:17,680
so border is going to be filled
15520
11:19:20,400 --> 11:19:21,400
the overlay is going to be filled as
15521
11:19:22,436 --> 11:19:23,436
well
15522
11:19:25,200 --> 11:19:26,200
so 0 0
15523
11:19:27,660 --> 11:19:28,660
all right and over here we can have text
15524
11:19:37,200 --> 11:19:38,200
and there's the advantage of using a
15525
11:19:39,416 --> 11:19:40,416
canvas panel
15526
11:19:40,860 --> 11:19:41,860
so 40
15527
11:19:43,200 --> 11:19:44,200
can make this regular Maybe
15528
11:19:49,560 --> 11:19:50,560
then go ahead and put score
15529
11:19:53,640 --> 11:19:54,640
and we can go ahead and
15530
11:19:57,360 --> 11:19:58,360
give the value
15531
11:19:59,220 --> 11:20:00,220
so
15532
11:20:01,140 --> 11:20:02,140
let's go ahead and set that so event
15533
11:20:03,300 --> 11:20:04,300
construct get game state
15534
11:20:07,320 --> 11:20:08,320
cost to our BP game State and we can get
15535
11:20:11,880 --> 11:20:12,880
access to the score variable get score
15536
11:20:15,120 --> 11:20:16,120
and we can set the text of this
15537
11:20:20,460 --> 11:20:21,460
so set the text
15538
11:20:23,340 --> 11:20:24,340
set text
15539
11:20:26,220 --> 11:20:27,220
and this is going to be about it we'll
15540
11:20:29,160 --> 11:20:30,160
format it
15541
11:20:31,700 --> 11:20:32,700
so format text
15542
11:20:40,140 --> 11:20:41,140
so this is the score
15543
11:20:45,900 --> 11:20:46,900
so let's go ahead and Center that make
15544
11:20:48,720 --> 11:20:49,720
it 0.5
15545
11:20:50,960 --> 11:20:51,960
and make everything else 0 here
15546
11:20:54,916 --> 11:20:55,916
oops uh the size shouldn't have been
15547
11:20:57,240 --> 11:20:58,240
zero
15548
11:21:02,276 --> 11:21:03,276
uh make this one central line
15549
11:21:06,240 --> 11:21:07,240
and the make sure for any vertical
15550
11:21:10,256 --> 11:21:11,256
alignment which we have
15551
11:21:12,360 --> 11:21:13,360
okay nope we don't so I'll just reduce
15552
11:21:15,240 --> 11:21:16,240
the size of this maybe to 100
15553
11:21:19,800 --> 11:21:20,800
okay this should be good now if I go
15554
11:21:22,560 --> 11:21:23,560
ahead and press play nothing will happen
15555
11:21:24,416 --> 11:21:25,416
because we haven't spawned the end
15556
11:21:25,860 --> 11:21:26,860
screen
15557
11:21:26,700 --> 11:21:27,700
uh where we have our event hit in our
15558
11:21:29,340 --> 11:21:30,340
character
15559
11:21:32,700 --> 11:21:33,700
so we can cast to obstacle and instead
15560
11:21:35,700 --> 11:21:36,700
of that we can go ahead and create a
15561
11:21:37,500 --> 11:21:38,500
widget
15562
11:21:38,820 --> 11:21:39,820
create a widget end screen
15563
11:21:42,120 --> 11:21:43,120
and we can add it to the viewport
15564
11:21:49,020 --> 11:21:50,020
all right
15565
11:21:50,640 --> 11:21:51,640
let's go ahead and do that
15566
11:21:53,220 --> 11:21:54,220
so I'm testing the end screen so I'll
15567
11:21:55,436 --> 11:21:56,436
just die immediately
15568
11:21:59,580 --> 11:22:00,580
okay so our score is 300 apparently
15569
11:22:04,200 --> 11:22:05,200
which is nice
15570
11:22:12,960 --> 11:22:13,960
okay not sure why we didn't exit
15571
11:22:15,416 --> 11:22:16,416
immediately there
15572
11:22:18,000 --> 11:22:19,000
uh we need to do once I understood the
15573
11:22:20,640 --> 11:22:21,640
problem so do once
15574
11:22:23,756 --> 11:22:24,756
because once we die the game's over
15575
11:22:26,096 --> 11:22:27,096
don't want to redo that
15576
11:22:32,580 --> 11:22:33,580
so
15577
11:22:39,180 --> 11:22:40,180
okay we need to do once from here
15578
11:22:41,460 --> 11:22:42,460
actually
15579
11:22:45,540 --> 11:22:46,540
now we just went over the obstacle which
15580
11:22:48,120 --> 11:22:49,120
was kind of stupid
15581
11:22:50,640 --> 11:22:51,640
so go ahead and try this out
15582
11:22:54,776 --> 11:22:55,776
and our score is 280.
15583
11:22:57,416 --> 11:22:58,416
so that's it for this video guys I hope
15584
11:23:00,480 --> 11:23:01,480
you guys really enjoyed this entire
15585
11:23:02,820 --> 11:23:03,820
course I know it's been over 11 hours at
15586
11:23:06,060 --> 11:23:07,060
this point but hopefully you have
15587
11:23:08,820 --> 11:23:09,820
learned something new and I hope you
15588
11:23:11,460 --> 11:23:12,460
enjoyed the last part where we actually
15589
11:23:13,256 --> 11:23:14,256
made an entire game and we didn't use
15590
11:23:15,960 --> 11:23:16,960
any C plus plus to be honest
15591
11:23:18,416 --> 11:23:19,416
so that's about it hope you guys enjoyed
15592
11:23:21,240 --> 11:23:22,240
and see you guys later goodbye1135890
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.