WEBVTT 1 00:00:23.500 --> 00:00:25.840 Hello, this is Younghoon Lee 2 00:00:25.841 --> 00:00:31.241 This time, in order to produce a shooting game that's based on C++ 3 00:00:31.241 --> 00:00:34.709 We're going to learn how to produce the project using C++ 4 00:00:34.710 --> 00:00:39.169 and learn the basic content production methods 5 00:00:39.169 --> 00:00:44.221 In this unit, we're going to create a project based off of C++ 6 00:00:44.221 --> 00:00:46.321 and compose the basic environments 7 00:00:46.322 --> 00:00:50.472 Then in C++, we're going to process user input 8 00:00:50.473 --> 00:00:53.823 and control the player 9 00:00:54.624 --> 00:00:58.058 Basic Project Settings 10 00:01:00.160 --> 00:01:04.939 This time, we're going to produce a shooting game based on C++ 11 00:01:04.940 --> 00:01:07.790 We're first going to create the project 12 00:01:07.839 --> 00:01:10.189 Select the game tab 13 00:01:10.190 --> 00:01:14.540 We're going to select the blank template 14 00:01:14.541 --> 00:01:17.741 And now select C++ 15 00:01:17.839 --> 00:01:22.180 And then, use the starter content as-is 16 00:01:22.181 --> 00:01:24.831 And then type the project name 17 00:01:24.832 --> 00:01:29.882 Like last time, I'm going to use the Cpp_ prefix 18 00:01:31.182 --> 00:01:32.920 I'll put shooting 19 00:01:32.921 --> 00:01:35.621 Create it like this 20 00:01:40.300 --> 00:01:42.750 Once the project is made 21 00:01:44.300 --> 00:01:47.319 We first need to do some environment settings 22 00:01:47.969 --> 00:01:53.270 First, set the layout to how you're used to 23 00:01:53.271 --> 00:01:55.321 I'm going to do it like this 24 00:01:56.120 --> 00:02:02.010 It becomes the same structure as when we were on blueprint 25 00:02:02.761 --> 00:02:06.111 Then, the very first thing you need to do is making a level 26 00:02:06.160 --> 00:02:08.499 Go to file, new level 27 00:02:08.500 --> 00:02:12.300 Same thing, we'll use empty level 28 00:02:12.399 --> 00:02:16.089 Create, then save 29 00:02:16.090 --> 00:02:17.590 Create a folder 30 00:02:17.590 --> 00:02:21.690 New Folder, and we'll name it Maps 31 00:02:22.790 --> 00:02:29.520 Here, I'll save the level in the name of GameMap 32 00:02:30.399 --> 00:02:33.139 Even though we're working with C++ 33 00:02:33.140 --> 00:02:35.190 we still use blueprint 34 00:02:35.190 --> 00:02:38.340 So we're going to create a blueprint folder as well 35 00:02:39.639 --> 00:02:44.000 Create the folder 36 00:02:45.720 --> 00:02:48.279 Like this 37 00:02:49.559 --> 00:02:53.609 First, we need to make the game mode base 38 00:02:53.610 --> 00:02:55.760 And we also need to make the player, Pawn 39 00:02:55.760 --> 00:02:59.750 After making both in C++ class 40 00:02:59.751 --> 00:03:03.051 we're going to inherit them with blueprint 41 00:03:03.052 --> 00:03:04.952 That will be our work process 42 00:03:05.000 --> 00:03:08.870 Should we first make the game mode? 43 00:03:08.871 --> 00:03:12.571 In order to make the game mode class with C++ 44 00:03:12.720 --> 00:03:16.910 If you look at the top, there's Tools 45 00:03:16.911 --> 00:03:22.061 If you open this, there's the new C++ class menu 46 00:03:22.061 --> 00:03:25.660 Click this, and you'll see this pop-up window 47 00:03:25.661 --> 00:03:28.061 Scroll down a little 48 00:03:29.279 --> 00:03:31.470 and you'll see game mode base 49 00:03:32.321 --> 00:03:35.221 Select this, and click next 50 00:03:35.720 --> 00:03:39.089 And if you look here, you can work as-is 51 00:03:39.090 --> 00:03:42.990 but in class type, there's public and private 52 00:03:43.039 --> 00:03:45.639 I'm going to click public 53 00:03:45.640 --> 00:03:47.440 What this does, is that 54 00:03:47.441 --> 00:03:49.341 In the case of Header file 55 00:03:49.342 --> 00:03:51.742 it will fall under the public folder 56 00:03:51.880 --> 00:03:53.780 Then for the source file 57 00:03:53.781 --> 00:03:55.981 it will fall under the private folder 58 00:03:56.880 --> 00:03:58.410 Do it like this 59 00:03:58.411 --> 00:04:00.711 Since the name is shooting 60 00:04:01.912 --> 00:04:05.962 I'm going to name it shooting game mode base 61 00:04:05.962 --> 00:04:07.560 Create 62 00:04:12.399 --> 00:04:14.369 Starting from Unreal 5 63 00:04:14.370 --> 00:04:16.770 They added a live coding function 64 00:04:16.770 --> 00:04:19.921 I'll use this function while working 65 00:04:20.119 --> 00:04:22.839 I can turn live coding on or off 66 00:04:22.840 --> 00:04:26.040 If you look here, there's this menu on the bottom right 67 00:04:26.041 --> 00:04:28.591 If you click these dots 68 00:04:28.839 --> 00:04:31.480 You can activate or deactivate it 69 00:04:32.131 --> 00:04:33.731 That's all 70 00:04:33.882 --> 00:04:34.940 Once you click this 71 00:04:34.941 --> 00:04:38.414 You can see that it compiles right away 72 00:04:38.480 --> 00:04:42.779 For Unreal versions before 5 73 00:04:42.780 --> 00:04:46.830 We would compile in visual studio 74 00:04:46.831 --> 00:04:49.831 and watch that after executing Unreal 75 00:04:50.081 --> 00:04:53.070 But that had many cons 76 00:04:53.071 --> 00:04:56.121 So the solution they provided was live coding 77 00:04:56.122 --> 00:05:00.572 Of course, there are some imperfect parts 78 00:05:00.572 --> 00:05:03.279 But after I used it 79 00:05:03.930 --> 00:05:05.830 it seems to have more stability 80 00:05:05.831 --> 00:05:08.681 So I'm going to use this to work 81 00:05:11.840 --> 00:05:13.610 Once a class is made 82 00:05:13.611 --> 00:05:16.361 Like this, under the C++ class folder 83 00:05:16.362 --> 00:05:17.962 This project's name is there 84 00:05:17.963 --> 00:05:19.463 And under the public folder 85 00:05:19.760 --> 00:05:23.049 There's the header file exposed 86 00:05:23.050 --> 00:05:24.550 We can't see the source file from here 87 00:05:24.551 --> 00:05:26.451 We can only see the header 88 00:05:26.452 --> 00:05:28.624 Now we double click this 89 00:05:28.799 --> 00:05:33.110 Then visual studio is already opened 90 00:05:34.761 --> 00:05:37.211 To take a look at the folder structure first 91 00:05:37.760 --> 00:05:39.910 Let's look at the project 92 00:05:39.911 --> 00:05:43.411 In Content, select Show in explorer 93 00:05:44.062 --> 00:05:46.501 Then we can see the folders 94 00:05:47.160 --> 00:05:51.460 This is the project job folders 95 00:05:53.311 --> 00:05:58.361 If you take a look, there are the essential folders 96 00:05:59.761 --> 00:06:05.980 Config, Content, and Source 97 00:06:07.130 --> 00:06:10.119 These are where the original files are saved 98 00:06:10.120 --> 00:06:12.570 They must never be deleted 99 00:06:12.571 --> 00:06:15.771 Then on the very bottom, uproject 100 00:06:16.519 --> 00:06:20.310 The project file, with the extension name uproject 101 00:06:20.311 --> 00:06:22.511 This file must also never be deleted 102 00:06:22.560 --> 00:06:26.489 So these 3 folders and one file 103 00:06:26.490 --> 00:06:28.190 These should never be deleted 104 00:06:28.229 --> 00:06:32.610 Even if others are deleted 105 00:06:32.611 --> 00:06:36.411 Once we execute Unreal, it will automatically be made again 106 00:06:36.760 --> 00:06:41.580 And when we compile, they're also made 107 00:06:41.581 --> 00:06:45.081 Binary is the case for that 108 00:06:45.880 --> 00:06:49.149 When you back-up this project later 109 00:06:49.150 --> 00:06:53.749 You need to back-up these four 110 00:06:53.849 --> 00:06:55.430 Let's proceed 111 00:06:57.081 --> 00:07:03.181 When we create the code with C++ 112 00:07:03.181 --> 00:07:08.429 it will be created within the source file folder 113 00:07:08.679 --> 00:07:13.350 It's created here, in the public and private folders 114 00:07:13.351 --> 00:07:15.051 The content there 115 00:07:15.200 --> 00:07:20.119 In visual studio, looks like this 116 00:07:20.720 --> 00:07:24.820 Of course, just because there's the file in the folder 117 00:07:25.019 --> 00:07:27.440 doesn't mean it will all be exposed here 118 00:07:27.441 --> 00:07:30.391 For visual studio, we have to input it in order to show here 119 00:07:30.640 --> 00:07:33.119 So even if there are multiple files here 120 00:07:33.120 --> 00:07:37.420 Over here, they only show the inputted files 121 00:07:40.119 --> 00:07:43.860 We first made the game mode 122 00:07:45.559 --> 00:07:48.809 Should we make the player too? 123 00:07:48.810 --> 00:07:53.510 Select New C++ class 124 00:07:54.260 --> 00:07:56.540 Our player is going to be Pawn 125 00:07:56.540 --> 00:07:58.441 Select Pawn 126 00:07:59.640 --> 00:08:01.129 It's says it in English here 127 00:08:01.130 --> 00:08:05.330 Pawn is an actor 128 00:08:06.829 --> 00:08:09.039 that can be possessed 129 00:08:09.940 --> 00:08:11.490 Click next 130 00:08:11.491 --> 00:08:15.491 I'll name it PlayerPawn 131 00:08:17.440 --> 00:08:19.140 Create it 132 00:08:25.000 --> 00:08:29.480 Among the extension programs, I'm using visual assist 133 00:08:29.481 --> 00:08:31.681 so my colors may look different 134 00:08:32.080 --> 00:08:35.880 Keep that in mind while watching this 135 00:08:37.880 --> 00:08:40.101 After making this 136 00:08:40.301 --> 00:08:42.751 We should set this up first 137 00:08:46.200 --> 00:08:52.270 If you look at the C++ folder, you'll see two classes 138 00:08:52.271 --> 00:08:54.821 We'll make this in blueprint 139 00:08:55.321 --> 00:08:59.370 First, select game mode base and right-click 140 00:08:59.370 --> 00:09:02.559 And there's Create Blueprint Class Base 141 00:09:02.560 --> 00:09:04.010 Click this 142 00:09:04.359 --> 00:09:09.760 Then the blueprint class that inherits this class can be made 143 00:09:09.760 --> 00:09:13.129 Select the blueprint folder 144 00:09:13.130 --> 00:09:16.379 For prefix, I'll put BP_ 145 00:09:19.029 --> 00:09:21.529 Create the game mode like this 146 00:09:21.530 --> 00:09:25.030 We'll make the player the same way 147 00:09:25.031 --> 00:09:27.081 Like this, blueprint 148 00:09:36.000 --> 00:09:40.159 Then we'll save all of these 149 00:09:40.919 --> 00:09:44.030 Then the structure will be like this 150 00:09:44.031 --> 00:09:46.431 The class made in C++ 151 00:09:46.432 --> 00:09:48.982 is inherited by the blueprint class 152 00:09:49.080 --> 00:09:54.060 The parent class is the player, Pawn 153 00:09:54.061 --> 00:09:55.811 And for the game mode as well 154 00:09:55.812 --> 00:09:59.062 It inherited the C++ class 155 00:10:01.359 --> 00:10:05.120 156 00:10:05.120 --> 00:10:10.071 Go to Edit, Project Settings, then Maps & Modes 157 00:10:10.320 --> 00:10:11.859 We'll set it up here 158 00:10:11.860 --> 00:10:13.460 Since we made the map 159 00:10:13.461 --> 00:10:18.911 We'll set the game map to start up map and default map 160 00:10:20.400 --> 00:10:23.840 And for default mode, we'll leave it as-is 161 00:10:23.841 --> 00:10:28.141 On the world setting of this level 162 00:10:28.142 --> 00:10:31.142 I'll designate this 163 00:10:34.559 --> 00:10:39.250 Over here, go to Settings in the top right corner 164 00:10:39.251 --> 00:10:40.951 They also have World Settings here 165 00:10:40.952 --> 00:10:45.452 We'll make those settings here 166 00:10:47.919 --> 00:10:50.969 And the player is in default right now 167 00:10:50.970 --> 00:10:54.170 Let's set this to BP_PlayerPawn that we made 168 00:10:54.170 --> 00:10:55.630 When this is edited 169 00:10:55.631 --> 00:11:00.131 It says that the blueprint class here was changed 170 00:11:00.131 --> 00:11:02.182 Let's save all of this 171 00:11:02.880 --> 00:11:06.530 Then now the player has been set 172 00:11:06.531 --> 00:11:09.881 Here, we need the camera and lights 173 00:11:09.882 --> 00:11:11.882 We'll do it the same way 174 00:11:12.080 --> 00:11:14.770 Here, there's Light 175 00:11:14.771 --> 00:11:18.021 Add Directional Light 176 00:11:19.200 --> 00:11:22.480 This is the correct direction 177 00:11:22.931 --> 00:11:27.731 Rotate it so that the X points to the inside of the screen 178 00:11:29.400 --> 00:11:31.879 And let's arrange the camera 179 00:11:32.480 --> 00:11:35.530 We'll place the camera actor in the screen 180 00:11:39.010 --> 00:11:43.030 And we'll set the camera the same way 181 00:11:43.031 --> 00:11:45.231 Reset rotation 182 00:11:45.232 --> 00:11:50.582 and push it back 10 meters 183 00:11:51.280 --> 00:11:55.430 Then change Perspective to Orthographic 184 00:11:55.431 --> 00:11:56.781 to do orthogonal projection 185 00:11:57.132 --> 00:12:01.744 And we'll set the width to 1920 186 00:12:05.229 --> 00:12:10.160 Then the player should use this camera 187 00:12:10.161 --> 00:12:16.311 So go to Auto Player Activation, and set it to Player 0 188 00:12:21.400 --> 00:12:25.450 And the player will appear on the screen 189 00:12:25.450 --> 00:12:26.909 Let's take a look 190 00:12:26.910 --> 00:12:28.760 For the player Pawn 191 00:12:28.761 --> 00:12:30.661 Let's first put a cube 192 00:12:30.661 --> 00:12:34.919 When we execute it, it appears on the screen 193 00:12:34.920 --> 00:12:36.870 But it's at the wrong spot 194 00:12:36.871 --> 00:12:41.171 That's because we didn't set the player's exact location 195 00:12:41.172 --> 00:12:42.672 So it was placed randomly 196 00:12:42.672 --> 00:12:48.350 So in BASIC, there's Player Start 197 00:12:48.351 --> 00:12:50.051 We'll use this to place it 198 00:12:50.051 --> 00:12:52.051 For player start 199 00:12:52.801 --> 00:12:54.439 First put it in the center 200 00:12:54.440 --> 00:12:56.340 then we'll lower it a little 201 00:13:00.769 --> 00:13:03.130 Execute it, and now it looks good 202 00:13:03.681 --> 00:13:05.081 Arrange it like that 203 00:13:05.231 --> 00:13:09.032 Then since we're working with C++ 204 00:13:10.080 --> 00:13:12.750 although some are done with blueprint 205 00:13:12.751 --> 00:13:17.501 The basic core logics should all be done using C++ 206 00:13:18.200 --> 00:13:20.999 We're going to work on it ourselves in the source code 207 00:13:21.000 --> 00:13:24.550 So we're going to do the coding with C++ 208 00:13:25.599 --> 00:13:30.079 Here, I put the cube as the appearance 209 00:13:30.080 --> 00:13:31.530 but we're going to delete this 210 00:13:31.530 --> 00:13:34.081 For the component that will be inserted here 211 00:13:34.582 --> 00:13:38.382 let's create it in the code 212 00:13:41.280 --> 00:13:44.889 Then we first need to go to the header file 213 00:13:45.489 --> 00:13:46.940 Compile first 214 00:13:46.941 --> 00:13:49.541 Then on the top right hand corner 215 00:13:49.542 --> 00:13:52.742 Click the Player Pawn, the parent class 216 00:13:53.280 --> 00:13:55.230 and it will go over to this window 217 00:13:55.231 --> 00:13:57.631 You can open it 218 00:13:59.520 --> 00:14:02.279 Or over here, it's like this 219 00:14:02.729 --> 00:14:05.380 You can do that here 220 00:14:06.479 --> 00:14:07.749 Go to the header file 221 00:14:07.750 --> 00:14:10.650 Open public, and there's the header file 222 00:14:11.701 --> 00:14:14.601 We don't need to expand this 223 00:14:16.299 --> 00:14:18.619 Scroll down 224 00:14:19.820 --> 00:14:22.420 Put public 225 00:14:24.889 --> 00:14:26.980 What we're going to do here, is 226 00:14:27.630 --> 00:14:32.709 Collider, a collider component 227 00:14:32.710 --> 00:14:40.210 We want to create the component and place it as Root 228 00:14:41.359 --> 00:14:43.809 I said this before 229 00:14:43.810 --> 00:14:45.410 I don't know if you'll remember 230 00:14:46.361 --> 00:14:50.611 For Unreal, if there's an Actor 231 00:14:51.159 --> 00:14:53.129 There's the actor component 232 00:14:53.130 --> 00:14:57.380 The actor basically has a root component 233 00:15:00.000 --> 00:15:02.039 It has a root component 234 00:15:02.040 --> 00:15:05.990 And under that, other components come in 235 00:15:07.599 --> 00:15:10.697 It can branch out like this 236 00:15:11.997 --> 00:15:15.232 Or it may branch out from the root 237 00:15:16.139 --> 00:15:18.740 It has a hierarchy like this 238 00:15:19.941 --> 00:15:26.128 Usually, the component with the collider 239 00:15:26.129 --> 00:15:29.129 gets inserted into the Root 240 00:15:30.240 --> 00:15:33.709 So what I'm going to do is 241 00:15:33.710 --> 00:15:36.560 The player is going to have this structure 242 00:15:39.119 --> 00:15:43.669 For the player, I'm going to put the box component in the Root 243 00:15:44.170 --> 00:15:47.120 Then here, I'm going to put Mesh 244 00:15:47.919 --> 00:15:52.320 And here, I can put something like Arrow 245 00:15:53.719 --> 00:15:57.049 That's the hierarchy I'm going to make 246 00:15:57.050 --> 00:16:01.500 We'll do the arrow later, and we'll first work on this 247 00:16:03.259 --> 00:16:06.330 That's what I wrote, and then 248 00:16:07.880 --> 00:16:16.700 Create the component in charge of the outer appearance 249 00:16:16.701 --> 00:16:20.201 and place it in Root 250 00:16:20.400 --> 00:16:24.309 Then Root, ultimately, becomes the collider 251 00:16:24.310 --> 00:16:27.260 So now 252 00:16:27.359 --> 00:16:32.280 we're going to declare in the header first 253 00:16:32.280 --> 00:16:35.150 In Unreal, we use prefixes 254 00:16:35.151 --> 00:16:36.751 Prefixes are very important 255 00:16:36.752 --> 00:16:40.902 If you look here, it says Pawn 256 00:16:41.000 --> 00:16:44.380 When you ctrl+click on it 257 00:16:44.381 --> 00:16:46.281 You can see its parent 258 00:16:46.281 --> 00:16:48.869 It's inheriting the actor like this, right? 259 00:16:49.620 --> 00:16:55.020 So the guys that inherit an actor all use the prefix, A 260 00:16:55.919 --> 00:16:58.740 That's why prefixes are important 261 00:16:59.441 --> 00:17:03.291 Above the actor, it's inheriting from UObject 262 00:17:03.591 --> 00:17:06.480 It says U, right? 263 00:17:08.359 --> 00:17:10.760 Remember those prefixes 264 00:17:10.761 --> 00:17:15.511 Normally, Actors, Pawn, Characters start with A 265 00:17:16.060 --> 00:17:20.799 And the components start with U 266 00:17:21.199 --> 00:17:26.599 And all the others usually start with F 267 00:17:26.599 --> 00:17:29.810 There's also S but 268 00:17:29.811 --> 00:17:31.411 those are very little 269 00:17:31.412 --> 00:17:34.912 Most of them use A, U, or F 270 00:17:34.913 --> 00:17:37.713 often as their prefixes 271 00:17:37.760 --> 00:17:40.569 So we're going to make a component 272 00:17:40.570 --> 00:17:43.720 All components start with U 273 00:17:43.721 --> 00:17:46.621 So write U first 274 00:17:46.719 --> 00:17:51.560 Type UBox, and there's auto fill 275 00:17:51.561 --> 00:17:55.111 Create something called UBox component 276 00:17:55.111 --> 00:17:58.009 We're going to make this as a pointer 277 00:17:59.239 --> 00:18:03.739 So I'll write boxComp 278 00:18:03.740 --> 00:18:08.440 And for C++, we need to declare header 279 00:18:08.440 --> 00:18:10.670 To use this 280 00:18:10.671 --> 00:18:12.771 The header of boxComp 281 00:18:12.772 --> 00:18:15.772 needs to be included here to use it 282 00:18:16.720 --> 00:18:21.550 But if we keep including in header file 283 00:18:21.551 --> 00:18:23.651 there may be problems later when we're compiling 284 00:18:23.652 --> 00:18:25.252 It will become very slow 285 00:18:25.400 --> 00:18:27.050 So in Unreal 286 00:18:27.050 --> 00:18:32.390 Or for all C++ based contents 287 00:18:32.391 --> 00:18:35.941 They all use "include what you use" 288 00:18:36.040 --> 00:18:37.950 When you include header 289 00:18:37.951 --> 00:18:41.151 include it at the implementing place 290 00:18:41.152 --> 00:18:43.252 That's the guideline 291 00:18:43.400 --> 00:18:45.430 So we're going to use that method as well 292 00:18:45.431 --> 00:18:48.931 Then we used that here 293 00:18:48.932 --> 00:18:51.332 But we didn't actually implement it because it's a pointer 294 00:18:51.332 --> 00:18:54.299 We're going to implement it now in source file 295 00:18:54.300 --> 00:18:56.400 So we need to do a forward declaration 296 00:18:56.599 --> 00:18:59.280 If we do it the proper way 297 00:18:59.281 --> 00:19:04.781 we should do the forward declaration at the top, on top of the class 298 00:19:05.181 --> 00:19:08.080 Then we can use this 299 00:19:08.081 --> 00:19:12.381 But forward declaration is this 300 00:19:12.382 --> 00:19:14.132 "We're going to use this" 301 00:19:14.133 --> 00:19:16.183 is what it's saying beforehand 302 00:19:16.280 --> 00:19:19.369 But if we do this every time, we need to scroll up and down 303 00:19:19.370 --> 00:19:24.420 So this is the formal way 304 00:19:24.420 --> 00:19:25.730 But the shortcut is 305 00:19:26.631 --> 00:19:30.681 Writing the class here right away 306 00:19:31.680 --> 00:19:35.819 Then we're doing forward declaration in the abbreviated way 307 00:19:35.820 --> 00:19:37.620 That's the forward declaration 308 00:19:37.719 --> 00:19:41.549 And this Ucomponent 309 00:19:41.550 --> 00:19:44.800 is a component provided by Unreal engine 310 00:19:44.801 --> 00:19:47.051 So when we use this 311 00:19:47.052 --> 00:19:50.302 We're going to use this in engine 312 00:19:50.599 --> 00:19:54.069 In Unreal engine, we're going to use that 313 00:19:54.070 --> 00:19:58.270 But even if we write it in C++ code 314 00:19:58.271 --> 00:20:01.021 the engine can't read it 315 00:20:01.119 --> 00:20:05.689 So when we produce the Unreal engine 316 00:20:05.690 --> 00:20:10.840 there's the Unreal header tool and the Unreal build tool 317 00:20:10.841 --> 00:20:12.589 Those are the two tools 318 00:20:12.589 --> 00:20:17.959 Those tools were used to implement reflection 319 00:20:18.059 --> 00:20:21.710 What reflection is, is that 320 00:20:21.959 --> 00:20:26.349 The content worked on here will also be seen in the engine 321 00:20:26.350 --> 00:20:29.594 It's just like the name, reflecting 322 00:20:29.599 --> 00:20:31.940 That's the concept 323 00:20:31.941 --> 00:20:35.590 For recent languages such as 324 00:20:35.591 --> 00:20:40.641 Python, C#, Java all these provide the reflection function 325 00:20:40.641 --> 00:20:44.400 So using that 326 00:20:44.851 --> 00:20:48.201 we can see the content of the corresponding class 327 00:20:48.202 --> 00:20:51.752 But C++ was released a while ago 328 00:20:51.800 --> 00:20:53.910 That's why it didn't have those functions 329 00:20:53.911 --> 00:20:57.661 But while producing the Unreal engine 330 00:20:57.662 --> 00:21:02.612 In order to make those, they implemented it themselves 331 00:21:02.612 --> 00:21:05.799 There's a rule 332 00:21:05.800 --> 00:21:09.200 In the header, in order to do reflection 333 00:21:09.201 --> 00:21:12.801 the header tool reads the header file 334 00:21:12.849 --> 00:21:17.279 and uses that to create a class 335 00:21:17.279 --> 00:21:18.730 That's the structure 336 00:21:18.731 --> 00:21:19.666 So at the very bottom 337 00:21:19.667 --> 00:21:23.067 There's the Generated header file 338 00:21:23.116 --> 00:21:25.340 It says under the "include" 339 00:21:25.841 --> 00:21:27.091 This must be there 340 00:21:27.092 --> 00:21:31.992 This class, the part without the A 341 00:21:33.140 --> 00:21:34.830 The same name as B 342 00:21:34.981 --> 00:21:36.981 The actual file name is this too, right 343 00:21:37.182 --> 00:21:39.332 That's the structure 344 00:21:39.333 --> 00:21:42.383 Then for including the header file 345 00:21:42.680 --> 00:21:45.450 It has to be at the very bottom of all the includes 346 00:21:45.451 --> 00:21:48.701 For example, it can't be switched like this 347 00:21:48.851 --> 00:21:50.939 There will be errors 348 00:21:51.540 --> 00:21:55.590 The rule is that it must be like this 349 00:21:55.839 --> 00:21:57.919 In order to do reflection 350 00:21:58.120 --> 00:22:03.670 if all of them are the target of reflection 351 00:22:03.671 --> 00:22:05.221 then it will be inconvenient 352 00:22:05.221 --> 00:22:09.109 The file size will be big and there will be unnecessary information 353 00:22:09.310 --> 00:22:11.360 In order to make that precise 354 00:22:11.459 --> 00:22:16.820 Here, in the UProperty 355 00:22:16.921 --> 00:22:19.771 literally means the properties of Unreal 356 00:22:19.771 --> 00:22:23.220 We use macro like these 357 00:22:23.220 --> 00:22:28.950 to designate that this variable is 358 00:22:28.951 --> 00:22:30.856 the target of reflection 359 00:22:32.959 --> 00:22:35.410 And here, there's a designator goes in 360 00:22:35.961 --> 00:22:40.111 For the main designators, in Unreal 361 00:22:40.560 --> 00:22:44.579 Here, I'll make the cube that I made earlier 362 00:22:44.680 --> 00:22:48.330 When I click this, there are the details, right? 363 00:22:48.479 --> 00:22:54.679 In order to see these, we need to set the designator 364 00:22:54.930 --> 00:22:57.430 That this component will be seen like that 365 00:22:57.431 --> 00:22:59.031 To see in details 366 00:23:01.131 --> 00:23:05.060 There's the Edit or Visible concept 367 00:23:05.061 --> 00:23:09.111 Use one of these prefixes 368 00:23:10.810 --> 00:23:11.919 Then plus 369 00:23:12.070 --> 00:23:13.720 Plus means profit 370 00:23:13.871 --> 00:23:17.371 Then Edit 371 00:23:20.599 --> 00:23:23.160 anywhere 372 00:23:29.359 --> 00:23:32.640 We'll have to write it here 373 00:23:33.560 --> 00:23:37.959 Here, there's EditAnywhere 374 00:23:37.960 --> 00:23:40.710 And there's Anywhere 375 00:23:40.711 --> 00:23:44.611 Then there's EditDefaultsOnly 376 00:23:45.359 --> 00:23:49.760 Like that, and then 377 00:23:50.760 --> 00:23:53.130 There's InstanceOnly 378 00:23:53.131 --> 00:23:56.731 We can do this with visible as well 379 00:23:59.249 --> 00:24:02.779 There are three in visible 380 00:24:03.280 --> 00:24:05.530 It's put together like this 381 00:24:05.531 --> 00:24:09.431 EditAnywhere, EditDefaultsOnly, EditInstanceOnly 382 00:24:09.530 --> 00:24:12.201 Like this, or visible 383 00:24:12.201 --> 00:24:14.901 Edit means editable 384 00:24:14.901 --> 00:24:17.152 Visible is read only 385 00:24:17.400 --> 00:24:20.600 So are we going to read only 386 00:24:20.601 --> 00:24:23.901 or will we be able to insert something, that's the concept 387 00:24:23.902 --> 00:24:24.902 What that means is 388 00:24:25.400 --> 00:24:28.370 When we select this 389 00:24:29.471 --> 00:24:31.471 We can insert a value here 390 00:24:31.872 --> 00:24:33.123 Like this 391 00:24:33.123 --> 00:24:35.573 This is Edit 392 00:24:36.320 --> 00:24:37.370 That's the meaning 393 00:24:37.370 --> 00:24:40.349 And for visible, we can only see this and not edit 394 00:24:40.350 --> 00:24:41.850 These here for example 395 00:24:42.151 --> 00:24:46.401 Of course, we can check this off to edit, then back to visible 396 00:24:46.401 --> 00:24:48.760 That's the concept 397 00:24:48.761 --> 00:24:51.961 It can control these 398 00:24:53.359 --> 00:24:58.040 Then for DefaultsOnly and InstanceOnly, it means where 399 00:24:58.041 --> 00:25:00.991 This is Anywhere, so it means both 400 00:25:00.991 --> 00:25:04.989 And this is only in Default, this is only in Instance 401 00:25:04.990 --> 00:25:08.790 So in class 402 00:25:09.289 --> 00:25:11.889 If you look here, this is our Edit window 403 00:25:11.890 --> 00:25:15.740 Then we can do it in the Editor window 404 00:25:15.741 --> 00:25:18.441 And when we take this out 405 00:25:18.441 --> 00:25:23.410 Now it's in the state of being at the outliner of the level, Instance 406 00:25:23.411 --> 00:25:27.611 At the instance state, if we still want to expose it here and edit it 407 00:25:29.011 --> 00:25:31.290 Then that's InstanceOnly 408 00:25:31.441 --> 00:25:33.341 Anywhere means both are possible 409 00:25:33.342 --> 00:25:36.992 So whether we'll edit only in blueprint class 410 00:25:37.040 --> 00:25:40.010 or whether we'll only edit in instance 411 00:25:40.011 --> 00:25:42.011 or do it in both, that's what it means 412 00:25:42.212 --> 00:25:44.512 So at first this may be hard 413 00:25:44.513 --> 00:25:47.213 So what I recommend is 414 00:25:47.213 --> 00:25:49.969 Rather than memorizing all of these 415 00:25:49.970 --> 00:25:55.370 First, EditAnywhere means we can literally edit anywhere 416 00:25:55.370 --> 00:25:57.300 So work with this first 417 00:25:57.300 --> 00:25:59.551 And you'll know later 418 00:25:59.552 --> 00:26:01.552 that something shouldn't be there 419 00:26:01.553 --> 00:26:04.103 That you shouldn't edit something 420 00:26:04.103 --> 00:26:05.909 You'll have those 421 00:26:06.060 --> 00:26:09.510 For example, that you should only do it in EditDefaultsOnly 422 00:26:09.511 --> 00:26:13.161 So once you start seeing those 423 00:26:13.359 --> 00:26:15.059 Then you'll have to write this exactly 424 00:26:15.310 --> 00:26:21.869 In this lecture for now, I'll use EditAnywhere 425 00:26:22.320 --> 00:26:25.640 Player Input Process 426 00:26:26.369 --> 00:26:31.149 Next, we're going to write the component in charge of the outer appearance 427 00:26:31.150 --> 00:26:34.400 Back to here, the cube 428 00:26:34.400 --> 00:26:36.860 This is a Static Mesh component 429 00:26:36.861 --> 00:26:42.561 There are two main components for outer appearance in Unreal 430 00:26:42.611 --> 00:26:46.610 There's Static Mesh and there's Skeletal Mesh 431 00:26:47.911 --> 00:26:51.211 Static Mesh means literally static 432 00:26:51.212 --> 00:26:54.212 It's a fixed mesh shape 433 00:26:54.212 --> 00:26:58.410 For Skeletal Mesh, it has the shape of a skeleton 434 00:26:58.411 --> 00:27:01.511 It has a skeleton 435 00:27:01.512 --> 00:27:04.762 and it can be animated 436 00:27:04.762 --> 00:27:08.429 So right now, we can go with Static Mesh 437 00:27:09.529 --> 00:27:12.210 Let's create a Static Mesh component 438 00:27:12.211 --> 00:27:13.611 Delete this 439 00:27:15.880 --> 00:27:20.399 So same thing, let's copy UProperty 440 00:27:21.150 --> 00:27:24.000 Then for the outer appearance 441 00:27:24.000 --> 00:27:30.351 put class UStaticMeshComponent 442 00:27:31.351 --> 00:27:35.239 We'll put MeshComponent 443 00:27:35.680 --> 00:27:41.319 Should we do it in caps 444 00:27:41.669 --> 00:27:45.000 Let's put it in capital letters 445 00:27:50.000 --> 00:27:52.210 Then we'll have to make this 446 00:27:52.211 --> 00:27:56.861 Making is done here, in the constructor 447 00:27:57.162 --> 00:27:59.612 The constructor in Unreal is a little special 448 00:28:00.962 --> 00:28:04.130 The role of the constructor is 449 00:28:04.131 --> 00:28:07.931 Normally, when we make an object, the constructor of that object is called over 450 00:28:07.931 --> 00:28:11.039 Then there, we reset and do all those 451 00:28:11.340 --> 00:28:15.640 For constructor in Unreal, the basics are like that 452 00:28:15.640 --> 00:28:17.940 but this is different 453 00:28:21.280 --> 00:28:27.749 First, the engine is activated 454 00:28:27.749 --> 00:28:31.599 Or the app is executed 455 00:28:32.569 --> 00:28:34.439 At the developing step, it will be engine activation 456 00:28:34.440 --> 00:28:36.340 And when it's made as a build file and executed 457 00:28:36.341 --> 00:28:37.991 then it becomes the app execution step 458 00:28:37.992 --> 00:28:42.492 At this step, you know the things we wrote beforehand 459 00:28:42.492 --> 00:28:45.343 The actors that inherited UObject 460 00:28:46.443 --> 00:28:48.800 We create the Actors beforehand 461 00:28:48.800 --> 00:28:50.919 Create them first 462 00:28:54.119 --> 00:28:56.369 And how it's made is 463 00:29:00.690 --> 00:29:02.549 Like this 464 00:29:03.350 --> 00:29:06.550 Let's bring the picture 465 00:29:06.550 --> 00:29:08.359 Here, there's the header tool 466 00:29:08.360 --> 00:29:12.510 When the Unreal header tool runs 467 00:29:13.159 --> 00:29:14.749 it creates the Actor beforehand 468 00:29:14.750 --> 00:29:17.900 It doesn't create one, but 2 instances 469 00:29:18.199 --> 00:29:19.590 It creates 2 classes 470 00:29:19.741 --> 00:29:22.141 It creates the UClass 471 00:29:23.040 --> 00:29:25.399 and the Unreal Object Class 472 00:29:25.400 --> 00:29:27.250 And using those, it makes objects 473 00:29:27.251 --> 00:29:28.752 It makes instances 474 00:29:28.752 --> 00:29:30.849 The UClass instance and 475 00:29:30.849 --> 00:29:32.870 the CDO instance 476 00:29:32.870 --> 00:29:37.079 The UClass instance is used in reflection 477 00:29:39.479 --> 00:29:43.400 So when there's an object 478 00:29:43.400 --> 00:29:46.051 When they're comparing the objects 479 00:29:46.051 --> 00:29:48.551 Or in engine or blueprint 480 00:29:48.551 --> 00:29:50.571 casting to see if the object is there 481 00:29:50.571 --> 00:29:53.670 Those using reflection 482 00:29:53.670 --> 00:29:56.440 Then they process by using UClass 483 00:29:56.440 --> 00:30:00.441 Then we create components 484 00:30:02.640 --> 00:30:06.519 When we create them 485 00:30:06.520 --> 00:30:10.520 Let's say for example, there's a class 486 00:30:11.119 --> 00:30:13.150 If there's class A 487 00:30:13.151 --> 00:30:19.151 Inside, there are variables int A, int B 488 00:30:19.552 --> 00:30:23.052 Let's say that there are about 100 variables 489 00:30:23.400 --> 00:30:28.729 Then when we create object A 490 00:30:29.080 --> 00:30:33.279 In constructor, this has to be set up one by one 491 00:30:33.429 --> 00:30:35.530 We need to copy all of them 492 00:30:35.531 --> 00:30:38.131 We need to insert them through substitution 493 00:30:38.282 --> 00:30:42.682 But the inserting process itself takes a long time 494 00:30:42.682 --> 00:30:43.830 Inserting like this 495 00:30:44.581 --> 00:30:47.781 So instead, we create this beforehand 496 00:30:47.782 --> 00:30:49.882 We create object A 497 00:30:49.882 --> 00:30:53.510 Then when we create objects after that 498 00:30:54.311 --> 00:30:55.961 When we create this Actor 499 00:30:55.962 --> 00:31:00.812 Then we copy the object that we pre-made 500 00:31:00.812 --> 00:31:03.719 We do memory copy 501 00:31:04.839 --> 00:31:09.090 Then memory copy is much faster than inputting one-by-one 502 00:31:09.091 --> 00:31:12.991 For that use, we create CDO 503 00:31:12.991 --> 00:31:16.209 This stands for 504 00:31:16.260 --> 00:31:18.860 Class Default Object 505 00:31:19.959 --> 00:31:23.109 Class Default Object 506 00:31:25.119 --> 00:31:26.960 That's how we call it 507 00:31:28.760 --> 00:31:33.149 So we make these two instances 508 00:31:33.150 --> 00:31:39.399 So the role of the constructor in Unreal is 509 00:31:40.499 --> 00:31:43.890 When we make an object, rather than calling the constructor then 510 00:31:43.891 --> 00:31:46.040 and creating it like this every time 511 00:31:46.040 --> 00:31:48.840 If there's nothing, make one 512 00:31:48.841 --> 00:31:51.041 and for all the ones coming after 513 00:31:51.042 --> 00:31:54.242 Memory-copy the existing ones 514 00:31:54.242 --> 00:31:57.439 That's the structure 515 00:31:58.330 --> 00:32:00.760 So we need to write that here 516 00:32:00.761 --> 00:32:05.811 How that will work is 517 00:32:08.000 --> 00:32:10.399 I explain more because it's the beginning 518 00:32:10.400 --> 00:32:12.900 Later, I'll just continue quickly 519 00:32:14.599 --> 00:32:20.289 The name of the collider component is BoxComp 520 00:32:20.289 --> 00:32:28.850 There's the CreateDefaultSubobject function 521 00:32:28.900 --> 00:32:30.530 Using that 522 00:32:32.439 --> 00:32:34.510 We create this 523 00:32:36.560 --> 00:32:37.999 Like this 524 00:32:38.000 --> 00:32:41.250 This is in the template form 525 00:32:41.251 --> 00:32:45.701 So here, put UBoxComponent 526 00:32:45.701 --> 00:32:48.089 And after that, we put the name 527 00:32:48.090 --> 00:32:51.790 The name earlier, in Unreal engine 528 00:32:51.791 --> 00:32:54.591 This name here, that's the name 529 00:32:55.839 --> 00:32:58.130 So there's a rule 530 00:32:58.131 --> 00:33:02.227 We can't have the same name in the class 531 00:33:03.280 --> 00:33:08.179 So I recommend using the variable name as-is 532 00:33:09.180 --> 00:33:10.980 You don't have to do it this way 533 00:33:11.479 --> 00:33:14.929 If you can distinguish it surely, then you can use it 534 00:33:14.930 --> 00:33:18.680 But if it's hard to name 535 00:33:18.681 --> 00:33:21.281 use the same name as the variable 536 00:33:22.479 --> 00:33:25.220 Then we'll place this in Root 537 00:33:25.220 --> 00:33:29.170 And there's the SetRootComponent function 538 00:33:29.171 --> 00:33:30.171 It's a function 539 00:33:30.172 --> 00:33:32.072 Here, we put the new component 540 00:33:32.119 --> 00:33:36.000 We'll put it like this 541 00:33:37.270 --> 00:33:38.979 And to use this 542 00:33:38.980 --> 00:33:42.480 We need to do add header here 543 00:33:44.029 --> 00:33:46.300 When we don't know what header this is 544 00:33:46.301 --> 00:33:50.151 Then in Google, let's write it like this 545 00:33:50.152 --> 00:33:52.402 Search it like this, and it will come up 546 00:33:52.402 --> 00:33:54.452 There's a document 547 00:33:54.452 --> 00:33:58.119 Click on it, and it looks like this 548 00:33:58.119 --> 00:34:02.740 Here, they say include this for header 549 00:34:02.741 --> 00:34:05.591 Then we include this 550 00:34:06.490 --> 00:34:07.790 And Unreal basically 551 00:34:07.790 --> 00:34:10.889 is composed of combinations of modules 552 00:34:10.890 --> 00:34:14.440 It's a class included in the module, engine 553 00:34:14.440 --> 00:34:17.920 So copy this 554 00:34:17.921 --> 00:34:20.571 and add it like this 555 00:34:20.571 --> 00:34:27.449 For those of you using visual assist or ReSharper like me 556 00:34:27.450 --> 00:34:31.250 There's a shortcut here 557 00:34:31.250 --> 00:34:36.320 You can do Shift-Alt-Q to include 558 00:34:36.320 --> 00:34:37.449 You can do it like that as well 559 00:34:37.450 --> 00:34:40.800 Here, the header is like this 560 00:34:40.801 --> 00:34:43.901 This is what's written here 561 00:34:44.749 --> 00:34:48.609 You can write it like this, or like this 562 00:34:50.159 --> 00:34:54.410 Then let's make the component for the outer appearance the same way 563 00:34:54.711 --> 00:34:56.961 This is the mesh component 564 00:34:59.110 --> 00:35:03.279 CreateDefaultSubobject, then text 565 00:35:03.280 --> 00:35:04.930 Write it the same way 566 00:35:14.829 --> 00:35:17.399 UStaticMeshComponent 567 00:35:17.399 --> 00:35:22.080 We'll name it MeshComponent 568 00:35:30.980 --> 00:35:33.370 And then 569 00:35:33.370 --> 00:35:37.170 Should we make the Arrow along with it 570 00:35:38.171 --> 00:35:42.021 It's the player, so the Arrow for shooting later 571 00:35:42.021 --> 00:35:44.122 Let's make it here first 572 00:35:44.122 --> 00:35:53.429 class UArrowComponent 573 00:35:54.799 --> 00:35:57.249 Should we put Arrow 574 00:35:58.450 --> 00:36:03.350 Same thing, we need to add this 575 00:36:06.600 --> 00:36:10.339 Here, in the constructor as well, the Arrow 576 00:36:10.379 --> 00:36:15.479 CreateDefaultSubobject 577 00:36:20.529 --> 00:36:23.220 Write it 578 00:36:24.660 --> 00:36:29.909 UArrowComponent, and this also has to be added to headers 579 00:36:36.159 --> 00:36:39.119 StaticMeshComponent won't necessarily need it 580 00:36:39.119 --> 00:36:44.940 It's probably already included somewhere 581 00:36:45.391 --> 00:36:46.491 You can use it as-is 582 00:36:46.742 --> 00:36:48.342 Like this 583 00:36:48.343 --> 00:36:51.043 Then all of these need to be added to Root as well 584 00:36:51.043 --> 00:36:53.469 MeshComponent in Root 585 00:36:53.470 --> 00:36:57.520 SetupAttachment 586 00:36:57.521 --> 00:37:00.471 And we'll write RootComponent 587 00:37:02.269 --> 00:37:05.269 Same thing for Arrow 588 00:37:05.269 --> 00:37:07.439 Write it like this 589 00:37:07.439 --> 00:37:09.450 We'll have to change the location for the Arrow 590 00:37:09.451 --> 00:37:12.501 Let's try this later, when we're shooting 591 00:37:12.802 --> 00:37:15.652 Let's arrange it like this for now 592 00:37:16.600 --> 00:37:19.600 Gun 593 00:37:23.320 --> 00:37:28.300 Then should we compile it now? 594 00:37:29.600 --> 00:37:32.580 Delete the cube 595 00:37:34.280 --> 00:37:38.760 Save it, then we'll compile it 596 00:37:41.199 --> 00:37:43.200 It worked well 597 00:37:43.201 --> 00:37:44.901 Double-click on it 598 00:37:46.120 --> 00:37:47.970 And you can see that it changed like this 599 00:37:47.970 --> 00:37:52.620 The components that we added in C++ are shown here 600 00:37:54.019 --> 00:37:57.410 Then here, on the mesh in charge of the outer appearance 601 00:37:57.411 --> 00:37:59.411 Should we put the StaticMesh in here? 602 00:37:59.760 --> 00:38:03.930 Search for cube here 603 00:38:03.931 --> 00:38:06.681 It sometimes doesn't appear for some of you 604 00:38:07.080 --> 00:38:11.689 Then open this, and it's like this 605 00:38:11.690 --> 00:38:14.190 If show engine content 606 00:38:14.190 --> 00:38:15.891 is not checked, then you won't be able to see them 607 00:38:16.439 --> 00:38:19.229 So you have to click that in order to see these 608 00:38:26.120 --> 00:38:29.719 Like this, cube 609 00:38:30.080 --> 00:38:33.240 Then here, there's Approach Size 610 00:38:33.241 --> 00:38:35.191 Right now, it's in 100x100x100 611 00:38:35.840 --> 00:38:39.239 There's a same cube, but the size is different 612 00:38:39.240 --> 00:38:41.290 It's in 256x256x256 613 00:38:41.290 --> 00:38:44.629 I'll use the 100x100x100 one, or 1 m 614 00:38:44.630 --> 00:38:45.930 You have to watch for it 615 00:38:46.679 --> 00:38:48.689 It's placed in viewport now 616 00:38:48.690 --> 00:38:49.690 Compile, then 617 00:38:49.691 --> 00:38:51.991 We can also insert the Material under that 618 00:38:52.239 --> 00:38:53.860 You can use it as-is 619 00:38:53.861 --> 00:39:00.061 But if you put basicshapematerial 620 00:39:00.062 --> 00:39:04.412 Then the material that we used first is this guy 621 00:39:04.612 --> 00:39:06.549 We'll use this 622 00:39:07.520 --> 00:39:10.279 Should we move the arrow up a little 623 00:39:10.630 --> 00:39:12.330 Rotate it a little 624 00:39:13.760 --> 00:39:16.199 After setting it like this 625 00:39:17.700 --> 00:39:21.300 we can continue the work in C++ constructor 626 00:39:21.399 --> 00:39:23.580 Normally when we work on this 627 00:39:23.581 --> 00:39:27.131 at the prototype step, we use the blueprint often 628 00:39:27.131 --> 00:39:29.749 And then after that 629 00:39:29.750 --> 00:39:34.100 we take these content back to the source code 630 00:39:34.101 --> 00:39:36.351 and fill in the values 631 00:39:36.351 --> 00:39:39.859 That's how we process it 632 00:39:40.360 --> 00:39:43.331 Player Movement Process 633 00:39:44.509 --> 00:39:47.639 Then after that, we'll try moving this 634 00:39:48.439 --> 00:39:52.049 When we execute it, the player will appear 635 00:39:52.050 --> 00:39:53.050 Now it just has to move 636 00:39:53.199 --> 00:39:56.479 To move, same thing here 637 00:39:57.230 --> 00:39:59.480 Use the four types of input 638 00:39:59.481 --> 00:40:00.681 to move it 639 00:40:00.681 --> 00:40:05.360 Let's fill it in, in input 640 00:40:05.360 --> 00:40:09.009 Make 2 access mapping 641 00:40:09.010 --> 00:40:12.560 One is horizontal, one is vertical 642 00:40:13.159 --> 00:40:17.320 Horizontal and Vertical 643 00:40:23.639 --> 00:40:25.629 Insert it like this 644 00:40:25.630 --> 00:40:30.780 For horizontal, we'll put A, D, W, S 645 00:40:30.780 --> 00:40:38.840 A is negative, and S is negative 646 00:40:41.360 --> 00:40:46.239 And now we're going to work on that here 647 00:40:46.239 --> 00:40:49.240 Basically here 648 00:40:49.241 --> 00:40:50.791 There's this function 649 00:40:50.841 --> 00:40:54.780 SetPlayerInputComponent 650 00:40:54.781 --> 00:40:59.231 Here, I'm going to receive the key input 651 00:40:59.280 --> 00:41:03.360 But when we work on it here, the structure is 652 00:41:03.360 --> 00:41:06.709 We need to create a function that will be called when the key is pressed 653 00:41:06.710 --> 00:41:09.160 So we connect that function to here 654 00:41:09.160 --> 00:41:11.080 This is called bind 655 00:41:11.081 --> 00:41:12.081 It's literally binding 656 00:41:12.082 --> 00:41:15.882 It would mean linking them together 657 00:41:16.080 --> 00:41:20.030 So we process this through binding 658 00:41:20.030 --> 00:41:22.639 Then 659 00:41:23.399 --> 00:41:25.920 In order to bind, we need 2 functions first 660 00:41:25.921 --> 00:41:26.921 Go to the header file 661 00:41:27.320 --> 00:41:31.519 Under that, here 662 00:41:31.520 --> 00:41:33.527 In response to the input 663 00:41:33.919 --> 00:41:41.040 The horizontal and vertical inputs 664 00:41:42.040 --> 00:41:46.719 will be received by a function 665 00:41:47.159 --> 00:41:48.219 Let's write it like that 666 00:41:48.220 --> 00:41:50.220 So it's a void type 667 00:41:50.221 --> 00:42:00.239 OnHorizontal... I'll use the prefix like this 668 00:42:00.289 --> 00:42:02.679 OnAxisHorizontal 669 00:42:02.679 --> 00:42:06.959 We're going to receive it as float value 670 00:42:08.709 --> 00:42:19.120 Then void again, OnAxisVertical 671 00:42:28.000 --> 00:42:30.900 Right now, we don't need it but 672 00:42:30.900 --> 00:42:34.030 I mentioned UProperty earlier 673 00:42:34.031 --> 00:42:36.031 But this is about the variable 674 00:42:36.080 --> 00:42:39.180 For function as well, in order to do reflection 675 00:42:39.180 --> 00:42:43.040 There's the UFunction macro 676 00:42:43.040 --> 00:42:46.889 This can be used to do reflection 677 00:42:46.890 --> 00:42:49.740 But I don't think we need that at the moment 678 00:42:49.740 --> 00:42:53.510 I'll put it like this for now 679 00:42:53.511 --> 00:42:57.711 We can use the UFunction and UProperty macro 680 00:42:57.760 --> 00:42:59.949 to do reflection processing 681 00:42:59.950 --> 00:43:02.500 Of course, it doesn't just have the reflection function 682 00:43:02.501 --> 00:43:05.451 Using this, we can do additional jobs as well 683 00:43:05.451 --> 00:43:06.830 We're going to implement this now 684 00:43:06.831 --> 00:43:09.481 We can implement it as-is, but 685 00:43:09.482 --> 00:43:13.032 Press Alt+Enter, and this will show 686 00:43:14.280 --> 00:43:17.920 I'm using extension now, but let me turn it off for a second 687 00:43:17.921 --> 00:43:20.621 Do Alt+Enter, and it will appear like this 688 00:43:20.622 --> 00:43:22.322 It's the same 689 00:43:22.520 --> 00:43:25.489 You can use this, or the one at the top 690 00:43:25.590 --> 00:43:30.390 Press Enter, and the function is implemented automatically 691 00:43:32.520 --> 00:43:35.300 The function that I'm talking about is method 692 00:43:35.301 --> 00:43:39.701 The member function. So going to the player Pawn 693 00:43:39.702 --> 00:43:43.652 You can see that the two functions are implemented on the bottom 694 00:43:43.652 --> 00:43:47.310 We'll have to implement them now by actually linking them 695 00:43:47.310 --> 00:43:52.959 We'll link them here 696 00:43:54.709 --> 00:43:57.079 Here, going to the parameters 697 00:43:57.080 --> 00:43:59.430 There's something called Player Input Component 698 00:43:59.430 --> 00:44:02.431 We can bind using this guy 699 00:44:02.879 --> 00:44:06.149 There's action and axis, but we're using axis 700 00:44:06.150 --> 00:44:09.000 Put axis 701 00:44:09.000 --> 00:44:10.951 And then here 702 00:44:11.699 --> 00:44:14.900 The name that we wrote here 703 00:44:14.901 --> 00:44:18.751 Use the name that we wrote in mapping 704 00:44:18.800 --> 00:44:21.820 We made Horizontal and Vertical 705 00:44:21.821 --> 00:44:24.021 Write it like this 706 00:44:24.120 --> 00:44:28.959 To be safe, put TEXT 707 00:44:30.879 --> 00:44:32.830 Then put a comma 708 00:44:32.831 --> 00:44:35.131 Second, we put the user class 709 00:44:35.132 --> 00:44:38.832 This is talking about the class that will actually receive the input 710 00:44:38.833 --> 00:44:41.433 then we'll put ourselves 711 00:44:43.469 --> 00:44:46.319 It's object, not class 712 00:44:46.320 --> 00:44:48.870 Since it's a pointer, we're putting this pointer 713 00:44:48.871 --> 00:44:52.421 Then we link the functions 714 00:44:52.919 --> 00:44:57.989 Right now, it's Horizontal, so this one, AxisHorizontal 715 00:44:57.990 --> 00:45:00.489 Then the full name is this 716 00:45:00.489 --> 00:45:04.270 Starting from the class name, write everything 717 00:45:04.271 --> 00:45:07.021 Write it like this 718 00:45:07.120 --> 00:45:11.720 In the function, we need to add ptr, or the pointer 719 00:45:11.721 --> 00:45:15.321 So put & in the front 720 00:45:15.520 --> 00:45:19.199 And through the veterans 721 00:45:19.200 --> 00:45:22.050 we'll hand over the address of this function 722 00:45:22.199 --> 00:45:26.800 Use the same method to make Vertical 723 00:45:29.320 --> 00:45:32.239 Vertical 724 00:45:32.480 --> 00:45:35.010 We linked the two like this 725 00:45:35.261 --> 00:45:37.211 Then the value will be handed over 726 00:45:37.212 --> 00:45:40.510 Then we'll remember this value and move in Tic 727 00:45:41.660 --> 00:45:46.229 Since we need to use this value in another location 728 00:45:46.230 --> 00:45:47.981 We'll have to save this 729 00:45:47.981 --> 00:45:53.531 So in header, we'll make two variables to save these values 730 00:45:54.479 --> 00:46:02.929 Make variables h and b, and we'll save them to use 731 00:46:02.929 --> 00:46:07.430 Here in h, put value 732 00:46:08.131 --> 00:46:12.731 And here in b, put value like this 733 00:46:19.530 --> 00:46:21.079 We're almost done 734 00:46:21.080 --> 00:46:22.780 Go to Tic 735 00:46:22.781 --> 00:46:24.481 Now we move in Tic 736 00:46:24.482 --> 00:46:28.482 Recall the motion equation 737 00:46:29.679 --> 00:46:36.009 p = p0 + vt, that's the equation that we're going to use 738 00:46:36.010 --> 00:46:37.910 The delta time comes over 739 00:46:37.959 --> 00:46:40.419 In blueprint, it was delta second 740 00:46:40.420 --> 00:46:41.420 Here, it says time 741 00:46:41.421 --> 00:46:45.771 Since delta time comes over, we'll use that 742 00:46:45.919 --> 00:46:53.250 Then the final location is, after making a vector at the current location 743 00:46:53.251 --> 00:46:55.351 It becomes velocity multiplied by delta time 744 00:46:55.352 --> 00:46:58.152 Let's first make velocity 745 00:46:58.800 --> 00:47:02.810 It starts with f, vector 746 00:47:02.910 --> 00:47:06.549 We'll put velocity 747 00:47:06.600 --> 00:47:09.200 Velocity needs direction 748 00:47:09.201 --> 00:47:13.251 We need to make the direction 749 00:47:16.129 --> 00:47:22.940 If we're doing absolute direction, put FVector 750 00:47:22.940 --> 00:47:26.809 Then this is x, y, z 751 00:47:26.810 --> 00:47:29.160 x, y, z 752 00:47:31.111 --> 00:47:36.512 Then the left right corresponds to h, or y 753 00:47:37.062 --> 00:47:42.812 In the coordinate, the left and right direction is y 754 00:47:43.312 --> 00:47:47.329 and up and down is z 755 00:47:47.379 --> 00:47:52.569 So in y, put h, and in z, put v 756 00:47:53.840 --> 00:47:56.439 Then 757 00:47:56.679 --> 00:48:00.439 It will be 0, h, v 758 00:48:00.440 --> 00:48:04.540 Now that we made direction, we also need speed 759 00:48:04.639 --> 00:48:07.030 We'll create a speed variable 760 00:48:07.031 --> 00:48:10.681 Like this, put multiply speed 761 00:48:11.280 --> 00:48:15.739 Then now it's the velocity 762 00:48:15.740 --> 00:48:21.040 We'll have to check it in header 763 00:48:21.090 --> 00:48:23.250 Put UPROPERTY 764 00:48:23.251 --> 00:48:28.651 Then we'll make a variable, float speed 765 00:48:30.479 --> 00:48:31.730 Like this 766 00:48:31.731 --> 00:48:35.881 Then we need Normalize 767 00:48:35.932 --> 00:48:37.682 So here 768 00:48:38.280 --> 00:48:42.040 Normally we can use the Normalize function 769 00:48:42.040 --> 00:48:47.540 but the return value doesn't return vector 770 00:48:47.540 --> 00:48:48.991 It returns success or fail 771 00:48:49.639 --> 00:48:54.600 So instead of that, put safe 772 00:48:55.119 --> 00:48:57.629 There's SafeNormal 773 00:48:57.730 --> 00:49:00.480 Use this 774 00:49:01.129 --> 00:49:04.219 to obtain Normalize 775 00:49:04.220 --> 00:49:06.370 Here, make elaborated vector 776 00:49:06.371 --> 00:49:09.871 Receive the Normalize vector, and there 777 00:49:10.020 --> 00:49:13.679 Multiply speed to make velocity 778 00:49:16.320 --> 00:49:18.840 And then 779 00:49:21.000 --> 00:49:23.089 We also need p0 780 00:49:23.090 --> 00:49:25.290 p0 is GetActorLocation 781 00:49:25.291 --> 00:49:27.891 Let's still make it 782 00:49:29.520 --> 00:49:33.800 We'll put p0 783 00:49:34.350 --> 00:49:38.280 GetActorLocation 784 00:49:39.919 --> 00:49:42.070 Then finally, we just need to insert it 785 00:49:42.071 --> 00:49:50.171 SetActorLocation, p0 + velocity 786 00:49:50.521 --> 00:49:54.679 times t, DeltaTime 787 00:49:58.959 --> 00:50:03.879 We wrote it like this 788 00:50:04.439 --> 00:50:08.249 We'll have to compile first 789 00:50:08.250 --> 00:50:09.850 Compile like this 790 00:50:12.679 --> 00:50:17.280 Then execute it 791 00:50:17.280 --> 00:50:20.899 It should move, but it's not moving 792 00:50:21.350 --> 00:50:24.600 Let's check again 793 00:50:25.000 --> 00:50:27.330 Ah we didn't give a value for speed 794 00:50:27.331 --> 00:50:30.031 I didn't put anything for speed 795 00:50:30.032 --> 00:50:32.632 In Unreal, the constructor is used 796 00:50:32.633 --> 00:50:34.233 to reset this value 797 00:50:34.233 --> 00:50:36.600 Then it becomes reset to 0 798 00:50:36.601 --> 00:50:39.401 So we'll put 500 799 00:50:39.600 --> 00:50:42.881 Come back here, and compile again 800 00:50:43.481 --> 00:50:47.031 Go to Player Pawn, go to class default 801 00:50:47.032 --> 00:50:49.232 It says 500 802 00:50:49.280 --> 00:50:51.760 Like this 803 00:50:52.639 --> 00:50:58.000 Execute it, and it works well 804 00:51:00.399 --> 00:51:04.579 Let's summarize the content learned in this lecture 805 00:51:05.080 --> 00:51:07.372 Basic Project Settings Creating project based on C++ and the basic setting methods Role of the constructor in Unreal and CDO UPROPERTY, UFUNCTION macro 806 00:51:07.372 --> 00:51:09.523 Player input process Creating and binding function for user input process in C++ 807 00:51:09.523 --> 00:51:11.673 Player movement process Creating the component in the constructor function Using the input value to move based on the user's input 808 00:51:11.673 --> 00:51:12.673 The End