1 00:00:24.600 --> 00:00:30.680 This is Kim Hyun-Jin, and I am teaching Unreal Engine Basics for Immersive Contents 2 00:00:30.680 --> 00:00:34.880 In this chapter, we will learn about what Blueprints are 3 00:00:34.880 --> 00:00:39.220 And what its basic grammars are 4 00:00:39.250 --> 00:00:42.900 Blueprint Node: Structure and Flow 5 00:00:43.320 --> 00:00:45.970 Let's create a new level 6 00:00:45.970 --> 00:00:51.799 File, New Level, and select Basic 7 00:00:51.799 --> 00:00:57.420 Create, and then save 8 00:00:57.420 --> 00:01:03.420 Let's name it 'BlueprintLevel' 9 00:01:03.420 --> 00:01:06.120 Make sure to save 10 00:01:06.120 --> 00:01:11.320 At our Content Browser, select our Content folder 11 00:01:11.320 --> 00:01:13.920 And we see all these files we created 12 00:01:13.920 --> 00:01:16.559 Let's make some folders to organize them 13 00:01:16.559 --> 00:01:20.659 Click on Add, and select New Folder 14 00:01:21.409 --> 00:01:29.059 Let's name it 'Space Design Level'' 15 00:01:30.009 --> 00:01:35.349 And select all the files we used for space design 16 00:01:37.080 --> 00:01:42.030 And drag everything into that folder 17 00:01:42.720 --> 00:01:46.460 And we get this option; select 'move here' 18 00:01:49.480 --> 00:01:54.369 And all the files move just like so 19 00:01:56.279 --> 00:01:59.529 And let's double click our Space Design Level 20 00:01:59.529 --> 00:02:03.379 And we go to that level where we did the space design 21 00:02:04.919 --> 00:02:08.669 And when we click on this Blueprint Level 22 00:02:08.919 --> 00:02:12.489 Then we move to this basic level 23 00:02:13.639 --> 00:02:15.389 Let's create another folder 24 00:02:15.389 --> 00:02:21.019 You can also right click on Content Browser to do so 25 00:02:21.919 --> 00:02:29.780 Select New Folder, and let's name is Blueprint Level 26 00:02:31.080 --> 00:02:36.439 And let's drag this Blueprint Level to move 27 00:02:39.479 --> 00:02:43.429 Double click on this folder, Blueprint Level 28 00:02:43.429 --> 00:02:46.199 And right click 29 00:02:46.199 --> 00:02:50.280 And let's create a Blueprint Class 30 00:02:51.080 --> 00:02:52.230 Click 31 00:02:52.830 --> 00:02:55.880 And we get this winddow 32 00:02:55.880 --> 00:03:01.080 Here we choose what we are going to make our Blueprint Class out of 33 00:03:01.080 --> 00:03:05.270 Meaning, we are choosing what would be its parent 34 00:03:06.320 --> 00:03:12.279 Let's choose Actor as the parent 35 00:03:12.279 --> 00:03:15.880 So choose Actor 36 00:03:15.880 --> 00:03:24.880 Let's name it 'BlueprintStudy' 37 00:03:25.720 --> 00:03:32.490 Double click to open the file, and you get this Blueprint window 38 00:03:34.000 --> 00:03:39.600 We get Viewport, Constructor Script and Event Graph tabs 39 00:03:39.600 --> 00:03:42.399 Here, choose Event Graph tab 40 00:03:42.399 --> 00:03:48.530 And we get these nodes already created 41 00:03:48.880 --> 00:03:52.479 These are called Blueprint Nodes 42 00:03:53.800 --> 00:04:01.960 Right click and let's type 'print' to search 43 00:04:03.000 --> 00:04:07.800 And we get this menu called Print String 44 00:04:07.800 --> 00:04:10.199 Click on that 45 00:04:10.199 --> 00:04:14.499 And that adds a node called Print String 46 00:04:14.899 --> 00:04:20.320 And now, go to this node called Event Begin Play 47 00:04:20.920 --> 00:04:25.520 Hover the cursor over this triangular icon 48 00:04:25.520 --> 00:04:31.399 And drag it out to have this line out 49 00:04:31.399 --> 00:04:37.699 And as you drag it to this triangular shape at Blueprint String 50 00:04:37.699 --> 00:04:40.739 This dropdown will connect the two 51 00:04:43.160 --> 00:04:48.910 And now, click on 'Compile' on your top left 52 00:04:48.910 --> 00:04:51.650 And press 'Save' 53 00:04:52.959 --> 00:04:55.759 What does 'Compile' do? 54 00:04:55.859 --> 00:04:58.409 We just added a node 55 00:04:58.409 --> 00:05:04.190 And by compiling, we let the computer know that this should work well 56 00:05:04.540 --> 00:05:06.540 So whenever we change something 57 00:05:06.540 --> 00:05:10.110 Always press 'Compile' afterwards 58 00:05:11.480 --> 00:05:16.280 And inside Print String, here at 'In String' 59 00:05:16.280 --> 00:05:17.780 It says 'Hello' 60 00:05:17.780 --> 00:05:19.920 And let's click on it 61 00:05:19.920 --> 00:05:24.669 And change it to 'Hello World' 62 00:05:25.469 --> 00:05:30.119 Since we just changed this part, we should compile again 63 00:05:30.119 --> 00:05:31.469 See this question mark? 64 00:05:31.469 --> 00:05:34.760 This means that we should compile now 65 00:05:34.760 --> 00:05:41.009 So click on it, and when it becomes a blue tick mark, it means it succeeded 66 00:05:41.959 --> 00:05:45.259 Now, back to our Blueprint Level 67 00:05:45.559 --> 00:05:50.350 And let's drag out this BlueprintStudy to place it here 68 00:05:51.000 --> 00:05:54.400 I told you that only actors can be on this level, right? 69 00:05:54.400 --> 00:05:57.839 And what was the parent when we created this Blueprint? 70 00:05:57.839 --> 00:06:00.589 We chose 'Actor', remember? 71 00:06:00.589 --> 00:06:05.329 That means that this BlueprintStudy is an actor 72 00:06:06.079 --> 00:06:09.479 That's why we can place it here 73 00:06:10.129 --> 00:06:15.419 So now let's finally press on 'Run' 74 00:06:16.119 --> 00:06:23.880 And we just saw 'Hello World' to our top left 75 00:06:23.880 --> 00:06:27.180 Let's stop and press 'Play' 76 00:06:27.180 --> 00:06:31.600 And it prints 'Hello World' 77 00:06:31.600 --> 00:06:37.150 Next to Content Drawer, there is a menu called Output Log 78 00:06:37.150 --> 00:06:40.409 Let's go to that menu 79 00:06:40.959 --> 00:06:44.909 And at this first class for BlueprintStudy 80 00:06:44.909 --> 00:06:48.459 It has printed 'Hello World' 81 00:06:48.459 --> 00:06:51.769 That's the message we see printed here as well 82 00:06:52.519 --> 00:06:56.469 We will be using that Output Log Window often as well 83 00:06:56.469 --> 00:07:01.580 So let's just pin it here, like this Content Browser 84 00:07:02.880 --> 00:07:06.730 So go to Window, and Output Log 85 00:07:06.730 --> 00:07:12.839 Click on the menu and it goes next to our Content Browser 86 00:07:12.839 --> 00:07:16.699 So we can go back and forth these tabs 87 00:07:18.000 --> 00:07:21.700 Let's now create another Print String 88 00:07:21.700 --> 00:07:28.050 Click on the node, Ctrl C and Ctrl V to copy and paste 89 00:07:28.600 --> 00:07:34.809 Now, let's connect this node called Event Tick to Print String 90 00:07:35.059 --> 00:07:40.529 Let's change the content, let's call it 'Unreal Engine' 91 00:07:41.079 --> 00:07:45.429 And then Compile, come back to Blueprint level 92 00:07:45.429 --> 00:07:47.729 And 'Play' 93 00:07:48.279 --> 00:07:51.479 Now we see a lot of 'Unreal Engine' 94 00:07:51.479 --> 00:07:53.129 It keeps printing 95 00:07:53.879 --> 00:07:55.939 Let's stop 96 00:07:56.239 --> 00:07:58.639 Let's play and then stop right away 97 00:07:58.639 --> 00:08:00.989 I pressed 'Play' and stopped right away 98 00:08:01.339 --> 00:08:05.770 Then, at Output Log, we only see one 'Hello World' 99 00:08:05.770 --> 00:08:09.679 And this repeating 'Unreal Engine' 100 00:08:10.679 --> 00:08:12.779 And here, we can see that 101 00:08:12.779 --> 00:08:18.640 Begin Play is something that is called only once when run 102 00:08:18.640 --> 00:08:22.140 And then for Event Tick, it is something 103 00:08:22.140 --> 00:08:25.360 That is called in repeatedly after it runs 104 00:08:27.359 --> 00:08:32.759 And when we want to disconnect this 105 00:08:32.759 --> 00:08:38.009 While pressing Alt, hover the cursor over the line 106 00:08:38.009 --> 00:08:41.899 And left click to make it disappear 107 00:08:42.799 --> 00:08:50.149 Let's now move this Print String node that says 'Unreal Engine' 108 00:08:50.149 --> 00:08:54.440 And after this Print String with 'Hello World' runs 109 00:08:54.440 --> 00:08:56.919 Let's connect it like so 110 00:08:58.200 --> 00:09:02.300 So the order is, Begin Play runs 111 00:09:02.300 --> 00:09:07.650 And moving over, Print String runs 112 00:09:07.650 --> 00:09:09.700 And then, also moving over 113 00:09:09.900 --> 00:09:15.199 This Print String for 'Unreal Engine' runs 114 00:09:15.599 --> 00:09:18.849 So let's play at our Blueprint level 115 00:09:19.499 --> 00:09:23.599 In this Output Log, it says 'Hello World' runs first 116 00:09:23.599 --> 00:09:28.539 And then 'Unreal Engine' runs afterwards 117 00:09:29.339 --> 00:09:34.529 So this pin on the top is called the 'Execution Pin' 118 00:09:35.129 --> 00:09:39.919 So this visualizes the order in which the nodes are run 119 00:09:39.960 --> 00:09:44.760 And the content inside is called 'Input Pin' 120 00:09:44.760 --> 00:09:50.059 It takes a data input and holds that value 121 00:09:51.005 --> 00:09:54.755 Using Variables 122 00:09:55.039 --> 00:09:59.060 Now, let's try using some variables 123 00:10:00.760 --> 00:10:05.160 Before that, what is a variable? 124 00:10:05.460 --> 00:10:09.130 Variable is a bowl that holds data 125 00:10:10.880 --> 00:10:18.839 But for a variable, we need to specify it to hold only some kinds of data 126 00:10:18.889 --> 00:10:22.389 And what does that is data type 127 00:10:22.389 --> 00:10:27.080 So variable and data type are like a pair 128 00:10:28.679 --> 00:10:33.319 And today we will talk about around four data types 129 00:10:34.479 --> 00:10:36.279 First is int data type 130 00:10:36.279 --> 00:10:42.969 Int makes a variable to hold integers 131 00:10:43.119 --> 00:10:46.419 Meaning, to hold numbers 132 00:10:46.419 --> 00:10:50.469 Natural numbers like 1, 2, 3, 4 133 00:10:50.469 --> 00:10:51.719 Or 0 as well 134 00:10:51.719 --> 00:10:59.879 And also negative numbers like -1, -2, -3 are in this data type 135 00:10:59.879 --> 00:11:03.760 Float allows for real numbers 136 00:11:03.760 --> 00:11:07.910 This allows for any decimal points as well 137 00:11:07.910 --> 00:11:11.420 So this includes what int includes as well 138 00:11:11.420 --> 00:11:19.359 But it also allows for real numbers, such as decimal points as well 139 00:11:20.320 --> 00:11:25.070 Now, bool type can only hold two things 140 00:11:25.170 --> 00:11:28.830 True or False 141 00:11:32.440 --> 00:11:36.690 So it is always either True or False 142 00:11:36.690 --> 00:11:41.809 String is for text values 143 00:11:42.359 --> 00:11:48.209 Let's now practice with these basic four data types 144 00:11:48.909 --> 00:11:52.709 To the left, we see My Blueprint window 145 00:11:52.709 --> 00:11:57.400 And there is a tab called VARIABLES 146 00:11:57.400 --> 00:12:01.150 And see the plus icon there? 147 00:12:01.950 --> 00:12:04.879 Click on the plus button 148 00:12:05.329 --> 00:12:08.079 And this creates a variable 149 00:12:08.229 --> 00:12:12.529 The first tab sets the variable name 150 00:12:12.529 --> 00:12:16.759 And the second, try the dropdown menu for Boolean 151 00:12:17.359 --> 00:12:20.009 And we get to choose the data type 152 00:12:20.459 --> 00:12:21.709 There are a lot of types 153 00:12:21.709 --> 00:12:27.679 But today, we will just test the basic four 154 00:12:28.599 --> 00:12:32.499 For now, Boolean is the default data type 155 00:12:32.499 --> 00:12:35.919 So let's start with this and see how this works 156 00:12:35.919 --> 00:12:38.469 Let's rename it as well 157 00:12:39.169 --> 00:12:45.559 You can either click on its name part or press F2 to rename it 158 00:12:45.559 --> 00:12:51.259 Or you can select that variable and move to the right at 'Details' 159 00:12:51.259 --> 00:12:57.919 And this shows what the name is and what its data type is as well 160 00:12:57.919 --> 00:13:00.819 You can rename this here as well 161 00:13:00.819 --> 00:13:04.440 Let's name it as 'isbool' 162 00:13:04.440 --> 00:13:07.890 Now, to the left, under VARIABLES 163 00:13:07.890 --> 00:13:12.960 The name of our variable changed into 'isbool' here as well 164 00:13:12.960 --> 00:13:15.660 Now, when we compile it 165 00:13:15.660 --> 00:13:21.760 Under Details, we get a tab called Default Value 166 00:13:21.760 --> 00:13:25.510 And here is 'is Bool' and a checkbox 167 00:13:25.510 --> 00:13:29.479 And this default value here is False 168 00:13:29.479 --> 00:13:36.119 And if we tick it, the default value is True 169 00:13:36.119 --> 00:13:39.319 So based on what the default value 170 00:13:39.319 --> 00:13:42.469 For your variable should be 171 00:13:42.469 --> 00:13:45.409 You can modify this part 172 00:13:46.440 --> 00:13:48.840 Here, I made its default value True 173 00:13:48.840 --> 00:13:55.759 And let's go ahead and check if our variable says True 174 00:13:56.359 --> 00:14:02.459 So drag this variable into Event Graph 175 00:14:02.459 --> 00:14:05.409 And it asks if you're bringing in the value in the bowl 176 00:14:05.409 --> 00:14:09.399 Or if you're setting that value in this bowl 177 00:14:09.399 --> 00:14:11.699 You are to choose between the two 178 00:14:11.699 --> 00:14:15.099 For now, we are just checking what the value is 179 00:14:15.099 --> 00:14:17.799 So let's click on 'get isBool' 180 00:14:17.799 --> 00:14:22.039 And add a node that looks like this 181 00:14:22.760 --> 00:14:28.110 Now, hover over this red pin of the node 182 00:14:28.110 --> 00:14:32.840 Drag it out and connect it to this 'In String' 183 00:14:32.840 --> 00:14:40.159 And this converts this bool type to a string type so that it prints 184 00:14:40.159 --> 00:14:45.629 For this 'Unreal Engine' part, let's select and delete 185 00:14:46.679 --> 00:14:53.229 Let's compile and come back to Blueprint level to run 186 00:14:53.229 --> 00:14:57.010 Now we see 'True' here 187 00:14:58.280 --> 00:15:02.680 So we now know that it starts with 'True' 188 00:15:02.680 --> 00:15:05.430 Let's drag in isBool again 189 00:15:05.430 --> 00:15:11.839 And this time let's bring in a node through this menu, 'set isBool' 190 00:15:11.839 --> 00:15:19.659 This means that this Execution Pin will set the value of this 'isBool' when it is run 191 00:15:19.659 --> 00:15:26.960 Since it is not ticked here, it means that isBool is set as False 192 00:15:26.960 --> 00:15:33.410 So click on this Execution Pin while pressing Alt to disconnect 193 00:15:33.410 --> 00:15:37.679 Let's say, when Begin Play starts, it starts setting 194 00:15:37.679 --> 00:15:40.779 For the value of isBool 195 00:15:40.779 --> 00:15:46.140 And then it will print it, that's how we changed a bit 196 00:15:46.390 --> 00:15:51.960 Then, before this set-node runs, is-bool will be True 197 00:15:51.960 --> 00:15:58.080 But here, as set-node runs, is-bool changes to False 198 00:15:58.080 --> 00:16:03.080 And this parts asks for printing the value of is-bool 199 00:16:03.080 --> 00:16:06.880 Because we changes it into False here 200 00:16:06.880 --> 00:16:10.309 It will be printing False 201 00:16:11.108 --> 00:16:16.209 Let's compile and play 202 00:16:16.209 --> 00:16:20.119 And we see 'False' as what is printed here 203 00:16:20.479 --> 00:16:23.679 Let's create another variable with this plus button 204 00:16:23.679 --> 00:16:29.559 Let's now name it 'intVar' 205 00:16:29.559 --> 00:16:32.309 And then, at the dropdown menu from Boolean 206 00:16:32.309 --> 00:16:36.280 Let's choose 'Integer' for int 207 00:16:36.280 --> 00:16:43.599 IntVar means this data type is integer 208 00:16:43.599 --> 00:16:47.499 So compile again, select intVar 209 00:16:47.499 --> 00:16:52.950 And at Details, we can also set its default value 210 00:16:52.950 --> 00:16:55.119 Now, it is set as 0 211 00:16:55.119 --> 00:16:58.169 So if I set it as 100 212 00:16:58.169 --> 00:17:03.280 As we run everything, this will start with 100 213 00:17:04.160 --> 00:17:08.760 So let's drag in this intVar from the left 214 00:17:08.760 --> 00:17:13.420 And let's use get intVar to bring in a node 215 00:17:14.400 --> 00:17:18.950 And right click, search for Print String 216 00:17:18.950 --> 00:17:21.560 And add a Print String node 217 00:17:21.560 --> 00:17:26.660 And next to this bool type Print String 218 00:17:27.260 --> 00:17:31.249 Let's connect this newly added Print String node 219 00:17:31.599 --> 00:17:34.099 And this In String value 220 00:17:34.099 --> 00:17:43.040 Let's set it so that this value is printed as what our variable holds 221 00:17:44.040 --> 00:17:47.160 Let's re-organize the nodes 222 00:17:49.079 --> 00:17:55.279 Now, compile and back to our Blueprint level to run 223 00:17:55.279 --> 00:17:59.440 Now we see this value 100 224 00:18:00.040 --> 00:18:06.479 It disappears right away at Viewport, so it may be easier to check at Output Log 225 00:18:06.479 --> 00:18:08.579 So 'False' is printed first 226 00:18:08.579 --> 00:18:13.109 And then we see this value '100' printed 227 00:18:13.959 --> 00:18:22.040 Let's continue with float and string type variables 228 00:18:22.040 --> 00:18:24.840 So VARIABLES, click on the plus button 229 00:18:24.840 --> 00:18:29.319 Name it 'floatVar' 230 00:18:29.319 --> 00:18:33.720 And from the dropdown menu, choose 'Float' 231 00:18:33.970 --> 00:18:40.570 And add another, name it 'stringVar' 232 00:18:40.570 --> 00:18:43.239 Click on what it says 'float' now 233 00:18:43.239 --> 00:18:47.800 To choose the menu that says 'string' 234 00:18:48.119 --> 00:18:51.439 And now let's compile 235 00:18:51.880 --> 00:18:56.230 Select floatVar, and at Details 236 00:18:56.230 --> 00:19:03.669 Let's set its default value as a decimal number, 3.14 237 00:19:04.599 --> 00:19:07.999 And for our stringVar 238 00:19:08.499 --> 00:19:13.330 Let's say its default value as 'Unreal Engine' 239 00:19:14.280 --> 00:19:19.160 And let's print everything in these variables as well 240 00:19:19.520 --> 00:19:24.470 So select this Print String node, Ctrl C and Ctrl V 241 00:19:24.470 --> 00:19:28.479 Add another to have four in total 242 00:19:28.479 --> 00:19:33.379 Drag in floatVar and bring it with 'get' 243 00:19:33.379 --> 00:19:40.239 And let's connect In String so that it prints 244 00:19:40.640 --> 00:19:45.690 Same thing with stringVar, drag and 'get' 245 00:19:45.690 --> 00:19:50.049 And connect to In String 246 00:19:50.049 --> 00:19:52.599 And it only runs when we connect the Execution Pins 247 00:19:52.599 --> 00:19:56.280 If this is not connected, the nodes at the back will not run 248 00:19:56.280 --> 00:20:00.520 So connect, connect 249 00:20:00.880 --> 00:20:06.239 And compile, and now let's play 250 00:20:06.239 --> 00:20:12.809 We see float 100 3.14 Unreal Engine, all the values in our variables 251 00:20:12.809 --> 00:20:17.119 They are all printed like so 252 00:20:18.280 --> 00:20:21.780 So based on data type, these variables here 253 00:20:21.780 --> 00:20:28.229 Can hold different data values 254 00:20:29.214 --> 00:20:32.714 Using If Statements 255 00:20:33.640 --> 00:20:38.239 Let's try an if statement now 256 00:20:38.839 --> 00:20:43.539 To an empty area at Event Graph, right click 257 00:20:43.539 --> 00:20:46.760 And search for 'branch' 258 00:20:46.760 --> 00:20:50.460 Of you can search for 'if' 259 00:20:50.460 --> 00:20:52.350 And we get 'Branch' 260 00:20:52.800 --> 00:20:56.300 Let's add this node that looks like this 261 00:20:56.850 --> 00:21:01.790 This Branch Node is an Execution Pin, and when connected 262 00:21:01.790 --> 00:21:06.040 When this node runs, based on the value in condition, 263 00:21:06.040 --> 00:21:12.070 It branches between 'true' and 'false' 264 00:21:12.070 --> 00:21:14.570 So let's say the condition is 'false' now 265 00:21:14.570 --> 00:21:17.880 Then it runs an Execution Node over at this 'false' branch 266 00:21:17.880 --> 00:21:21.130 Anything under this 'true' will not run 267 00:21:21.530 --> 00:21:24.130 Let's say it is set as 'true' 268 00:21:24.130 --> 00:21:27.670 Then anything after 'true' will run 269 00:21:27.920 --> 00:21:30.470 Let's see how it actually works 270 00:21:31.170 --> 00:21:38.360 Let's drag in our isBool and 'get' 271 00:21:38.410 --> 00:21:40.660 And we can add this data like so 272 00:21:40.660 --> 00:21:42.880 It's because they are the same bool types 273 00:21:42.880 --> 00:21:49.319 Now, according to the value in here, it will say either True or False 274 00:21:49.319 --> 00:21:54.560 Right click to add another Print String node 275 00:21:55.239 --> 00:21:58.939 Copy and paste another under here 276 00:21:58.939 --> 00:22:03.920 This will make this to run when True and this when False 277 00:22:03.920 --> 00:22:08.319 Let's say here 'it is true' 278 00:22:09.160 --> 00:22:13.280 And here, 'it is false' 279 00:22:14.640 --> 00:22:17.790 Now, for isBool, when we begin 280 00:22:17.790 --> 00:22:21.000 Since it is set as False 281 00:22:21.000 --> 00:22:23.300 This is by default False, which will print this 282 00:22:23.300 --> 00:22:29.080 Compile and play at our Blueprint level 283 00:22:30.079 --> 00:22:34.890 And at Output Log it says 'it is false' 284 00:22:35.880 --> 00:22:42.680 Then, when we start with Begin Play, we set isBool as True 285 00:22:42.680 --> 00:22:47.180 Then, when we compile and play at Blueprint level 286 00:22:47.180 --> 00:22:53.079 Now we see 'it is true' as what is printed 287 00:22:53.199 --> 00:22:54.899 Like so, an if statement 288 00:22:54.899 --> 00:23:01.400 Branches out based on whether this value in the condition is true or false 289 00:23:01.839 --> 00:23:09.719 Now let's add a value to the condition in a different way 290 00:23:09.719 --> 00:23:13.359 Let's delete isBool 291 00:23:13.640 --> 00:23:20.640 Let's drag in our intVar variable from the left 292 00:23:20.640 --> 00:23:26.199 And let's create another variable in int type 293 00:23:26.359 --> 00:23:29.259 VARIABLES, click on the plus button 294 00:23:29.259 --> 00:23:33.239 Let's name it 'intVar2' 295 00:23:33.239 --> 00:23:37.719 And its data type is again an integer 296 00:23:38.319 --> 00:23:45.680 Compile, and for Default Value, let's say 200 297 00:23:46.040 --> 00:23:53.000 Now, drag in our intVar2 to bring it in 298 00:23:53.719 --> 00:23:58.119 And drag the Execution Pin at our intVar node 299 00:23:58.119 --> 00:24:01.959 And this allows for us to search 300 00:24:01.959 --> 00:24:05.719 And here, try typing this sign 301 00:24:05.719 --> 00:24:11.599 What do you call this? This is angle bracket from our math class 302 00:24:11.599 --> 00:24:16.640 This asks whether the left value is bigger than the right 303 00:24:16.640 --> 00:24:18.640 So it poses a question 304 00:24:18.640 --> 00:24:26.000 And when we search for this, we get two nodes 305 00:24:26.000 --> 00:24:31.150 The one that asks whether the left one is bigger 306 00:24:31.150 --> 00:24:38.989 And the one that asks whether the left one is bigger or equal to the right 307 00:24:39.239 --> 00:24:43.309 So let's go with this 'Greater' 308 00:24:43.309 --> 00:24:47.620 And we get this node that looks like this 309 00:24:48.239 --> 00:24:54.959 And let's drag in our intVar2 to connect it to the second pin 310 00:24:55.040 --> 00:24:58.440 Now, intVar has the value 100 311 00:24:58.440 --> 00:25:02.199 And intVar2 has the value 200 312 00:25:02.199 --> 00:25:08.199 So here we ask, is this condition true or false? 313 00:25:08.199 --> 00:25:09.699 This is false 314 00:25:09.699 --> 00:25:16.040 So we get the value 'false' here 315 00:25:16.040 --> 00:25:21.040 And if intVar2 is 50, instead of 200 316 00:25:21.040 --> 00:25:26.000 It will ask if 100 is bigger than 50 317 00:25:26.280 --> 00:25:36.199 And for that, the value here is true, not false 318 00:25:37.079 --> 00:25:39.829 So this node uses these two values 319 00:25:39.829 --> 00:25:47.060 To decide whether it is true based on this condition 320 00:25:47.560 --> 00:25:53.479 So let's connect this value to this condition 321 00:25:54.520 --> 00:26:02.000 This is connecting the result of the comparison, of these two values, to the condition 322 00:26:02.000 --> 00:26:06.350 So if it is true 323 00:26:06.350 --> 00:26:17.769 Then this part says 'var1 is bigger than var2' 324 00:26:18.869 --> 00:26:29.890 And here, 'var1 is smaller than var2' 325 00:26:30.640 --> 00:26:33.540 Let's modify that text 326 00:26:33.540 --> 00:26:36.079 Let's compile 327 00:26:36.079 --> 00:26:39.920 Come back to Blueprint level to play 328 00:26:39.920 --> 00:26:44.570 And we get 'var1 is smaller than var2' printed here 329 00:26:44.570 --> 00:26:47.680 The reason is, now var1 has 100 330 00:26:47.680 --> 00:26:51.880 And var2 has 200 as their values 331 00:26:52.839 --> 00:26:56.589 And this is what an if statement looks like 332 00:26:57.289 --> 00:27:01.040 As we use more nodes, things may get more complex 333 00:27:01.040 --> 00:27:06.880 And there are ways to group them 334 00:27:06.880 --> 00:27:11.080 So let's drag all these to select them 335 00:27:11.080 --> 00:27:12.480 And press 'C' 336 00:27:12.480 --> 00:27:17.000 And we get a window where we can add a comment 337 00:27:17.150 --> 00:27:21.560 Here, let's say 'Variable Practice' 338 00:27:24.430 --> 00:27:29.630 And here too, let's drag this part and press 'C' 339 00:27:29.630 --> 00:27:32.839 'If Statement Practice' 340 00:27:35.040 --> 00:27:38.040 Using this comment function 341 00:27:38.040 --> 00:27:40.240 You can group the nodes 342 00:27:40.240 --> 00:27:44.680 And when you move it around, dragging on this white area 343 00:27:44.680 --> 00:27:47.980 All the nodes in this area will move altogether 344 00:27:47.980 --> 00:27:51.080 So when you are implementing per method 345 00:27:51.080 --> 00:27:54.630 This is a good habit to have, to group them together like so 346 00:27:57.734 --> 00:28:01.184 Using Functions 347 00:28:02.479 --> 00:28:07.000 This time, let's try using some functions 348 00:28:07.479 --> 00:28:12.779 First, get intVar from the left with 'get' 349 00:28:13.179 --> 00:28:18.479 And intVar2 again with 'get' 350 00:28:18.479 --> 00:28:22.929 For intVar, drag it out like so 351 00:28:22.929 --> 00:28:25.490 And let's search for plus 352 00:28:26.040 --> 00:28:29.640 And we get 'add' like so 353 00:28:29.640 --> 00:28:31.920 Click on 'add' 354 00:28:31.920 --> 00:28:36.220 And this looks very similar to our if statement node 355 00:28:36.220 --> 00:28:38.439 But this part says plus 356 00:28:38.439 --> 00:28:43.640 And its Output Pin has a different color 357 00:28:43.640 --> 00:28:49.390 Let's drag this IntVar2 to connect to the second pin 358 00:28:49.390 --> 00:28:56.589 This obviously means that it will deliver the value, which is the sum 359 00:28:57.239 --> 00:29:00.789 And let's now print this result here 360 00:29:00.789 --> 00:29:06.400 Right click, add a Print String node 361 00:29:06.400 --> 00:29:17.009 And let's connect this printed value from In String 362 00:29:17.009 --> 00:29:20.920 To print that value 363 00:29:20.920 --> 00:29:25.070 And as of now, this node will not run 364 00:29:25.070 --> 00:29:25.870 Why not? 365 00:29:25.870 --> 00:29:29.040 It's because the Execution Pin is not connected yet 366 00:29:29.040 --> 00:29:36.330 So for now, let's disconnect this Variable and If Statement Practices 367 00:29:36.330 --> 00:29:38.680 Starting with Begin Play 368 00:29:39.680 --> 00:29:44.560 Press Alt and disconnect 369 00:29:44.560 --> 00:29:49.880 Let's instead connect it to this part 370 00:29:49.880 --> 00:29:51.980 At Blueprint 371 00:29:51.980 --> 00:29:58.199 We often have the line overlap with other nodes 372 00:29:58.199 --> 00:30:02.899 If that's fine with you, this won't do any harm 373 00:30:02.899 --> 00:30:06.599 But a helpful way of organizing this is 374 00:30:06.599 --> 00:30:10.949 To double click on this line 375 00:30:10.949 --> 00:30:14.000 Then it adds a pin like that 376 00:30:14.000 --> 00:30:20.839 And you can adjust the shape and location by dragging this part 377 00:30:20.839 --> 00:30:25.089 This way, the line does not overlap with the node over there 378 00:30:25.089 --> 00:30:28.539 We can organize the visuals for the nodes like so 379 00:30:29.439 --> 00:30:34.889 Compile and play at Blueprint level 380 00:30:34.889 --> 00:30:42.640 We see the value 300, which is the sum of 100 and 200 381 00:30:43.359 --> 00:30:45.679 Let's stop it 382 00:30:46.599 --> 00:30:51.299 And let's repeat this same action once more 383 00:30:51.299 --> 00:30:52.349 How do we do that? 384 00:30:52.349 --> 00:30:54.649 Copy everything 385 00:30:55.549 --> 00:30:57.540 And paste 386 00:30:59.760 --> 00:31:01.510 And connect these two 387 00:31:02.710 --> 00:31:04.460 And how do we do it yet again? 388 00:31:04.460 --> 00:31:06.839 Copy and paste again 389 00:31:06.839 --> 00:31:13.389 If we use copy and paste in order to repeat an action 390 00:31:13.389 --> 00:31:18.359 This screen will look incredibly complex 391 00:31:18.359 --> 00:31:22.599 That's when we start using a function 392 00:31:23.000 --> 00:31:26.400 So let's delete what we just added here 393 00:31:26.400 --> 00:31:31.700 Let me change this part using a function 394 00:31:32.479 --> 00:31:40.319 At My Blueprint, we have FUNCTIONS tab 395 00:31:40.319 --> 00:31:44.319 Click on the plus button here to create a function 396 00:31:44.319 --> 00:31:46.400 Let's click on the plus button 397 00:31:46.400 --> 00:31:49.500 Now we name this function 398 00:31:49.500 --> 00:31:52.680 Let's say 'Plus' 399 00:31:53.560 --> 00:31:55.210 When we have a function 400 00:31:55.210 --> 00:31:59.599 We get another window next to Event Graph 401 00:31:59.599 --> 00:32:04.599 This is a window designated for functions 402 00:32:05.479 --> 00:32:08.579 This part for Event Graph 403 00:32:08.579 --> 00:32:13.920 Where two values are added, copy this part 404 00:32:13.920 --> 00:32:17.920 And move to Plus tab and paste 405 00:32:17.920 --> 00:32:20.569 Then the nodes move like so 406 00:32:21.119 --> 00:32:24.269 So when this function Plus runs 407 00:32:24.269 --> 00:32:28.279 We are connecting this to say 'run this' 408 00:32:29.079 --> 00:32:32.169 Back to Event Graph 409 00:32:32.469 --> 00:32:38.769 Let's now delete this part 410 00:32:38.769 --> 00:32:43.069 Let's drag our Plus function here 411 00:32:43.069 --> 00:32:45.519 And we get a node 412 00:32:46.769 --> 00:32:51.160 And we can connect our Execution Pin 413 00:32:51.160 --> 00:32:57.640 Compile, play at Blueprint level 414 00:32:57.640 --> 00:33:01.719 And we get that same 300 415 00:33:03.079 --> 00:33:05.029 As it starts with Begin Play 416 00:33:05.029 --> 00:33:08.599 It is running our function, Plus 417 00:33:08.599 --> 00:33:11.499 And what happens there? It goes in here 418 00:33:11.499 --> 00:33:13.249 And it runs everything attached here 419 00:33:13.249 --> 00:33:14.249 And what is it? 420 00:33:14.249 --> 00:33:20.319 It is where we print the sum of the two values 421 00:33:21.920 --> 00:33:25.170 Let's say we are repeating this same action 422 00:33:25.170 --> 00:33:29.170 Then we can simply connect this Plus node again 423 00:33:29.170 --> 00:33:36.730 And this looks much more intuitive than before 424 00:33:38.400 --> 00:33:42.400 This is the basic structure of a function 425 00:33:43.199 --> 00:33:44.949 When we run a function 426 00:33:44.949 --> 00:33:52.920 It just does an action inside, of adding 100 and 200 427 00:33:52.920 --> 00:33:56.170 Meaning, the value in IntVar 428 00:33:56.170 --> 00:34:02.920 And the value in IntVar2, summing them and printing the result 429 00:34:03.079 --> 00:34:05.779 When we think of a calculator 430 00:34:05.779 --> 00:34:12.080 A calculator shows us the result of adding two numbers 431 00:34:12.080 --> 00:34:18.530 Same with this Plus function; it uses the two values, sums them up 432 00:34:18.530 --> 00:34:22.439 And prints the result 433 00:34:23.520 --> 00:34:27.220 And this is called a parameter 434 00:34:27.220 --> 00:34:32.760 Double click on this Plus function to open it 435 00:34:33.120 --> 00:34:35.620 And click on this Plus node 436 00:34:35.620 --> 00:34:41.600 Over at Details, we get Inputs 437 00:34:41.600 --> 00:34:45.100 And click on this plus button 438 00:34:45.100 --> 00:34:49.719 And this looks like the variable that we created 439 00:34:49.719 --> 00:34:55.280 Let's name it num1 440 00:34:55.520 --> 00:35:00.520 And click on where it says Boolean to change it into integer, and let's add another 441 00:35:00.520 --> 00:35:07.040 The name will be num2, an int type 442 00:35:07.239 --> 00:35:10.189 So here, for our Plus node 443 00:35:10.189 --> 00:35:13.939 It used to not have these pins called num1 and num2 444 00:35:13.939 --> 00:35:15.859 And now it does 445 00:35:16.159 --> 00:35:19.959 So let's delete this intVar and intVar2 446 00:35:19.959 --> 00:35:26.199 Let's instead use the values as inputs through variables 447 00:35:26.199 --> 00:35:32.439 To sum them up and then print the result, whenever Plus runs 448 00:35:32.439 --> 00:35:34.939 So over at Event Graph 449 00:35:34.939 --> 00:35:40.959 Now this Plus node has changed, where we can add something 450 00:35:41.120 --> 00:35:44.639 Here, drag in intVar 451 00:35:46.159 --> 00:35:52.919 And intVar2 to connect each here 452 00:35:52.919 --> 00:35:58.619 Now, with Begin Play, this Plus function runs 453 00:35:58.619 --> 00:36:03.330 And when it does, the values in intVar and intVar2 454 00:36:03.330 --> 00:36:09.780 They move into num1 and num2, respectively 455 00:36:09.780 --> 00:36:11.580 And then over at this Plus function 456 00:36:11.580 --> 00:36:13.379 num1 has 100 457 00:36:13.379 --> 00:36:19.959 And num2 has 200 458 00:36:20.560 --> 00:36:25.760 Let's copy and paste Plus 459 00:36:25.760 --> 00:36:27.800 And let's write the value directly here 460 00:36:27.800 --> 00:36:32.879 Let's say, we're adding 50 and 1000 461 00:36:32.959 --> 00:36:36.109 And connect this Execution Pin 462 00:36:36.459 --> 00:36:38.199 And now 463 00:36:38.199 --> 00:36:44.280 Here, this adds the values from intVar and intVar2 464 00:36:44.280 --> 00:36:51.030 And here, it adds 50 and 1000 465 00:36:51.030 --> 00:36:55.959 Compile, play at Blueprint level 466 00:36:55.959 --> 00:37:03.959 And we get 300 and 1050 as what is printed 467 00:37:05.509 --> 00:37:12.159 Now, for the sum of the two values 468 00:37:12.159 --> 00:37:17.479 We'd like to add yet another value to that, like 50 469 00:37:18.000 --> 00:37:23.200 Then, this Plus function will now provide 470 00:37:23.200 --> 00:37:29.040 A result value of that summation 471 00:37:29.399 --> 00:37:33.919 So let's modify this function 472 00:37:34.080 --> 00:37:39.840 To the left, at FUNCTIONS, double click on our function Plus to open 473 00:37:39.840 --> 00:37:42.690 And choose this Plus node 474 00:37:42.690 --> 00:37:47.270 And to the right, at Details, we now get Outputs 475 00:37:47.270 --> 00:37:50.639 Click on the plus button here 476 00:37:50.639 --> 00:37:55.479 And let's name it 'Result' 477 00:37:55.719 --> 00:37:58.769 Data type, int again 478 00:37:58.769 --> 00:38:02.719 Now we get this Return node 479 00:38:03.479 --> 00:38:06.579 And here, remove Print String 480 00:38:06.579 --> 00:38:12.080 And remove this node where we change int type to string 481 00:38:12.560 --> 00:38:17.639 Now, we will move right from Plus node to Return node 482 00:38:18.239 --> 00:38:25.879 For Result, let's add the result of summing num1 and num2 483 00:38:27.159 --> 00:38:30.509 And then back at Event Graph 484 00:38:30.509 --> 00:38:38.109 We now have a value called Result below the Plus button's Exec Pin 485 00:38:39.840 --> 00:38:42.240 Here it has 100 and here 200 486 00:38:42.240 --> 00:38:47.120 So now Result has the value 300 487 00:38:47.120 --> 00:38:51.870 Now, this value can connect to num1 488 00:38:51.870 --> 00:38:55.760 And for num2, let's say 1000 489 00:38:55.760 --> 00:38:59.510 So what will happen here? 490 00:38:59.510 --> 00:39:02.210 300 and 1000 will add up 491 00:39:02.210 --> 00:39:06.469 And for this result, we will get 1300 492 00:39:06.469 --> 00:39:10.879 Let's see if it works that way 493 00:39:10.879 --> 00:39:19.439 Right click and Print String 494 00:39:19.439 --> 00:39:26.760 And let's connect this result to In String to print 495 00:39:27.639 --> 00:39:30.360 Compile 496 00:39:30.719 --> 00:39:33.840 And play here 497 00:39:33.919 --> 00:39:38.520 We get this value 1300 printed here 498 00:39:38.760 --> 00:39:43.360 So we just worked on the three types of function 499 00:39:43.360 --> 00:39:50.119 First, we began simple; this function has no inputs or outputs 500 00:39:50.119 --> 00:39:53.840 Second, the function now had inputs 501 00:39:53.840 --> 00:40:01.320 And third, the function had both inputs and outputs 502 00:40:01.842 --> 00:40:05.242 Using Iterations 503 00:40:06.520 --> 00:40:11.199 Now let's try iterations 504 00:40:11.959 --> 00:40:18.520 On any empty surface, right click and search 'for loop' 505 00:40:18.520 --> 00:40:22.670 And we get 'for loop' at the bottom 506 00:40:22.670 --> 00:40:28.520 Select this, and we get this node 507 00:40:28.520 --> 00:40:35.479 For First Index, add 0, and Last Index, 10 508 00:40:35.479 --> 00:40:42.719 And right click to add a Print String node 509 00:40:43.479 --> 00:40:49.639 And for this Loop Body Exec Pin, connect Print String 510 00:40:50.040 --> 00:40:55.600 And using this Index, connect it to In String 511 00:40:56.600 --> 00:41:01.679 And add another Print String node 512 00:41:02.360 --> 00:41:08.060 And at Completed Exec Pin, connect another Print String 513 00:41:08.660 --> 00:41:17.199 And let's say 'Iteration complete' here 514 00:41:18.799 --> 00:41:24.849 So at the end of this Exec Pin, of the last Print String we used for our function practice 515 00:41:24.849 --> 00:41:29.600 Let's bring it in and connect to our For Loop 516 00:41:30.200 --> 00:41:35.100 And double click on this line to add a pin 517 00:41:35.100 --> 00:41:38.520 Just to tidy it up visually 518 00:41:48.199 --> 00:41:53.099 And let's compile and play at Blueprint level 519 00:41:53.099 --> 00:41:57.809 And what happens? 520 00:41:57.809 --> 00:42:02.840 It prints numbers from 0 to 10 521 00:42:02.840 --> 00:42:10.199 ANd at the end it says 'Iteration complete' 522 00:42:10.560 --> 00:42:16.000 So this node starts with the value 0 523 00:42:16.000 --> 00:42:19.150 And when Loop Body runs once 524 00:42:19.150 --> 00:42:24.439 This Index has the value 0 in it 525 00:42:24.750 --> 00:42:27.800 That's why it prints 0 526 00:42:27.800 --> 00:42:34.300 And it repeats until 0 becomes 10 527 00:42:34.300 --> 00:42:37.040 How? By incrementing by one 528 00:42:37.040 --> 00:42:43.719 So one incrementation from 0 becomes 1 529 00:42:44.080 --> 00:42:47.130 So Index now is 1, which prints 1 530 00:42:47.130 --> 00:42:50.330 When it becomes 2, it prints 2 531 00:42:50.330 --> 00:42:54.410 3, 4, 5, 6, 7, 8, 9 and up until 10 532 00:42:54.410 --> 00:42:58.010 And after printing 10, it stops 533 00:42:58.010 --> 00:43:00.660 And when it repeats until that final loop 534 00:43:00.660 --> 00:43:03.719 This 'Completed' runs 535 00:43:03.719 --> 00:43:08.109 And it prints what we added, 'Iteration complete' 536 00:43:08.809 --> 00:43:14.800 Let's apply this to create a times table 537 00:43:15.159 --> 00:43:21.239 For a times table, we need to multiply from 1 to 9 538 00:43:21.239 --> 00:43:24.550 2x1=2, 2x2=4, 2x3=6 and so on 539 00:43:27.840 --> 00:43:33.199 Let's remove this node that connects to In String for now 540 00:43:33.199 --> 00:43:38.049 So Index will change from 1 to 9, incrementing by one 541 00:43:38.049 --> 00:43:42.640 So let's search for 'x' for multiplication 542 00:43:42.640 --> 00:43:44.340 And we get 'Multiply' 543 00:43:44.340 --> 00:43:47.739 Let's create that Multiply node 544 00:43:48.289 --> 00:43:51.239 And let's add the value 5 here 545 00:43:51.789 --> 00:43:56.330 Then, it brings in that value 1, multiplies by 5 546 00:43:56.330 --> 00:43:57.930 And what does it get? 5 547 00:43:57.930 --> 00:44:01.199 So it prints that value 548 00:44:01.560 --> 00:44:03.960 And what about when this becomes from 1 to 2? 549 00:44:03.960 --> 00:44:08.000 The result is 10, and when this is 3, it is 15 550 00:44:08.000 --> 00:44:12.500 This will be the 5 times table 551 00:44:12.500 --> 00:44:19.600 Compile, play at Blueprint level 552 00:44:19.760 --> 00:44:23.460 Just like that, 5, 10, 15, 20 553 00:44:23.460 --> 00:44:29.000 We get the result for a 5 times table 554 00:44:30.000 --> 00:44:38.750 We have learned about variables, if statements, functions and iterations 555 00:44:38.750 --> 00:44:43.399 These are the basic grammars for Blueprint 556 00:44:43.399 --> 00:44:47.349 So I highly recommend that you take some time 557 00:44:47.349 --> 00:44:52.190 To try and go over these concepts multiple times on your own 558 00:44:53.160 --> 00:44:56.919 Let's summarize what we've learned in this chapter 559 00:44:56.919 --> 00:45:00.269 We learned about the structure and the flow of Blueprint 560 00:45:00.269 --> 00:45:09.179 And we learned about basic grammar of Blueprint: variable, function, if statement and iteration 561 00:45:11.019 --> 00:45:12.769 Blueprint Node: Structure and Flow Creating Blueprint Class What should its base be? 562 00:45:12.769 --> 00:45:14.519 Add Print String nodes, Compile to check if it can run Select node, Ctrl C and Ctrl V to copy and create more 563 00:45:14.519 --> 00:45:17.969 Node-related Terms Begin Play: Call once after run Event Tick: Call repeatedly after run Execute Pin: Order of nodes when run Input Pin: What contains the data input value 564 00:45:17.969 --> 00:45:21.419 Using Variables Creating Variables My Blueprint - VARIABLES - ( ) icon 565 00:45:21.419 --> 00:45:24.879 Data type Int Float Bool String Distinguish its value and setup to select 566 00:45:24.879 --> 00:45:31.929 Using If Statements Creating Branch Nodes When running a node, it branches to either True or False based on the value for the condition Search for 'Branch' or 'If' at Event Graph 567 00:45:31.929 --> 00:45:34.429 Using Functions Creating Functions Functions: command for the nodes with the same action My Blueprint - Functions - ( ) button 568 00:45:34.429 --> 00:45:36.729 Parameter Which receives two values, adds them and prints the result Details - Inputs - ( ) button 569 00:45:36.729 --> 00:45:38.979 Return Node Creating Return Value Details - Outputs - ( ) button, choose Integer data type 570 00:45:38.979 --> 00:45:45.870 Using Iterations Creating Iteration Node Search for 'for loop'