WEBVTT 1 00:00:23.950 --> 00:00:29.660 Hello, my name is Hyunjin Kim and I will be teaching the basics of Unreal Engine for implementing immersive contents 2 00:00:29.660 --> 00:00:35.510 In this lesson, we will learn about vectors and its addition 3 00:00:35.510 --> 00:00:38.410 How to receive user input 4 00:00:38.410 --> 00:00:44.029 and learn how to make the actor move with the received input 5 00:00:44.796 --> 00:00:48.196 Vector's Concept and Addition 6 00:00:48.779 --> 00:00:54.170 Let's learn about the vectors and addition of vectors 7 00:00:55.020 --> 00:01:00.199 First, we will talk about what a vector is 8 00:01:01.540 --> 00:01:07.620 A vector is something that has a direction and a size 9 00:01:08.860 --> 00:01:13.190 Let's say we have a car, like this 10 00:01:14.739 --> 00:01:18.589 The car moves towards the right 11 00:01:18.589 --> 00:01:25.389 Let's say it moved in 100km/h speed 12 00:01:26.339 --> 00:01:31.479 What I just described is the vector 13 00:01:32.379 --> 00:01:38.079 It has a size of 100km/h 14 00:01:38.079 --> 00:01:41.300 and direction of towards the right 15 00:01:41.300 --> 00:01:44.680 We call this speed 16 00:01:47.480 --> 00:01:52.679 So vector is anything that expresses direction and size together 17 00:01:53.660 --> 00:01:59.010 The weather forecast mentions both the wind direction and wind speed 18 00:01:59.010 --> 00:02:01.630 The southwest wind is blowing 19 00:02:02.580 --> 00:02:08.600 at a speed of 20km/h 20 00:02:10.050 --> 00:02:15.020 This also represents a vector 21 00:02:15.539 --> 00:02:19.589 We use the arrow 22 00:02:19.589 --> 00:02:25.740 to express vectors as symbols 23 00:02:26.139 --> 00:02:31.699 the length of this tail tells us the size 24 00:02:32.179 --> 00:02:41.619 and where the arrow points tells us the direction 25 00:02:42.380 --> 00:02:49.380 There is something that only has the size and not the direction 26 00:02:49.380 --> 00:02:52.379 That is called a scalar 27 00:02:54.100 --> 00:02:56.450 We used a car as an example 28 00:02:56.890 --> 00:03:06.619 This car drives in 100km/h 29 00:03:06.619 --> 00:03:07.369 to where? 30 00:03:07.369 --> 00:03:10.139 to the right 31 00:03:10.940 --> 00:03:13.890 The two of these combined 32 00:03:13.890 --> 00:03:16.460 is a vector 33 00:03:16.820 --> 00:03:20.720 But what do we call this value that only represents this number shown here? 34 00:03:20.720 --> 00:03:24.619 This is what we call scalar 35 00:03:25.779 --> 00:03:28.760 So y도 36 00:03:28.760 --> 00:03:34.210 speed and velocity in school 37 00:03:34.210 --> 00:03:38.419 Scalar represents the speed value 38 00:03:38.419 --> 00:03:45.460 while velocity has both speed and direction 39 00:03:47.460 --> 00:03:53.619 the addition of vector means the addition of all the powers 40 00:03:53.619 --> 00:03:58.339 A person throws a ball 41 00:03:58.339 --> 00:04:04.419 with a speed of 10m/s to the top right 42 00:04:04.419 --> 00:04:06.369 This itself is a vector 43 00:04:06.369 --> 00:04:10.059 because it has speed and direction 44 00:04:10.220 --> 00:04:16.700 Would this ball reach the sky? 45 00:04:16.700 --> 00:04:19.650 No, it moves parabolically like this 46 00:04:19.650 --> 00:04:21.000 Why is that? 47 00:04:21.000 --> 00:04:25.739 Because the ball floats up 48 00:04:25.739 --> 00:04:30.389 with the force of throwing 49 00:04:30.389 --> 00:04:32.589 but the power of gravity is added 50 00:04:32.589 --> 00:04:36.179 and it keeps going down 51 00:04:36.179 --> 00:04:39.420 in a parabolic move 52 00:04:39.940 --> 00:04:44.659 these kind of calculations can be done with the vector addition 53 00:04:46.579 --> 00:04:51.469 The wind could be blowing this way too 54 00:04:53.339 --> 00:04:55.839 so this curve 55 00:04:57.089 --> 00:05:01.380 could fall steeply more and more 56 00:05:01.830 --> 00:05:09.280 In this case the throw-power, gravity, and wind power 57 00:05:09.280 --> 00:05:12.420 are all added for this effect 58 00:05:13.420 --> 00:05:22.019 I will illustrate how the sum of vectors works 59 00:05:23.100 --> 00:05:25.720 We have a graph like this 60 00:05:27.420 --> 00:05:30.990 We will call this x and this y 61 00:05:32.500 --> 00:05:34.600 I will draw a vector on this plane 62 00:05:34.600 --> 00:05:37.990 a vector starting from the origin 63 00:05:39.779 --> 00:05:44.660 and another vector from the origin going this way 64 00:05:45.660 --> 00:05:49.809 The red vector will be v1 65 00:05:51.500 --> 00:05:54.619 and the blue one will be v2 66 00:05:56.980 --> 00:06:00.839 I will illustrate how these two vectors add up 67 00:06:01.739 --> 00:06:06.250 First, duplicate this red vector 68 00:06:07.619 --> 00:06:11.049 and place it at the end of the blue one 69 00:06:13.499 --> 00:06:20.819 Again, copy the blue vector and 70 00:06:22.980 --> 00:06:26.359 place it on top of the red 71 00:06:27.659 --> 00:06:34.120 Then, the blue and the red will meet at the end 72 00:06:35.420 --> 00:06:37.719 So if you draw a vector 73 00:06:40.619 --> 00:06:46.470 from the origin to the meeting point 74 00:06:47.620 --> 00:06:54.630 this will be the addition of vector v1 and v2 75 00:06:56.500 --> 00:07:00.800 If you memorize this drawing 76 00:07:00.800 --> 00:07:09.059 You will be able to recognize when two vectors are added 77 00:07:09.100 --> 00:07:14.420 So what we are trying to do with this addition 78 00:07:14.820 --> 00:07:23.999 is by using the keyboard's W, A, S, and D key 79 00:07:23.999 --> 00:07:27.209 we will move an actor 80 00:07:29.260 --> 00:07:32.660 We will make it move right with the D key 81 00:07:32.660 --> 00:07:35.739 move left with the A key 82 00:07:35.739 --> 00:07:38.739 move forward with the W key 83 00:07:38.739 --> 00:07:41.659 and move back with the S key 84 00:07:43.459 --> 00:07:50.019 But what should happen when W and D is pressed together? 85 00:07:51.019 --> 00:07:53.269 It should move diagonally 86 00:07:53.919 --> 00:07:57.540 So the direction of movement is based on 87 00:07:57.540 --> 00:08:01.840 the addition of the W and D key's vectors 88 00:08:01.840 --> 00:08:06.220 when the keys are pressed 89 00:08:07.420 --> 00:08:12.500 So basically the addition of vector going forward and to the right 90 00:08:12.500 --> 00:08:15.900 So I've said that 91 00:08:17.000 --> 00:08:20.220 we would connect these meeting point 92 00:08:20.260 --> 00:08:24.010 Then when the two vectors are added 93 00:08:24.010 --> 00:08:28.799 we get a diagonal facing right 94 00:08:30.459 --> 00:08:34.810 So we will move the actor in this way 95 00:08:36.538 --> 00:08:39.888 Receiving User Input 96 00:08:41.739 --> 00:08:47.790 Let's learn about receiving the user's input 97 00:08:48.940 --> 00:08:52.460 I will make a new level 98 00:08:52.460 --> 00:09:01.059 Click File - NewLevel - Basic - Create 99 00:09:02.820 --> 00:09:06.170 click the save button on the top left 100 00:09:07.220 --> 00:09:10.500 I will make a folder under the Contents folder 101 00:09:10.500 --> 00:09:13.990 Right click and New folder 102 00:09:15.140 --> 00:09:20.519 Let's name it Actual Practice 103 00:09:22.140 --> 00:09:27.490 So double click Actual Practice 104 00:09:28.340 --> 00:09:33.620 I will name this level the Actual level 105 00:09:34.720 --> 00:09:35.969 Save 106 00:09:38.099 --> 00:09:43.539 Now select the Actual Practice folder in the Contents browser 107 00:09:43.539 --> 00:09:46.039 I will make a blueprint class 108 00:09:46.589 --> 00:09:49.179 Right click 109 00:09:49.179 --> 00:09:50.879 Blueprint Class 110 00:09:51.929 --> 00:09:56.409 and we will inherit a Pawn 111 00:09:57.219 --> 00:10:03.390 Pawn is a class created by inheriting actor 112 00:10:04.490 --> 00:10:07.000 But this Pawn 113 00:10:07.000 --> 00:10:15.500 is a Blueprint class that is ready to receive user input 114 00:10:16.580 --> 00:10:19.980 and because we have to receive user input now 115 00:10:19.980 --> 00:10:26.029 we will inherit this class called Pawn and make the Blueprint 116 00:10:27.299 --> 00:10:28.499 Select it 117 00:10:29.399 --> 00:10:33.579 and name it BP_Player 118 00:10:35.059 --> 00:10:37.909 Double click to open 119 00:10:37.909 --> 00:10:41.340 When we get a separate window like this 120 00:10:41.340 --> 00:10:45.100 assemble it as a tab at the top 121 00:10:47.020 --> 00:10:49.770 There is the Component window on the left 122 00:10:49.770 --> 00:10:52.970 This is a space that shows 123 00:10:52.970 --> 00:10:57.739 what components this actor and pawn consist of 124 00:10:58.780 --> 00:11:02.630 Actors are made of components 125 00:11:02.630 --> 00:11:07.900 So let's add a component here that represents appearance 126 00:11:07.900 --> 00:11:10.550 Click the Add button 127 00:11:10.550 --> 00:11:13.650 Write Static on the search bar 128 00:11:13.650 --> 00:11:17.659 and at the end there is the Static Mesh 129 00:11:17.659 --> 00:11:22.940 Click this component to add 130 00:11:23.500 --> 00:11:27.850 Now you see we have a component added 131 00:11:28.700 --> 00:11:30.350 Select this component 132 00:11:30.350 --> 00:11:33.469 If you look at the detail window on the right 133 00:11:34.269 --> 00:11:38.269 There is Static Mesh 134 00:11:38.269 --> 00:11:43.750 If you press the clickable button here 135 00:11:44.700 --> 00:11:49.650 Here are all the appearance meshes that can be set 136 00:11:50.450 --> 00:11:55.900 Now search 'Cube' at the search bar 137 00:11:56.460 --> 00:12:01.210 You will see 2 cubes 138 00:12:01.210 --> 00:12:03.700 When you hover over 139 00:12:03.700 --> 00:12:06.350 select the one with 140 00:12:06.350 --> 00:12:11.659 'Approx size 100x100x100' in the details 141 00:12:13.219 --> 00:12:16.919 If you don't see such cube 142 00:12:18.069 --> 00:12:23.700 click the gear button to the right of the search bar 143 00:12:23.700 --> 00:12:27.550 Check the menu called 'Show Engine Content' 144 00:12:27.550 --> 00:12:29.519 Then you will see the list 145 00:12:30.619 --> 00:12:33.319 Now search Cube again 146 00:12:34.369 --> 00:12:40.539 and choose 'Approx size 100x100x100' 147 00:12:41.289 --> 00:12:46.059 Then you can see what the actor looks like 148 00:12:46.059 --> 00:12:53.399 on a window called Viewport 149 00:12:53.780 --> 00:12:56.180 Let's try Compile 150 00:12:56.180 --> 00:13:02.580 You will see a list called Materials 151 00:13:02.739 --> 00:13:04.589 This is a space where 152 00:13:04.589 --> 00:13:10.970 you can add color or designs to the exterior 153 00:13:10.970 --> 00:13:16.190 Click the drop down here 154 00:13:16.190 --> 00:13:20.380 and you will see all the possible settings 155 00:13:20.900 --> 00:13:26.449 Choose the one you want 156 00:13:27.099 --> 00:13:30.599 I will choose Arrow Material 157 00:13:30.599 --> 00:13:33.360 You may choose anything to your liking 158 00:13:34.739 --> 00:13:39.819 Let's shift this to the right 159 00:13:40.619 --> 00:13:43.469 To do a movement 160 00:13:44.019 --> 00:13:53.350 You can implement it through a blueprint node using the Event Graph tab at the top 161 00:13:53.580 --> 00:14:01.099 Right click and search 'Get Actor Location' 162 00:14:01.099 --> 00:14:02.949 and a list pops up 163 00:14:02.949 --> 00:14:06.910 Click it to add a node 164 00:14:07.460 --> 00:14:15.260 This node tells us the Actor's location 165 00:14:15.539 --> 00:14:26.260 Now click right again to add a node called 'Get Actor Right Vector' 166 00:14:28.619 --> 00:14:29.909 This 167 00:14:31.979 --> 00:14:37.539 The direction this actor is facing is in red 168 00:14:37.539 --> 00:14:39.889 The upward direction is this blue 169 00:14:39.889 --> 00:14:43.500 and the right direction is green 170 00:14:43.500 --> 00:14:51.170 So the direction indicated by this green color is a node that indicates the vector 171 00:14:52.320 --> 00:14:58.739 It tells you what direction value the right side of this actor is 172 00:14:58.900 --> 00:15:02.750 Let's drag this 173 00:15:02.750 --> 00:15:07.219 and if you search X, then you will find Multipy 174 00:15:07.219 --> 00:15:09.739 add this node 175 00:15:10.859 --> 00:15:15.459 On the Variables under My Blueprint on the left side 176 00:15:15.459 --> 00:15:18.180 Click the plus button to increase a variable 177 00:15:18.180 --> 00:15:19.530 Plus 178 00:15:20.030 --> 00:15:23.240 The variable's name will be Speed 179 00:15:24.580 --> 00:15:29.870 Then drop down this data type and make it float 180 00:15:32.059 --> 00:15:37.749 I will click the Compile button and set 181 00:15:38.299 --> 00:15:41.460 Speed's default to 400 182 00:15:42.580 --> 00:15:47.430 Then drag the speed variable 183 00:15:47.430 --> 00:15:51.059 to Get Speed 184 00:15:51.140 --> 00:15:57.219 I'm going to multiply that value by this vector on the right 185 00:15:57.419 --> 00:16:06.140 Then drag the right vector multiplied by the Speed ​​value again 186 00:16:06.140 --> 00:16:10.659 Add another multiply node 187 00:16:11.539 --> 00:16:15.460 I will move this node to the top for a second 188 00:16:16.780 --> 00:16:24.739 Now drag out the pin on Delta Seconds in the Event Tick 189 00:16:24.739 --> 00:16:31.219 and connect it to the second multiplier input pin 190 00:16:34.040 --> 00:16:41.859 Multiply these two values ​​and drag again 191 00:16:41.859 --> 00:16:46.909 this time adding an Add Node 192 00:16:46.909 --> 00:16:48.460 and then add this Get Actor Location 193 00:16:48.460 --> 00:16:53.770 which is the current location 194 00:16:55.140 --> 00:16:58.590 and right click on a blank to search 195 00:16:58.590 --> 00:17:04.780 Set Actor Location and click that 196 00:17:04.780 --> 00:17:07.680 it gives you this node 197 00:17:07.680 --> 00:17:11.180 this has an Execution Pin 198 00:17:12.180 --> 00:17:15.880 So connect the execution pin from the Even tick 199 00:17:15.880 --> 00:17:20.380 to the Set Actor Location node 200 00:17:20.739 --> 00:17:26.289 In the Input Pin called New Location 201 00:17:26.289 --> 00:17:29.660 connect the final result 202 00:17:29.660 --> 00:17:33.110 calculated so far 203 00:17:33.110 --> 00:17:37.459 Now we click Compile 204 00:17:37.459 --> 00:17:40.859 Now move to the Actual level 205 00:17:40.859 --> 00:17:45.300 drag the BP_Player we made earlier 206 00:17:45.300 --> 00:17:48.540 and place it on the View Port 207 00:17:49.300 --> 00:17:53.699 For the location of the transform of the detail 208 00:17:53.699 --> 00:17:58.339 we will set it to 300, 0, 0 209 00:17:58.339 --> 00:18:01.039 300 and 0 and 0 210 00:18:01.039 --> 00:18:03.739 now if you play it 211 00:18:03.739 --> 00:18:09.459 you can see a cube moving to the right 212 00:18:10.300 --> 00:18:17.660 We've made the actor move 213 00:18:18.020 --> 00:18:23.180 So the formula to make the actor move is 214 00:18:23.180 --> 00:18:31.060 P = P0 + VT 215 00:18:31.140 --> 00:18:36.939 P is the final location value 216 00:18:36.939 --> 00:18:41.739 P0 is my current location 217 00:18:41.739 --> 00:18:45.589 V means velocity 218 00:18:45.589 --> 00:18:48.900 T is for time 219 00:18:49.979 --> 00:18:52.979 So the result value is P 220 00:18:54.279 --> 00:18:58.519 Get Actor Location is P0 221 00:18:59.619 --> 00:19:06.020 Get Actor Right Vector and the speed 222 00:19:06.020 --> 00:19:08.520 equals V 223 00:19:08.520 --> 00:19:13.819 and the delta time is T 224 00:19:13.819 --> 00:19:17.799 So I multiplied V and T 225 00:19:18.749 --> 00:19:20.449 and to there 226 00:19:20.449 --> 00:19:24.399 I added P0 to get the final P 227 00:19:24.399 --> 00:19:28.249 which tells what the actor should do 228 00:19:29.540 --> 00:19:34.140 When you want to move something using unreal 229 00:19:34.140 --> 00:19:37.680 you will be using this formula the most 230 00:19:39.660 --> 00:19:43.130 Let me make some distinctions with Comments 231 00:19:45.939 --> 00:19:53.109 Select the product node of Get Actor Right, speed and delta time 232 00:19:53.109 --> 00:19:55.359 and press C 233 00:19:55.359 --> 00:19:58.569 This means VT 234 00:20:00.099 --> 00:20:04.199 then select the Get Actor Location 235 00:20:04.199 --> 00:20:09.819 separately, press C and it means P0 236 00:20:11.979 --> 00:20:18.200 Select the sum node of VT and P0 and press C 237 00:20:20.020 --> 00:20:23.170 The value here will be P 238 00:20:23.870 --> 00:20:28.300 So the result value tells the actor to set a new location 239 00:20:30.619 --> 00:20:34.969 When you want to leave a comment for a node 240 00:20:34.969 --> 00:20:37.669 you can use this Comment function 241 00:20:37.669 --> 00:20:40.300 but if you hover over the node 242 00:20:40.300 --> 00:20:43.500 there is a icon that looks like ... 243 00:20:43.500 --> 00:20:48.230 If you click that, you can write descriptions of this node 244 00:20:49.180 --> 00:20:54.180 P means result value 245 00:20:55.540 --> 00:21:01.010 So use these features wisely to keep the nodes organized 246 00:21:02.819 --> 00:21:06.919 As of now, the actor automatically moves to the right 247 00:21:06.919 --> 00:21:12.549 Now let’s move it by receiving user and keyboard input 248 00:21:13.699 --> 00:21:17.899 I will go to Actual level to make another file 249 00:21:18.499 --> 00:21:20.900 Right click 250 00:21:20.900 --> 00:21:27.380 Under Input, you will find Input Mapping Context 251 00:21:27.380 --> 00:21:29.980 add this file 252 00:21:29.980 --> 00:21:37.160 we will name it input mapping 253 00:21:38.410 --> 00:21:41.710 we will add another file now 254 00:21:41.710 --> 00:21:43.900 right click 255 00:21:43.900 --> 00:21:50.339 not choose Input Action under the Input category 256 00:21:50.339 --> 00:21:56.219 I will name it IA_AD 257 00:21:56.219 --> 00:22:00.819 double click IA_AD to open it 258 00:22:01.619 --> 00:22:07.119 click the drop down where the value type is digital 259 00:22:07.119 --> 00:22:12.099 and change it to Axis1D float 260 00:22:12.099 --> 00:22:15.239 now click the save button 261 00:22:15.979 --> 00:22:21.710 Comeback to the Actual level and open the Input Mapping file 262 00:22:22.260 --> 00:22:27.109 Click the plus button on Mappings 263 00:22:27.859 --> 00:22:31.959 then if you click 'none' 264 00:22:31.959 --> 00:22:35.219 there are files regarding the input action 265 00:22:35.219 --> 00:22:37.619 We only made one 266 00:22:37.619 --> 00:22:42.540 so we can see this IA_AD 267 00:22:42.540 --> 00:22:45.290 Select this file 268 00:22:46.290 --> 00:22:51.140 When you click the button to expand 269 00:22:51.140 --> 00:22:56.459 you can see which keyboards you can set 270 00:22:56.459 --> 00:23:00.459 We will first register the A key 271 00:23:00.459 --> 00:23:03.009 If you click this keyboard looking button 272 00:23:03.009 --> 00:23:06.180 it turns yellow like this 273 00:23:06.180 --> 00:23:11.230 If you press the actual keyboard now, it will be registered 274 00:23:11.680 --> 00:23:14.249 I will press A 275 00:23:15.099 --> 00:23:19.459 Now click the expand button again 276 00:23:20.339 --> 00:23:23.439 You can see Modifiers here 277 00:23:23.439 --> 00:23:26.500 click the plus button again here 278 00:23:27.939 --> 00:23:31.429 click where it says 'none' 279 00:23:32.859 --> 00:23:36.900 and select Negate 280 00:23:37.140 --> 00:23:41.840 We've pressed the plus button on IA_AD, 281 00:23:41.840 --> 00:23:44.060 I will do that again 282 00:23:44.060 --> 00:23:48.410 you will see the keyboard again 283 00:23:48.410 --> 00:23:52.669 Click the keyboard icon and we will press D now 284 00:23:54.780 --> 00:23:57.980 What happens now 285 00:23:57.980 --> 00:24:03.420 When you press the A key, you will get a value of -1 286 00:24:03.420 --> 00:24:08.840 When you press D, you will get a value of 1 287 00:24:10.380 --> 00:24:12.980 Insert Negate on the a value 288 00:24:12.980 --> 00:24:14.280 If you don't do this 289 00:24:14.280 --> 00:24:17.380 You will get a value of 1 when A key is pressed 290 00:24:17.380 --> 00:24:19.280 The Negate here 291 00:24:19.280 --> 00:24:24.780 sets i so that you get the opposite value 292 00:24:25.819 --> 00:24:28.409 Now we go back to BP Player 293 00:24:30.180 --> 00:24:33.480 We will make the initial settings on this Begin Play node 294 00:24:33.480 --> 00:24:39.700 so that it can receive and process the input 295 00:24:41.260 --> 00:24:45.590 Right click on a blank 296 00:24:46.540 --> 00:24:50.619 and search Enhanced 297 00:24:52.180 --> 00:24:57.280 Under Controller and Local Player Sub-system 298 00:24:57.280 --> 00:25:02.579 You will see Get Enhanced Input Local Player Sub System 299 00:25:02.579 --> 00:25:08.579 Select that to add a node 300 00:25:08.579 --> 00:25:12.029 Right click on a blank again 301 00:25:12.029 --> 00:25:18.019 Search Get Player Control 302 00:25:18.969 --> 00:25:22.579 There is a Get Player Control node 303 00:25:22.579 --> 00:25:25.610 Click it to add the node 304 00:25:27.780 --> 00:25:35.030 So we connect the value from Get Player Control 305 00:25:35.030 --> 00:25:38.830 to Enhanced Input Local Player Sub System 306 00:25:40.780 --> 00:25:46.859 And for the value of Enhanced Input Local Player Sub System 307 00:25:46.859 --> 00:25:52.309 If you search Add Mapping here 308 00:25:52.309 --> 00:25:54.939 There will be Add Mapping Context 309 00:25:54.939 --> 00:25:57.789 Add this node 310 00:26:01.739 --> 00:26:08.260 and connect it to the Begin Play node's execution pin 311 00:26:08.260 --> 00:26:14.200 This is the input's initial setting 312 00:26:15.939 --> 00:26:18.539 If you look at Add Mapping Context node 313 00:26:18.539 --> 00:26:23.249 You will find Mapping Context 314 00:26:23.249 --> 00:26:26.299 If you click the Select Asset button 315 00:26:26.299 --> 00:26:30.020 You will see the input mapping that we've made 316 00:26:30.060 --> 00:26:33.910 Select that file 317 00:26:34.360 --> 00:26:37.380 We've added settings for 318 00:26:37.380 --> 00:26:42.280 the A and D key in this input mapping 319 00:26:42.980 --> 00:26:47.849 Now we are saying that we will be using those input 320 00:26:49.540 --> 00:26:54.040 Let's move to the bottom to actually try receiving this input 321 00:26:54.040 --> 00:26:56.040 right click 322 00:26:56.040 --> 00:26:58.219 and the action we've made 323 00:26:58.219 --> 00:27:01.469 which is the IA_AD 324 00:27:01.469 --> 00:27:08.060 So if you search IA_AD we see these two things 325 00:27:08.060 --> 00:27:15.010 We will add the bottom one, Enhanced Action Value 326 00:27:15.979 --> 00:27:18.829 What the value of this is 327 00:27:18.829 --> 00:27:23.479 The value will be -1 when you press A 328 00:27:23.479 --> 00:27:27.729 and it will be 1 when you press D 329 00:27:27.729 --> 00:27:30.629 If you don't press any 330 00:27:30.629 --> 00:27:35.450 this node will give you 0 as the value 331 00:27:37.100 --> 00:27:42.639 We can use this node by creating IA_AD 332 00:27:45.889 --> 00:27:49.439 So let's put it to the test 333 00:27:49.439 --> 00:27:52.639 Right click and search Print String 334 00:27:54.180 --> 00:28:00.869 Take the return value of IA_AD and drag it to the In String 335 00:28:02.219 --> 00:28:07.319 and we need to connect it to the execution pin 336 00:28:07.319 --> 00:28:10.660 Connect the execution pin on the Event tick 337 00:28:10.660 --> 00:28:14.579 to the Print String 338 00:28:15.540 --> 00:28:20.539 Press Compile and we will move on to Actual Level 339 00:28:21.339 --> 00:28:26.189 If you press the play button and the A key 340 00:28:26.189 --> 00:28:27.489 only the screen moves 341 00:28:27.489 --> 00:28:31.180 and the output value on the left is only 0 342 00:28:31.180 --> 00:28:36.280 This is because our player, Pawn 343 00:28:36.280 --> 00:28:38.739 is not receiving the inputs 344 00:28:38.739 --> 00:28:43.739 Right now, the default input settings are being forced on the Pawn 345 00:28:43.739 --> 00:28:48.540 So we need to configure here once more 346 00:28:48.540 --> 00:28:50.690 so the Pawn receives the new input 347 00:28:51.090 --> 00:28:53.340 Select the BP Player 348 00:28:53.340 --> 00:28:57.609 Go to Details and under Pawn 349 00:28:58.159 --> 00:29:02.000 there is Auto Possess Player 350 00:29:02.900 --> 00:29:05.050 It is set to Disabled 351 00:29:05.050 --> 00:29:09.739 choose Player 0 from the drop down menu 352 00:29:10.180 --> 00:29:12.330 if you play now 353 00:29:13.530 --> 00:29:16.380 What happens when we press the A key? 354 00:29:16.380 --> 00:29:20.080 we see the value as -1 355 00:29:20.080 --> 00:29:21.980 and 0 when you are not pressing 356 00:29:21.980 --> 00:29:24.579 and 1 when you press D key 357 00:29:24.579 --> 00:29:26.679 with these values 358 00:29:26.679 --> 00:29:35.559 we can make movements such as going to the left or right, or staying still 359 00:29:36.459 --> 00:29:38.119 We will stop 360 00:29:39.619 --> 00:29:43.700 Come back to the event graph of BP Player 361 00:29:45.180 --> 00:29:51.319 We will make direction of movement using Get IA_AD 362 00:29:51.819 --> 00:29:55.319 To have it simply move to the right 363 00:29:55.319 --> 00:29:59.420 This right here is the setting for that 364 00:29:59.420 --> 00:30:05.870 This says move to the right with a certain speed 365 00:30:05.870 --> 00:30:09.519 We will change this part a bit 366 00:30:10.619 --> 00:30:15.719 Erase this yellow connecting line from Get actor right vector 367 00:30:15.719 --> 00:30:17.989 Press Alt and click 368 00:30:18.939 --> 00:30:22.339 Erase some of the prints here and there 369 00:30:22.339 --> 00:30:25.480 We will only leave this Get IA_AD 370 00:30:27.579 --> 00:30:31.139 I will multiply these two vectors 371 00:30:36.989 --> 00:30:40.900 and insert the product here 372 00:30:40.900 --> 00:30:42.600 It would've been a right vector 373 00:30:42.600 --> 00:30:44.950 but this time the right vector will be 374 00:30:44.950 --> 00:30:50.350 multiplied by a value of -1, 0, or 1 375 00:30:51.500 --> 00:30:54.300 Let's see what happens 376 00:30:55.500 --> 00:30:57.619 Compile 377 00:30:57.660 --> 00:31:01.210 Let's go to Actual level to press play 378 00:31:01.210 --> 00:31:04.879 Press the A, D key to see if it moves 379 00:31:05.579 --> 00:31:06.879 It does not 380 00:31:07.929 --> 00:31:11.079 Go back to the blueprint 381 00:31:11.079 --> 00:31:14.579 this Select Location Execution pin was not connected 382 00:31:14.579 --> 00:31:18.029 Only the data nodes were connected 383 00:31:18.029 --> 00:31:22.359 What actually executes it was not connected so 384 00:31:24.459 --> 00:31:29.159 We will connect Event pin's Execution pin to the Select Location 385 00:31:29.909 --> 00:31:32.459 Compile again 386 00:31:32.459 --> 00:31:34.759 Go back to Actual level 387 00:31:34.759 --> 00:31:36.359 Press play 388 00:31:36.359 --> 00:31:39.059 Now when you press A it moves like this 389 00:31:39.059 --> 00:31:40.539 and when you press D 390 00:31:41.639 --> 00:31:43.879 you can see how it moves 391 00:31:45.160 --> 00:31:49.689 Now let's move back and forth using W and S key 392 00:31:51.099 --> 00:31:52.999 We need to make another action 393 00:31:52.999 --> 00:31:59.780 Right click and add the Input action 394 00:31:59.780 --> 00:32:04.589 I will name it IA_WS 395 00:32:05.339 --> 00:32:09.389 Double click IA_WS 396 00:32:09.939 --> 00:32:15.209 Set the value type to Axis1d from the drop down 397 00:32:16.459 --> 00:32:19.409 Now go to input mapping 398 00:32:19.509 --> 00:32:23.689 Click the plus button 399 00:32:25.099 --> 00:32:28.830 From the drop down menu where 'none' is 400 00:32:30.859 --> 00:32:34.510 select IA_WS 401 00:32:35.660 --> 00:32:37.060 Expand it 402 00:32:37.060 --> 00:32:41.219 Click the keyboard icon and set the W key 403 00:32:41.819 --> 00:32:46.060 Now we add another one in IA_WS 404 00:32:46.060 --> 00:32:50.759 Click the plus buton on the right of IA_WS 405 00:32:51.459 --> 00:32:55.939 click the keyboard icon and click S 406 00:32:56.339 --> 00:33:01.739 Now when you press W, we will get a value of 1 407 00:33:01.739 --> 00:33:05.729 and when S is pressed, you get a value of -1 408 00:33:06.579 --> 00:33:09.429 Keep the W as is 409 00:33:09.429 --> 00:33:13.180 on the S's modifiers 410 00:33:13.180 --> 00:33:16.000 add negate 411 00:33:17.579 --> 00:33:21.079 Press the plus button on Modifiers 412 00:33:21.079 --> 00:33:25.630 expand on none 413 00:33:25.630 --> 00:33:28.660 and select negate here 414 00:33:29.260 --> 00:33:31.410 save now 415 00:33:31.910 --> 00:33:35.790 move back to BP Player 416 00:33:36.699 --> 00:33:40.269 and we will expand this part 417 00:33:47.300 --> 00:33:49.950 right click on a blank space 418 00:33:49.950 --> 00:33:53.700 and search Get Actor Forward 419 00:33:53.700 --> 00:33:55.939 There is Get Actor Forward Vector 420 00:33:55.939 --> 00:33:58.230 Add this node 421 00:33:59.619 --> 00:34:04.140 Right click again 422 00:34:04.140 --> 00:34:08.090 search IA_WS 423 00:34:08.090 --> 00:34:12.930 and we will use the enhanced action value on the bottom 424 00:34:14.780 --> 00:34:18.730 we will multiply it here 425 00:34:19.280 --> 00:34:22.769 Drag the returned pin in get actor forward 426 00:34:23.119 --> 00:34:30.079 and add a multipy node 427 00:34:30.979 --> 00:34:35.570 multiply the Get IA_WS value 428 00:34:37.699 --> 00:34:41.919 and then we will add the value of these two 429 00:34:43.500 --> 00:34:50.279 For now, disconnect the product of the right vector and IA_AD from connecting here 430 00:34:52.139 --> 00:34:56.129 drag it out and then 431 00:34:57.419 --> 00:34:59.619 add an add node 432 00:34:59.819 --> 00:35:06.509 then add the product of Forward vector and IA_WS 433 00:35:08.419 --> 00:35:13.689 To this value, multiply the speed 434 00:35:17.020 --> 00:35:21.320 Compile, then go to actual level 435 00:35:21.320 --> 00:35:25.820 When you press play, now you can see it moves forwards and backwards 436 00:35:25.820 --> 00:35:29.889 left and right 437 00:35:32.780 --> 00:35:35.330 The camera is too close right now 438 00:35:35.330 --> 00:35:41.780 so set the camera way back here 439 00:35:41.780 --> 00:35:46.430 and we'll watch how the player moves 440 00:35:47.699 --> 00:35:51.849 In the search section of place actors 441 00:35:51.849 --> 00:35:56.260 search camera, and you will see a camera actor 442 00:35:56.260 --> 00:36:01.019 Drag this actor and place it here 443 00:36:02.340 --> 00:36:07.190 The camera view screen appears at the bottom 444 00:36:07.190 --> 00:36:11.780 but we can't look at the player 445 00:36:11.780 --> 00:36:14.530 So right click here 446 00:36:14.530 --> 00:36:19.869 and we can control the viewport camera like this using WASD keys 447 00:36:21.459 --> 00:36:26.659 so select the view like this 448 00:36:26.659 --> 00:36:30.559 We can set the camera to show 449 00:36:30.559 --> 00:36:34.430 what we are seeing in the screen below 450 00:36:35.899 --> 00:36:40.599 Go to outliner and see if camera actor is selected 451 00:36:40.599 --> 00:36:43.679 click right on camera actor 452 00:36:44.379 --> 00:36:50.679 and choose snap object to view 453 00:36:50.679 --> 00:36:58.829 then the camera switches to the position of the viewport 454 00:36:58.829 --> 00:37:04.679 What we are seeing on the bottom right corner 455 00:37:04.679 --> 00:37:07.020 we can see from the camera 456 00:37:07.820 --> 00:37:10.470 Now use the mouse to rotate 457 00:37:10.470 --> 00:37:15.979 You can see the camera has moved here 458 00:37:17.260 --> 00:37:21.559 to make the camera actor move 459 00:37:22.400 --> 00:37:28.950 There is auto player activation under the details window 460 00:37:29.100 --> 00:37:31.900 this is disabled right now 461 00:37:31.900 --> 00:37:35.769 choose player 0 from the drop down menu 462 00:37:36.419 --> 00:37:38.969 If you play it now 463 00:37:38.969 --> 00:37:43.829 We can now watch the players from a distance 464 00:37:44.229 --> 00:37:48.270 If you move the WASD key in this state 465 00:37:48.620 --> 00:37:54.659 We can not watch the player 466 00:37:54.659 --> 00:37:58.300 from above 467 00:38:01.060 --> 00:38:04.810 The product of 468 00:38:04.810 --> 00:38:09.210 the Get actor right vector we made here 469 00:38:09.210 --> 00:38:12.150 and the values that come in through input 470 00:38:12.150 --> 00:38:16.799 is the final direction the player moves in 471 00:38:18.979 --> 00:38:22.780 Let's organize the comments 472 00:38:32.540 --> 00:38:35.740 Select this node 473 00:38:35.740 --> 00:38:39.060 press c to make a comment inside 474 00:38:39.060 --> 00:38:44.379 I will write that this is the 475 00:38:45.629 --> 00:38:49.930 final direction 476 00:38:49.930 --> 00:38:52.480 This is hard to distinguish 477 00:38:52.480 --> 00:38:57.179 If you select the space above the comment 478 00:38:57.179 --> 00:39:03.020 There is Comment Color under details 479 00:39:03.020 --> 00:39:04.970 Click this 480 00:39:04.970 --> 00:39:08.830 and you can change the color of the comment 481 00:39:11.829 --> 00:39:16.029 Let me explain this further 482 00:39:16.979 --> 00:39:21.179 When we have an axis 483 00:39:21.729 --> 00:39:25.010 Let's say we have a player here 484 00:39:26.260 --> 00:39:30.910 Which is this far from the origin 485 00:39:31.810 --> 00:39:36.580 This location is in a vector so it also has a direction 486 00:39:36.580 --> 00:39:39.580 This is the player 487 00:39:39.739 --> 00:39:42.939 This is the player's right direction 488 00:39:42.939 --> 00:39:47.340 If you bring this to the origin, it is the same vector 489 00:39:47.340 --> 00:39:55.060 If the vectors are here like this, they are all converging to the origin 490 00:39:55.060 --> 00:39:58.810 So the size and direction is all the same 491 00:39:58.810 --> 00:40:01.820 and these mean the same vector 492 00:40:01.820 --> 00:40:04.270 So when these are set apart like this 493 00:40:04.270 --> 00:40:09.699 they are basically all gathering to the center 494 00:40:10.899 --> 00:40:14.349 So this will be the Get Actor Right vector 495 00:40:15.099 --> 00:40:18.899 If you multiply numbers to the vector 496 00:40:18.899 --> 00:40:25.720 the direction does not change, only the length does 497 00:40:26.620 --> 00:40:32.320 So we simply took the right vetor or the forward vector 498 00:40:32.320 --> 00:40:35.060 and multiplied it 499 00:40:35.060 --> 00:40:37.310 So the directions do not change 500 00:40:37.310 --> 00:40:40.860 directions will change when there is addition 501 00:40:41.939 --> 00:40:46.539 If you multiply something like speed 502 00:40:46.539 --> 00:40:49.260 or the input values from the keyboard 503 00:40:49.260 --> 00:40:51.720 and if you multiply the time 504 00:40:52.110 --> 00:41:01.060 only the size will get bigger or smaller but the direction will stay the same 505 00:41:01.060 --> 00:41:04.910 However, if you multiply a value of -1 506 00:41:04.910 --> 00:41:07.860 you will get the opposite direction 507 00:41:07.860 --> 00:41:12.660 We get -1 when we press the A key 508 00:41:12.660 --> 00:41:14.699 That is why we go to the left 509 00:41:14.699 --> 00:41:17.749 We go to the right when D is pressed 510 00:41:17.749 --> 00:41:23.580 Let's say we pressed D and got a right vector 511 00:41:23.580 --> 00:41:27.330 then P = P0 + VT 512 00:41:27.330 --> 00:41:30.540 This part is P0 513 00:41:30.540 --> 00:41:35.779 Let's say the VT is this vector here 514 00:41:36.379 --> 00:41:39.629 We will add the P0 and VT 515 00:41:39.629 --> 00:41:43.559 The I said it would take it as is 516 00:41:45.060 --> 00:41:47.010 Copy this as is 517 00:41:47.010 --> 00:41:52.179 So what is the meeting point of these? 518 00:41:53.580 --> 00:41:55.130 This will be the P 519 00:41:55.130 --> 00:42:00.540 The meeting point here will be the new location 520 00:42:00.540 --> 00:42:03.990 This is the new location vector 521 00:42:03.990 --> 00:42:07.020 This will be P 522 00:42:07.419 --> 00:42:13.020 So the player will move here, to the right 523 00:42:13.020 --> 00:42:16.070 What would happen if this action is repeated? 524 00:42:16.070 --> 00:42:19.739 If we add the right vector 525 00:42:19.739 --> 00:42:23.289 to this blue vector, we get this location 526 00:42:23.289 --> 00:42:28.780 we move here again and again 527 00:42:29.419 --> 00:42:33.919 Right now the player is moving 528 00:42:33.919 --> 00:42:36.609 by the sum of the vectors 529 00:42:37.899 --> 00:42:40.499 Here is another example 530 00:42:40.499 --> 00:42:45.419 Let me draw out what would happen 531 00:42:45.419 --> 00:42:48.860 when we press W and A together 532 00:42:49.459 --> 00:42:54.219 Draw an axis like this 533 00:42:54.300 --> 00:42:57.300 The player is here 534 00:42:57.300 --> 00:43:00.860 which would have such a location vector 535 00:43:02.020 --> 00:43:03.720 We pressed A and D key 536 00:43:03.720 --> 00:43:10.110 then we would have a left vector and a top vector 537 00:43:10.110 --> 00:43:12.910 We will add these vectors 538 00:43:12.910 --> 00:43:16.179 What do we get? 539 00:43:16.300 --> 00:43:21.690 We will have a vector from the origin to this point 540 00:43:22.540 --> 00:43:27.379 This is the direction of movement 541 00:43:30.139 --> 00:43:34.659 we get the VT 542 00:43:35.580 --> 00:43:38.180 So we move by adding 543 00:43:38.180 --> 00:43:43.430 the P0 valuen and VT which is made by 544 00:43:43.430 --> 00:43:45.860 pressing W and D 545 00:43:45.860 --> 00:43:50.939 If we draw the addition formula 546 00:43:50.939 --> 00:43:54.189 The red would go like this 547 00:43:54.189 --> 00:43:59.359 and if we connect the meeting point to the origin 548 00:43:59.359 --> 00:44:00.659 This is what we get 549 00:44:00.659 --> 00:44:02.359 What is this'? 550 00:44:02.359 --> 00:44:03.979 This will be our P 551 00:44:03.979 --> 00:44:10.020 Resulting in the player moving in this diagonal direction 552 00:44:11.420 --> 00:44:14.620 These processes continue to take place very quickly 553 00:44:14.620 --> 00:44:18.699 which makes the player actor move 554 00:44:18.780 --> 00:44:25.219 Internally, it is made up of the sum of vectors 555 00:44:26.419 --> 00:44:35.179 It may come around as difficult, but I hope you take your time in understanding 556 00:44:36.060 --> 00:44:40.659 Let's wrap up what we've learned today 557 00:44:40.659 --> 00:44:45.620 We learned that vectors are composed of direction and speed 558 00:44:45.620 --> 00:44:52.899 We learned how to obtain the direction the actor should move by receiving user input 559 00:44:52.899 --> 00:44:59.780 We also learned how to calculate the next position of an actor using vector addition 560 00:45:00.879 --> 00:45:04.129 Vector Concept and Vector Addition Vector: something that has direction and velocity Scalar: having size Sum of vectors: sum of all forces 561 00:45:04.129 --> 00:45:07.529 Actor Movement Formula: P = P0 + VT P: final location value P0: current location V: velocity T: time 562 00:45:07.529 --> 00:45:14.629 Receiving User Input Using keyboards WASD keys to move the actor