WEBVTT 1 00:00:27.336 --> 00:00:29.941 Let's practice how to use rear camera 2 00:00:29.941 --> 00:00:34.990 on smartphone to recognize floor of real world 3 00:00:34.990 --> 00:00:39.753 In order to make camera to recognize floor 4 00:00:39.753 --> 00:00:43.753 use function to prevent standby mode set on your phone 5 00:00:43.753 --> 00:00:46.089 while it works 6 00:00:46.089 --> 00:00:50.030 and in order to find the center of screen 7 00:00:50.030 --> 00:00:54.139 we will implements function to get resolution size of each phone screen 8 00:00:54.139 --> 00:00:56.951 And not only just recognize the floor 9 00:00:56.951 --> 00:01:00.436 but create specific object we prepare 10 00:01:00.436 --> 00:01:03.985 depends of area or slope of floor recognized 11 00:01:03.985 --> 00:01:07.955 recognition of floor on real world 12 00:01:07.955 --> 00:01:10.109 start Unreal Engine 13 00:01:10.109 --> 00:01:13.248 Now it's not for sample project 14 00:01:13.248 --> 00:01:16.149 in order to work real projcet 15 00:01:16.149 --> 00:01:19.782 let's create new Level 16 00:01:19.782 --> 00:01:24.505 Go to File menu on the left top corner and select New Level 17 00:01:24.505 --> 00:01:27.970 to make new Level So select 18 00:01:27.970 --> 00:01:31.010 Empty Level 19 00:01:31.010 --> 00:01:32.860 and click Create 20 00:01:32.860 --> 00:01:35.218 to create new Level 21 00:01:35.218 --> 00:01:39.079 Since AR contents is basically 22 00:01:39.079 --> 00:01:43.248 creating 3D objects on real world where camera is capturing 23 00:01:43.248 --> 00:01:47.733 In order to fill the backgrounds 24 00:01:47.733 --> 00:01:50.000 with the picture camera captures 25 00:01:50.000 --> 00:01:53.139 we selected Empty Level 26 00:01:53.139 --> 00:01:56.456 To develop AR contents 27 00:01:56.456 --> 00:02:00.386 let's do some basic necessary works 28 00:02:00.386 --> 00:02:03.614 First, we need to set player start point 29 00:02:03.614 --> 00:02:06.911 where player will be placed 30 00:02:06.911 --> 00:02:10.511 Therefore on Place Actors 31 00:02:10.511 --> 00:02:13.347 drag Player Start 32 00:02:13.347 --> 00:02:15.693 and place it on the screen 33 00:02:15.693 --> 00:02:19.010 Location at 0, 0, 0 34 00:02:19.010 --> 00:02:24.109 and Rotation at 0, 0, 0 as well 35 00:02:24.109 --> 00:02:29.169 In order to make objects visible 36 00:02:29.169 --> 00:02:32.169 when some objects are placed on screen 37 00:02:32.169 --> 00:02:34.832 we need lights 38 00:02:34.832 --> 00:02:40.406 therefore let's place Directional Light 39 00:02:40.406 --> 00:02:42.713 which gives the effect of sun on the map 40 00:02:42.713 --> 00:02:45.268 It doesn't matter where you place it 41 00:02:45.268 --> 00:02:48.168 Since Directional Light 42 00:02:48.168 --> 00:02:49.495 gives the effect of sunlight 43 00:02:49.495 --> 00:02:53.139 wherever you place it, place here or place here 44 00:02:53.139 --> 00:02:56.139 since the sun's light goes everywhere 45 00:02:56.139 --> 00:02:58.901 in the same direction on screen 46 00:02:58.901 --> 00:03:02.287 it really doesn't matter where you place it 47 00:03:02.287 --> 00:03:05.087 But the direction of light is 48 00:03:05.087 --> 00:03:07.139 the white arrow you can see here 49 00:03:07.139 --> 00:03:09.620 Source Angle on here 50 00:03:09.620 --> 00:03:13.584 it can be changed by manipulating Source Angle 51 00:03:13.584 --> 00:03:17.624 That's all you should know 52 00:03:17.624 --> 00:03:20.258 Let's just keep the default value for now 53 00:03:20.258 --> 00:03:23.674 and place it little above from 0, 0, 0 54 00:03:23.674 --> 00:03:27.010 Then we need to save Level 55 00:03:27.010 --> 00:03:32.139 So go to Contents Drawer, on Content folder 56 00:03:32.139 --> 00:03:35.733 Click Add button and New Folder on top 57 00:03:35.733 --> 00:03:37.533 Select New Folder 58 00:03:37.533 --> 00:03:39.654 to create a new folder 59 00:03:39.654 --> 00:03:44.773 Name it Maps 60 00:03:44.773 --> 00:03:52.386 and we will save current Level 61 00:03:52.386 --> 00:03:56.476 In Maps folder 62 00:03:56.476 --> 00:04:01.076 name it MainMap 63 00:04:01.076 --> 00:04:03.990 and save it 64 00:04:03.990 --> 00:04:05.840 Then in Maps folder 65 00:04:05.840 --> 00:04:07.614 you can see the file 66 00:04:07.614 --> 00:04:10.139 named MainMap is saved 67 00:04:10.139 --> 00:04:15.000 Next, we will create Player Pawn which will appear 68 00:04:15.000 --> 00:04:17.259 on Player Start position 69 00:04:17.259 --> 00:04:19.509 So in order to make Player Pawn 70 00:04:19.509 --> 00:04:25.422 in Content folder, go to Add then New Folder 71 00:04:25.422 --> 00:04:28.140 to make another new folder 72 00:04:28.140 --> 00:04:33.328 and name it Blueprints 73 00:04:33.328 --> 00:04:36.496 And go into Blueprints 74 00:04:36.496 --> 00:04:39.536 right click on empty space 75 00:04:39.536 --> 00:04:42.616 and select 76 00:04:42.616 --> 00:04:44.922 Blueprint Class above 77 00:04:44.922 --> 00:04:48.140 Pick Pawn class for parent class 78 00:04:48.140 --> 00:04:51.140 Select Pawn class 79 00:04:51.140 --> 00:04:58.431 Name new Pawn BP_HunetPlayer 80 00:04:58.431 --> 00:05:01.140 name it like this 81 00:05:01.140 --> 00:05:05.704 Open settings of BP_HunetPlayer Pawn 82 00:05:05.704 --> 00:05:09.813 we only need camera on HunetPlayer 83 00:05:09.813 --> 00:05:13.823 Click Add button on Components 84 00:05:13.823 --> 00:05:16.473 camera, on search field 85 00:05:16.473 --> 00:05:19.140 type camera 86 00:05:19.140 --> 00:05:20.159 You see Camera here 87 00:05:20.159 --> 00:05:22.459 Let's add 88 00:05:22.459 --> 00:05:24.249 Camera component 89 00:05:24.249 --> 00:05:27.499 Then on viewport window 90 00:05:27.499 --> 00:05:32.754 you can see camera mark like this 91 00:05:32.754 --> 00:05:37.467 Compile and save it 92 00:05:37.467 --> 00:05:40.675 Back to MainMap 93 00:05:40.675 --> 00:05:45.952 Player Pawn we just made 94 00:05:45.952 --> 00:05:49.981 in order to make this HunetPlayer Pawn to default Pawn 95 00:05:49.981 --> 00:05:52.467 we will make a game mode 96 00:05:52.467 --> 00:05:54.675 Right click again 97 00:05:54.675 --> 00:05:57.467 select Blueprint Class 98 00:05:57.467 --> 00:05:59.417 for parent class 99 00:05:59.417 --> 00:06:03.873 select Game Mode Base 100 00:06:03.873 --> 00:06:07.536 For the name of blueprint file we created 101 00:06:07.536 --> 00:06:14.336 BP_ARGameModeBase 102 00:06:14.336 --> 00:06:17.873 set it like this 103 00:06:17.873 --> 00:06:20.473 Double click ARGameModeBase 104 00:06:20.473 --> 00:06:22.942 to open settings window 105 00:06:22.942 --> 00:06:27.140 Default Pawn Class on ARGameModeBase 106 00:06:27.140 --> 00:06:29.040 Default Pawn Class on the right 107 00:06:29.040 --> 00:06:33.437 to BP_HunetPlayer we just created 108 00:06:33.437 --> 00:06:37.140 set it to BP_HunetPlayer 109 00:06:37.140 --> 00:06:41.140 Compile and save it 110 00:06:41.140 --> 00:06:45.882 In order to make this ARGameModeBase we just made 111 00:06:45.882 --> 00:06:48.615 to main game mode 112 00:06:48.615 --> 00:06:53.447 Edit menu on top, click Project Settings 113 00:06:53.447 --> 00:06:56.140 to open project settings window 114 00:06:56.140 --> 00:06:59.508 Click Maps & Modes tab 115 00:06:59.508 --> 00:07:01.071 on the left 116 00:07:01.071 --> 00:07:04.121 Set Default GameMode 117 00:07:04.121 --> 00:07:08.625 to BP_ARGameModeBase 118 00:07:08.625 --> 00:07:11.714 change it to this 119 00:07:11.714 --> 00:07:15.982 If you open Selected GameMode here 120 00:07:15.982 --> 00:07:23.526 You can see Default Pawn Class is set to BP_HunetPlayer 121 00:07:23.526 --> 00:07:26.912 And in case of Default Maps as well 122 00:07:26.912 --> 00:07:30.612 set Editor Startup Map 123 00:07:30.612 --> 00:07:34.368 to MainMap we just created 124 00:07:34.368 --> 00:07:36.618 Game Default Map which is executed first 125 00:07:36.618 --> 00:07:39.457 when packaged to apk file 126 00:07:39.457 --> 00:07:43.140 set this to MainMap as well 127 00:07:43.140 --> 00:07:47.506 Change it to MainMap like this 128 00:07:47.506 --> 00:07:50.853 Come back to MainMap 129 00:07:50.853 --> 00:07:56.031 Now the next thing we are going to do is 130 00:07:56.031 --> 00:08:01.447 double click HunetPlayer to open it 131 00:08:01.447 --> 00:08:05.536 On BeginPlay 132 00:08:05.536 --> 00:08:08.566 in order to use AR at first 133 00:08:08.566 --> 00:08:12.724 we need to start something called AR Session 134 00:08:12.724 --> 00:08:14.684 AR Session is 135 00:08:14.684 --> 00:08:16.318 simply speaking 136 00:08:16.318 --> 00:08:21.397 where this apk file will be executed? 137 00:08:21.397 --> 00:08:23.249 On the phone 138 00:08:23.249 --> 00:08:28.140 It is intermediate equipment 139 00:08:28.140 --> 00:08:30.932 to synchronize lifecycles 140 00:08:30.932 --> 00:08:34.447 of Unreal Engine 141 00:08:34.447 --> 00:08:37.140 and camera on your phone 142 00:08:37.140 --> 00:08:41.585 So pull out from BeginPlay node 143 00:08:41.585 --> 00:08:48.140 type Start AR Session on search field 144 00:08:48.140 --> 00:08:50.140 search it 145 00:08:50.140 --> 00:08:51.790 Here is Session Config 146 00:08:51.790 --> 00:08:53.566 About session which will be opened 147 00:08:53.566 --> 00:08:56.774 it meant to be put file about session settings in 148 00:08:56.774 --> 00:08:58.346 But we haven't made 149 00:08:58.346 --> 00:09:00.081 Session Config yet 150 00:09:00.081 --> 00:09:01.972 so we have to make it now 151 00:09:01.972 --> 00:09:04.556 On Content Drawer 152 00:09:04.556 --> 00:09:06.536 we will make folder again 153 00:09:06.536 --> 00:09:10.140 On Content folder, click Add 154 00:09:10.140 --> 00:09:12.130 Then New Folder 155 00:09:12.130 --> 00:09:14.140 to make another new folder 156 00:09:14.140 --> 00:09:16.140 And the name of folder 157 00:09:16.140 --> 00:09:22.239 name it DataAssets 158 00:09:22.239 --> 00:09:25.694 Inside of DataAssets 159 00:09:25.694 --> 00:09:28.140 right click 160 00:09:28.140 --> 00:09:32.140 and select Miscellaneous 161 00:09:32.140 --> 00:09:35.259 find and select Data Asset 162 00:09:35.259 --> 00:09:39.793 among these list on the right 163 00:09:39.793 --> 00:09:43.496 In the case of Data Asset, we can select 164 00:09:43.496 --> 00:09:46.269 which class this Data Asset will be 165 00:09:46.269 --> 00:09:49.140 Among them ARSession Config 166 00:09:49.140 --> 00:09:51.823 to set about Session 167 00:09:51.823 --> 00:09:55.447 select ARSession Config file 168 00:09:55.447 --> 00:09:57.247 click Select 169 00:09:57.247 --> 00:09:59.457 to create Session Config file 170 00:09:59.457 --> 00:10:02.140 Name of Session Config file we made 171 00:10:02.140 --> 00:10:07.690 is HunetARSessionConfig 172 00:10:07.690 --> 00:10:10.873 name it like this 173 00:10:10.873 --> 00:10:14.665 Double click HunetARSessionConfig to open 174 00:10:14.665 --> 00:10:18.427 Then you will see a variety of setting values 175 00:10:18.427 --> 00:10:20.358 Among the setting values 176 00:10:20.358 --> 00:10:23.774 first thing we are going to do 177 00:10:23.774 --> 00:10:26.457 is recognize the floor 178 00:10:26.457 --> 00:10:30.972 Under this AR Settings 179 00:10:30.972 --> 00:10:34.526 First, there is Session Type 180 00:10:34.526 --> 00:10:35.964 Session Type 181 00:10:35.964 --> 00:10:38.803 Session Type is set to World 182 00:10:38.803 --> 00:10:42.675 There are options such as World, Face, Image 183 00:10:42.681 --> 00:10:45.391 recognizing floor means 184 00:10:45.391 --> 00:10:47.543 recognizing World 185 00:10:47.562 --> 00:10:51.140 So we will set this to World 186 00:10:51.140 --> 00:10:53.430 Especially in this case of World 187 00:10:53.430 --> 00:10:56.384 there are front camera 188 00:10:56.384 --> 00:10:57.628 and rear camera on your phone 189 00:10:57.628 --> 00:11:00.552 It's to turn rear camera on 190 00:11:00.552 --> 00:11:03.411 Set it to World to select 191 00:11:03.411 --> 00:11:05.140 turning on the rear camera as type 192 00:11:05.140 --> 00:11:08.279 Above that there is World Alignment 193 00:11:08.279 --> 00:11:11.882 align method of World 194 00:11:11.882 --> 00:11:14.140 In order to make it align with the direction of gravity 195 00:11:14.140 --> 00:11:17.754 select Gravity 196 00:11:17.754 --> 00:11:21.140 And among the detection types 197 00:11:21.140 --> 00:11:24.467 Horizontal Plane, Vertical Plane 198 00:11:24.467 --> 00:11:26.298 We can detect both of them 199 00:11:26.298 --> 00:11:29.774 Both of them is checked as default 200 00:11:29.774 --> 00:11:32.833 Horizontal Plane is 201 00:11:32.833 --> 00:11:36.486 Horizontal therefore detects horizontal surface 202 00:11:36.486 --> 00:11:41.486 such as upper side of desk or box 203 00:11:41.486 --> 00:11:45.278 Vertical detects vertical surface 204 00:11:45.278 --> 00:11:49.308 such as wall or window 205 00:11:49.308 --> 00:11:51.645 So we can detect 206 00:11:51.645 --> 00:11:53.368 both Horizontal and Vertical 207 00:11:53.368 --> 00:11:57.962 If we detect too many surfaces it would be dizzy and confuse 208 00:11:57.962 --> 00:11:59.764 so remove Vertical 209 00:11:59.764 --> 00:12:03.140 and leave Horizontal on 210 00:12:03.140 --> 00:12:07.348 to detect only floor, horizontal surface 211 00:12:07.348 --> 00:12:10.853 To adjust the focus of the camera automatically 212 00:12:10.853 --> 00:12:14.041 we have to turn on Enable Auto Focus 213 00:12:14.041 --> 00:12:16.308 Light Estimation Mode 214 00:12:16.308 --> 00:12:20.318 If the picture camera is capturing is too bright 215 00:12:20.318 --> 00:12:22.437 then reduce the brightness of camera 216 00:12:22.437 --> 00:12:25.595 if it is too dark, increase the brightness 217 00:12:25.595 --> 00:12:28.526 Light Estimation Mode working as aperture 218 00:12:28.526 --> 00:12:31.675 set to Ambient Light Estimate 219 00:12:31.675 --> 00:12:35.011 to measure occlusion light 220 00:12:35.011 --> 00:12:37.140 To measure how dark surrounding is 221 00:12:37.140 --> 00:12:40.249 with Ambient Light 222 00:12:40.249 --> 00:12:42.536 There are various things 223 00:12:42.536 --> 00:12:45.328 but we don't need to touch anything else 224 00:12:45.328 --> 00:12:47.259 so leave them as they are 225 00:12:47.259 --> 00:12:49.863 and adjust only these part 226 00:12:49.863 --> 00:12:51.813 Seession Type, Horizontal 227 00:12:51.813 --> 00:12:53.536 Vertical and Detection 228 00:12:53.536 --> 00:12:55.853 check only these 229 00:12:55.853 --> 00:12:59.823 Click save to save it 230 00:12:59.823 --> 00:13:03.140 and close SessionConfig window 231 00:13:03.140 --> 00:13:05.823 Now that we made session config 232 00:13:05.823 --> 00:13:08.902 Come back to BP_HunetPlayer 233 00:13:08.902 --> 00:13:11.140 Start AR Session node 234 00:13:11.140 --> 00:13:13.764 we made earlier 235 00:13:13.764 --> 00:13:16.526 on Session Config 236 00:13:16.526 --> 00:13:19.427 put HunetARSessionConfig file 237 00:13:19.427 --> 00:13:20.813 we just made 238 00:13:24.199 --> 00:13:27.049 Now on Session 239 00:13:27.049 --> 00:13:29.140 Session is executed now 240 00:13:29.140 --> 00:13:32.793 We are keep going to move camera 241 00:13:32.793 --> 00:13:36.378 we need to know which plane of objects 242 00:13:36.378 --> 00:13:38.516 was recognized every frame 243 00:13:38.516 --> 00:13:41.140 And also need to check 244 00:13:41.140 --> 00:13:42.417 whether things are recognized well 245 00:13:42.417 --> 00:13:45.140 246 00:13:45.140 --> 00:13:52.912 So drag execution pin from Tick node 247 00:13:52.912 --> 00:13:58.140 and type get all AR geometries on search field 248 00:13:58.140 --> 00:14:01.140 and select it 249 00:14:01.140 --> 00:14:04.833 to get every target 250 00:14:04.833 --> 00:14:09.477 AR camera recognized in the form of array 251 00:14:09.477 --> 00:14:15.140 let me draw every array 252 00:14:15.140 --> 00:14:18.467 that camera recognized on screen 253 00:14:18.467 --> 00:14:21.546 Pick execution pin and drag 254 00:14:21.546 --> 00:14:25.318 type debug draw 255 00:14:25.318 --> 00:14:27.140 if you search it 256 00:14:27.140 --> 00:14:31.051 there will be node 257 00:14:31.051 --> 00:14:32.783 called Debug Draw Tracked Geometry 258 00:14:32.783 --> 00:14:35.655 Debug Draw Tracked Geometry 259 00:14:35.655 --> 00:14:41.100 This node can draw 260 00:14:41.100 --> 00:14:44.576 selected Geometries on screen 261 00:14:44.576 --> 00:14:48.387 But it detects as array 262 00:14:48.387 --> 00:14:50.140 and indicate one by one 263 00:14:50.140 --> 00:14:52.774 therefore use loop statement 264 00:14:52.774 --> 00:14:55.486 to make it indicate multiple things at once 265 00:14:55.486 --> 00:14:59.863 So drag this node 266 00:14:59.863 --> 00:15:03.417 and execute For Each Loop 267 00:15:03.417 --> 00:15:04.817 Use For Each Loop 268 00:15:04.817 --> 00:15:07.486 connect execution pin 269 00:15:07.486 --> 00:15:12.991 To make it Debug Draw from beginning to the end 270 00:15:12.991 --> 00:15:16.764 which means it will draw 271 00:15:16.764 --> 00:15:18.467 each element values in array 272 00:15:18.467 --> 00:15:20.595 Draw lines 273 00:15:20.595 --> 00:15:26.140 Probably it will draw the outline of plane we detected 274 00:15:26.140 --> 00:15:30.417 If you open it by clicking arrow below 275 00:15:30.417 --> 00:15:33.863 we can set things such as 276 00:15:33.863 --> 00:15:36.140 the color and thickness of outline 277 00:15:36.140 --> 00:15:39.892 Change settings 278 00:15:39.892 --> 00:15:42.675 to draw green outline 279 00:15:42.675 --> 00:15:45.882 of target we detected 280 00:15:45.882 --> 00:15:49.288 Then the thickness 281 00:15:49.288 --> 00:15:51.873 5 pixel would be too thick 282 00:15:51.873 --> 00:15:56.140 It'd be enough to set it 1 pixel 283 00:15:56.140 --> 00:16:00.447 let's just change it to 1 pixel 284 00:16:00.447 --> 00:16:04.140 This is for how long this outline will be remained 285 00:16:04.140 --> 00:16:06.140 We are doing this on Tick 286 00:16:06.140 --> 00:16:08.140 Therefore it doesn't need to be remained 287 00:16:08.140 --> 00:16:12.734 Since we will draw again every Tick 288 00:16:12.734 --> 00:16:17.417 compile and save it 289 00:16:17.417 --> 00:16:20.298 Then back to the map 290 00:16:20.298 --> 00:16:22.863 package it once 291 00:16:22.863 --> 00:16:24.774 Package it 292 00:16:24.774 --> 00:16:26.590 Same as before 293 00:16:26.590 --> 00:16:30.140 select Packages folder 294 00:16:30.140 --> 00:16:33.912 click Select to start packaging 295 00:16:37.526 --> 00:16:41.417 Once it is done, as same as last time 296 00:16:43.645 --> 00:16:46.982 under Unreal Project, under HunetAR 297 00:16:46.982 --> 00:16:50.417 Where our projects is located, under Packages folder 298 00:16:50.417 --> 00:16:52.992 it's the apk file under the Android_Multi folder 299 00:16:52.992 --> 00:16:56.982 Ctrl + C to copy apk file 300 00:16:56.982 --> 00:16:59.803 We made folder named UnrealApp 301 00:16:59.803 --> 00:17:02.120 last time on the phoe 302 00:17:02.120 --> 00:17:03.902 To make it easy to be found 303 00:17:03.902 --> 00:17:06.298 exist file in this folder 304 00:17:06.298 --> 00:17:09.595 press Delete key to delete it 305 00:17:09.595 --> 00:17:12.318 and Ctrl + V 306 00:17:12.318 --> 00:17:15.457 to paste what we packaged 307 00:17:18.219 --> 00:17:22.031 When it's done, unlock your phone 308 00:17:22.031 --> 00:17:28.318 APK on your phone 309 00:17:28.318 --> 00:17:31.668 apk install file on My Files 310 00:17:31.668 --> 00:17:34.506 double click 311 00:17:34.506 --> 00:17:38.140 HunetAR we just pasted 312 00:17:38.140 --> 00:17:41.140 and install it with install program 313 00:17:41.140 --> 00:17:44.011 Since we installed once last time 314 00:17:44.011 --> 00:17:45.546 so it will be overwritten 315 00:17:45.546 --> 00:17:47.487 So when you overwrite it 316 00:17:47.487 --> 00:17:49.348 not asking if you would install it 317 00:17:49.348 --> 00:17:51.784 it will ask if you would update 318 00:17:51.784 --> 00:17:55.140 Then tap update 319 00:17:55.140 --> 00:17:56.744 to overwrite 320 00:17:56.744 --> 00:17:58.655 It is finished now 321 00:17:58.655 --> 00:18:00.952 then tap open 322 00:18:05.041 --> 00:18:05.823 Now then 323 00:18:08.249 --> 00:18:10.140 if you try to aim surface 324 00:18:10.140 --> 00:18:14.140 you will see the surfaces are starting to be recognized little by little 325 00:18:14.140 --> 00:18:16.526 Planes are recognized little by little 326 00:18:18.882 --> 00:18:20.922 Now it's narrow space 327 00:18:20.922 --> 00:18:22.397 and have a lot of bumpy surfaces 328 00:18:22.397 --> 00:18:24.140 so the recognition might be take some times 329 00:18:24.140 --> 00:18:27.229 One of the reason it takes time to recognize is 330 00:18:27.229 --> 00:18:29.011 that there are dark 331 00:18:29.011 --> 00:18:30.774 and shadow surfaces here and there 332 00:18:30.774 --> 00:18:33.625 but if you keep aiming slowly 333 00:18:33.625 --> 00:18:36.952 then you would see the recognized surfaces are increasing gradually 334 00:18:36.952 --> 00:18:39.090 You can see the outlines are increasing 335 00:18:39.090 --> 00:18:42.080 Now we can see the surfaces 336 00:18:42.080 --> 00:18:43.378 are recognized like this 337 00:18:45.239 --> 00:18:47.992 Now it's confirmed 338 00:18:47.992 --> 00:18:52.417 that camera is recognize plane surfaces well 339 00:18:52.417 --> 00:18:57.496 Then the part where we debug 340 00:18:57.496 --> 00:19:01.932 was only for checking 341 00:19:01.932 --> 00:19:04.298 so disconnect it 342 00:19:04.298 --> 00:19:09.863 and move these nodes aside above 343 00:19:09.863 --> 00:19:11.952 We are not going to process collision for now 344 00:19:11.952 --> 00:19:16.140 so let me put aside below where we it can not be seen 345 00:19:16.140 --> 00:19:19.457 move Tick little below 346 00:19:19.457 --> 00:19:20.348 For this 347 00:19:24.546 --> 00:19:36.734 note that these are nodes indicating outlines of surface recognized 348 00:19:36.734 --> 00:19:39.001 let's mark it like this 349 00:19:39.001 --> 00:19:43.744 We can connect these node 350 00:19:43.744 --> 00:19:46.497 whenever we need for checking 351 00:19:47.066 --> 00:19:51.155 Prevent standby mode and function to get resolution information 352 00:19:51.396 --> 00:19:53.407 For convenience 353 00:19:53.407 --> 00:19:55.655 we will add some nodes 354 00:19:55.655 --> 00:20:01.693 First, when we are aiming 355 00:20:01.693 --> 00:20:05.693 AR camera to recognize plane 356 00:20:05.693 --> 00:20:11.416 While we are doing it 357 00:20:11.416 --> 00:20:13.816 screen could be turned off 358 00:20:13.816 --> 00:20:15.881 by working of screen saver or standby mode 359 00:20:15.881 --> 00:20:18.406 Therefore, in order to prevent it 360 00:20:18.406 --> 00:20:23.039 we will add a node to turn screen saver off 361 00:20:23.039 --> 00:20:26.178 So it needs to be done only once 362 00:20:26.178 --> 00:20:29.278 on BeginPlay, on Start AR Session 363 00:20:29.278 --> 00:20:31.554 drag execution pin out 364 00:20:31.554 --> 00:20:40.445 And search control screensaver 365 00:20:40.445 --> 00:20:43.505 Then you will see Control Screensaver node 366 00:20:43.505 --> 00:20:47.822 On Control Screensaver 367 00:20:47.822 --> 00:20:52.572 uncheck Allow Screensaver 368 00:20:52.572 --> 00:20:58.426 to set for screensaver not to work 369 00:20:58.426 --> 00:21:03.832 And now all geometries 370 00:21:03.832 --> 00:21:06.851 it will detect geometries we recognized 371 00:21:06.851 --> 00:21:13.317 Now with geometries, we recognize the center of your phone 372 00:21:13.317 --> 00:21:15.426 when you aim center 373 00:21:15.426 --> 00:21:18.713 if there is plane on the center 374 00:21:18.713 --> 00:21:21.406 of screen we are aiming with camera 375 00:21:21.406 --> 00:21:25.416 then we will display a object 376 00:21:25.416 --> 00:21:30.901 So let's make a object 377 00:21:30.901 --> 00:21:33.000 we'd like to generate there as blueprint 378 00:21:37.475 --> 00:21:38.554 There is a image file 379 00:21:38.554 --> 00:21:41.307 It's Indicator.png file 380 00:21:41.307 --> 00:21:45.957 Ctrl + X to cut this image file 381 00:21:45.957 --> 00:21:48.881 cut it and 382 00:21:48.881 --> 00:21:51.871 under Unreal Project, under HunetAR project folder 383 00:21:51.871 --> 00:21:55.317 where our projects are located 384 00:21:55.317 --> 00:21:59.713 and make a new folder inside of Content folder 385 00:21:59.713 --> 00:22:03.000 New and Folders 386 00:22:03.000 --> 00:22:08.000 So let's make a folder 387 00:22:08.000 --> 00:22:09.555 named Textures here 388 00:22:09.555 --> 00:22:11.805 Textures 389 00:22:11.805 --> 00:22:13.727 And inside of this Textures folder 390 00:22:13.727 --> 00:22:15.307 Ctrl + V 391 00:22:15.307 --> 00:22:20.376 to paste Indicator image file 392 00:22:20.376 --> 00:22:22.555 Now since new image is added 393 00:22:22.555 --> 00:22:24.634 you will be asked 394 00:22:24.634 --> 00:22:26.673 if you would import on editor 395 00:22:26.673 --> 00:22:28.089 then import it 396 00:22:28.089 --> 00:22:32.297 Click Import button 397 00:22:32.297 --> 00:22:34.713 Then if you look at Content Drawer 398 00:22:34.713 --> 00:22:36.782 we made Textures folder 399 00:22:36.782 --> 00:22:40.000 So inside of Textures folder, you can see 400 00:22:40.000 --> 00:22:43.000 there is file named Indicator 401 00:22:43.000 --> 00:22:47.634 But texture file is just white 402 00:22:47.634 --> 00:22:49.000 It's hard to see but 403 00:22:49.000 --> 00:22:51.287 it is a circle shape 404 00:22:51.287 --> 00:22:55.346 with some pointy arrows on the transparent background 405 00:22:55.346 --> 00:22:58.337 This image supposed to be shown like this 406 00:22:58.337 --> 00:23:01.594 but it isn't now 407 00:23:01.594 --> 00:23:04.139 Double click texture 408 00:23:04.139 --> 00:23:07.614 to make texture image sticks out 409 00:23:07.614 --> 00:23:09.832 on the right side here 410 00:23:09.832 --> 00:23:13.465 change Texture Group 411 00:23:13.485 --> 00:23:17.277 from World to UI 412 00:23:17.277 --> 00:23:20.277 Then save it 413 00:23:20.277 --> 00:23:22.416 and close settings window 414 00:23:22.416 --> 00:23:25.317 and go back to Textures folder on Contents Drawer 415 00:23:25.317 --> 00:23:27.763 now you can see 416 00:23:27.763 --> 00:23:30.413 the transparent and opaque part 417 00:23:30.413 --> 00:23:33.683 of Indicator file like this 418 00:23:33.683 --> 00:23:36.396 Then based on this texture 419 00:23:36.396 --> 00:23:38.000 we will make a Material 420 00:23:38.000 --> 00:23:42.643 Select texture and right click 421 00:23:42.643 --> 00:23:45.544 Then Create Material 422 00:23:45.544 --> 00:23:49.000 Cilck Create Material 423 00:23:49.000 --> 00:23:51.317 and once new Material file is created 424 00:23:51.317 --> 00:23:56.366 name it M_Indicator 425 00:23:56.366 --> 00:23:58.436 name it like this 426 00:23:58.436 --> 00:24:01.475 Then double click Indicator Material file 427 00:24:01.475 --> 00:24:04.782 to open settings window 428 00:24:04.782 --> 00:24:09.000 Now the Texture Sample is just white like this 429 00:24:09.000 --> 00:24:12.475 but the real texture is, if you select this node 430 00:24:12.475 --> 00:24:15.277 you see Indicator is assigned to Texture 431 00:24:15.277 --> 00:24:18.000 But the transparent value is not applying 432 00:24:18.000 --> 00:24:22.772 Here is M_Indicator, the basic node 433 00:24:22.772 --> 00:24:25.000 Select this main node 434 00:24:25.000 --> 00:24:29.634 On Details pannel on the left 435 00:24:29.634 --> 00:24:31.950 there is Blend Mode here 436 00:24:31.950 --> 00:24:34.300 Opaque is used 437 00:24:34.300 --> 00:24:35.614 to indicate opaque image 438 00:24:35.614 --> 00:24:37.237 But for the image 439 00:24:37.237 --> 00:24:40.772 which has transparent value, alpha value 440 00:24:40.772 --> 00:24:44.119 you need to select Translucent 441 00:24:44.119 --> 00:24:46.921 So change it to Translucent 442 00:24:46.921 --> 00:24:51.386 Then enabled sockets on main node would be changed 443 00:24:51.386 --> 00:24:53.752 And Opacity would be enabled 444 00:24:53.752 --> 00:24:56.000 This alpha value, this is transparent value 445 00:24:56.000 --> 00:25:00.990 connect this transparent value to the Opacity 446 00:25:00.990 --> 00:25:03.140 Now the transparent part 447 00:25:03.140 --> 00:25:06.000 and opaque part has been split like this 448 00:25:06.000 --> 00:25:07.250 We will indicate it 449 00:25:07.250 --> 00:25:09.812 on plane, flat surface 450 00:25:09.812 --> 00:25:13.412 on preview viewport, right in the middle among the buttons 451 00:25:13.412 --> 00:25:15.317 let's click plain button 452 00:25:15.317 --> 00:25:19.817 Then you would see image texture 453 00:25:19.817 --> 00:25:22.000 on flat square surface 454 00:25:22.000 --> 00:25:24.000 Now we can see it better 455 00:25:24.000 --> 00:25:28.000 But it still can not be seen well since it is white 456 00:25:28.000 --> 00:25:31.198 It could not be seen well when it is on camera 457 00:25:31.198 --> 00:25:33.921 so let's add some colors to it 458 00:25:33.921 --> 00:25:35.723 In order to put some colors 459 00:25:35.723 --> 00:25:41.000 right click on the empty space 460 00:25:41.000 --> 00:25:45.841 and type VectorParameter 461 00:25:45.841 --> 00:25:49.337 VectorParameter node will be searched 462 00:25:49.337 --> 00:25:53.000 Select VectorParameter node 463 00:25:53.000 --> 00:25:57.564 and name it Color 464 00:25:57.564 --> 00:26:01.000 Put Color node little above 465 00:26:01.000 --> 00:26:06.376 drag this RGB socket and type * 466 00:26:06.376 --> 00:26:09.158 then Multiply node will be searched 467 00:26:09.158 --> 00:26:10.129 It's to multiply 468 00:26:10.129 --> 00:26:13.584 Socket A of Multiply node is connected 469 00:26:13.584 --> 00:26:17.693 And Indicator texture we chose earlier 470 00:26:17.693 --> 00:26:19.793 connect RGB value of Texture node 471 00:26:19.793 --> 00:26:23.713 to B socket of Multiply 472 00:26:23.713 --> 00:26:26.313 And the result of multiply 473 00:26:26.313 --> 00:26:29.564 will be passed to Base Color 474 00:26:29.564 --> 00:26:31.247 Then which color are we going to add 475 00:26:31.247 --> 00:26:35.445 in order to make it stick out 476 00:26:35.445 --> 00:26:38.792 let's make it yellow 477 00:26:38.792 --> 00:26:42.673 Yellow color and set alpha value to 1 478 00:26:42.673 --> 00:26:45.653 make it opaque then click OK 479 00:26:45.653 --> 00:26:49.921 So let them multiply with each other 480 00:26:49.921 --> 00:26:51.257 How it would be like? 481 00:26:51.257 --> 00:26:53.757 You will see 482 00:26:53.757 --> 00:26:57.000 Indicator image with color like this 483 00:26:57.000 --> 00:27:01.614 Click Save to save Material settings 484 00:27:01.614 --> 00:27:07.861 If it is saved, close Material settings window 485 00:27:07.861 --> 00:27:09.911 At last, go to Content Drawer 486 00:27:09.911 --> 00:27:12.139 go into Blueprints folder 487 00:27:12.139 --> 00:27:15.000 let's put Indicator Texture we made 488 00:27:15.000 --> 00:27:20.000 to actual 3D modeling 489 00:27:20.000 --> 00:27:22.000 to square plane modeling 490 00:27:22.000 --> 00:27:24.000 Right click 491 00:27:24.000 --> 00:27:28.000 and create Blueprint Class 492 00:27:28.000 --> 00:27:32.693 I'll make it as Actor since it needs to be placed on World 493 00:27:32.693 --> 00:27:36.293 blueprint inherited Actor class 494 00:27:36.293 --> 00:27:43.634 name It BP_Indicator 495 00:27:43.634 --> 00:27:46.684 Double click BP_Indicator file 496 00:27:46.684 --> 00:27:48.337 to open settings window 497 00:27:52.000 --> 00:27:55.600 Under the DefaultSceneRoot of Indicator 498 00:27:55.600 --> 00:27:58.000 click Add button 499 00:27:58.000 --> 00:28:01.277 Select Plane here 500 00:28:01.277 --> 00:28:03.208 Plane Mesh 501 00:28:03.208 --> 00:28:06.099 Set a Plane Mesh like this 502 00:28:12.603 --> 00:28:16.745 If you compile it once 503 00:28:16.745 --> 00:28:19.643 on Plane Mesh, below Static Mesh 504 00:28:19.643 --> 00:28:22.673 there will be Materials 505 00:28:22.673 --> 00:28:26.781 In search field on this Materials 506 00:28:26.781 --> 00:28:29.716 type M_Indicator 507 00:28:29.716 --> 00:28:32.772 then you will see Indicator Material 508 00:28:32.772 --> 00:28:35.697 M_Indicator Material 509 00:28:35.697 --> 00:28:37.772 Assign this Material 510 00:28:37.772 --> 00:28:39.300 we created before 511 00:28:39.300 --> 00:28:42.112 Then on Plane Mesh 512 00:28:42.112 --> 00:28:45.468 you will see Indicator is indicating like this 513 00:28:45.468 --> 00:28:51.488 But let me change it to World coordinate 514 00:28:51.488 --> 00:28:52.944 with globe mark 515 00:28:52.944 --> 00:28:55.102 On World coordinate 516 00:28:55.102 --> 00:28:58.300 which way is the front? 517 00:28:58.300 --> 00:28:59.805 The red arrow 518 00:28:59.805 --> 00:29:03.280 This red arrow refers to forward vector 519 00:29:03.280 --> 00:29:05.458 blue is up vector 520 00:29:05.458 --> 00:29:07.587 and green is right vector 521 00:29:07.587 --> 00:29:11.854 And the direction of world is red arrow 522 00:29:11.854 --> 00:29:15.112 In order to match with forward direction 523 00:29:15.112 --> 00:29:17.488 this needs to be rotated 524 00:29:17.488 --> 00:29:19.538 So switch it to rotation tool 525 00:29:22.300 --> 00:29:28.270 rotate it 90 degree 526 00:29:28.270 --> 00:29:30.280 Therefore when switch it back to move tool 527 00:29:30.280 --> 00:29:31.904 front direction 528 00:29:31.904 --> 00:29:35.181 and the arrow part 529 00:29:35.181 --> 00:29:37.151 on the front of this texture 530 00:29:37.151 --> 00:29:39.419 should be pointed same direction 531 00:29:39.419 --> 00:29:41.552 Since decimal point is irritate 532 00:29:41.552 --> 00:29:43.240 so let's just type 533 00:29:43.240 --> 00:29:44.528 90 manually 534 00:29:46.815 --> 00:29:49.844 So that rotate it 90 degree 535 00:29:49.844 --> 00:29:53.929 Then this Plain Mesh has 536 00:29:53.929 --> 00:29:58.735 1m of width and depth 537 00:29:58.735 --> 00:30:01.359 But this 1m-long Mesh 538 00:30:01.359 --> 00:30:03.928 is too big to fit in 539 00:30:03.928 --> 00:30:07.190 when we are aiming in short distance 540 00:30:07.190 --> 00:30:09.952 It is too big for small pace 541 00:30:09.952 --> 00:30:12.705 so let's make Indicator smaller 542 00:30:12.705 --> 00:30:14.772 In order to make Indicator smaller 543 00:30:14.772 --> 00:30:19.218 Set Scale to 0.1, 0.1, 0.1 544 00:30:19.218 --> 00:30:20.624 to make 545 00:30:20.624 --> 00:30:22.554 Indicator 546 00:30:22.554 --> 00:30:25.445 10cm long 547 00:30:25.445 --> 00:30:27.257 Now it is very small 548 00:30:27.257 --> 00:30:30.277 we need to get real close to see it 549 00:30:30.277 --> 00:30:34.624 anyway, 10cm long, by setting to 0.1, 0.1, 0.1 550 00:30:34.624 --> 00:30:37.426 we made 10cm-long 551 00:30:37.426 --> 00:30:40.624 Indicator blueprint file 552 00:30:40.624 --> 00:30:43.762 Compile and save it 553 00:30:43.762 --> 00:30:46.000 and close this settings window 554 00:30:48.000 --> 00:30:49.772 After close the window 555 00:30:49.772 --> 00:30:51.248 HunetPlayer 556 00:30:54.574 --> 00:30:56.089 let me change the name 557 00:30:56.089 --> 00:30:58.614 from HunetPlayer 558 00:30:58.614 --> 00:31:00.465 to HunetPlayerPawn 559 00:31:00.465 --> 00:31:02.762 Otherwise it could be confusing later 560 00:31:02.762 --> 00:31:04.891 whether this is Character or Pawn 561 00:31:04.891 --> 00:31:06.641 so I'll just name it 562 00:31:06.641 --> 00:31:08.634 as Pawn 563 00:31:08.634 --> 00:31:12.000 So open HunetPlayerPawn settings window 564 00:31:13.406 --> 00:31:18.802 Recognize floor on Event Tick first 565 00:31:18.802 --> 00:31:22.871 and if there is recognized floor on the center of screen 566 00:31:22.871 --> 00:31:24.554 then we will indicate 567 00:31:24.554 --> 00:31:27.079 that Indictor on the floor which is recognized 568 00:31:27.079 --> 00:31:30.901 Therefore we need the value of the center of screen 569 00:31:30.901 --> 00:31:32.703 but resolutions are different 570 00:31:32.703 --> 00:31:35.307 depends on each phone 571 00:31:35.307 --> 00:31:39.000 so the center of resolution of our phone 572 00:31:39.000 --> 00:31:41.000 we are using right now 573 00:31:41.000 --> 00:31:43.891 it would be half of width of resolution, half pixel of resolution 574 00:31:43.891 --> 00:31:46.416 and half of height pixel 575 00:31:46.416 --> 00:31:48.267 to be the center of screen 576 00:31:48.267 --> 00:31:50.667 But we don't know what pixel 577 00:31:50.667 --> 00:31:52.782 width and height are now 578 00:31:52.782 --> 00:31:55.406 so we will get those values 579 00:31:55.406 --> 00:31:58.733 In order to get pixel values of phone 580 00:31:58.733 --> 00:32:01.188 right click 581 00:32:01.188 --> 00:32:04.841 Type get user settings 582 00:32:04.841 --> 00:32:06.337 Game User Settings 583 00:32:06.337 --> 00:32:09.887 and add 584 00:32:09.887 --> 00:32:11.049 GetGameUserSettings node 585 00:32:14.109 --> 00:32:18.089 Now we will get the resolution 586 00:32:18.089 --> 00:32:20.148 So here at Return Value 587 00:32:20.148 --> 00:32:23.000 type get resolution 588 00:32:23.000 --> 00:32:25.792 It is resolution 589 00:32:25.792 --> 00:32:29.178 Search get screen resolution 590 00:32:29.178 --> 00:32:31.778 then you will see there is 591 00:32:31.778 --> 00:32:34.238 Get Screen Resolution node 592 00:32:34.238 --> 00:32:38.337 You can get resolution values of screen 593 00:32:38.337 --> 00:32:42.544 And it would be consisted of X value and Y value 594 00:32:42.544 --> 00:32:46.000 We will save these values 595 00:32:46.000 --> 00:32:48.654 Drag this 596 00:32:48.654 --> 00:32:53.257 type promote to variable to save it as variable 597 00:32:53.257 --> 00:32:56.000 and set it 598 00:32:56.000 --> 00:32:57.000 like this 599 00:32:57.000 --> 00:33:02.000 The name of variable is set to NewVar 600 00:33:02.000 --> 00:33:04.000 Let's change it on Details panel 601 00:33:04.000 --> 00:33:07.554 On Details panel, Variable Name here 602 00:33:07.554 --> 00:33:10.804 name it ScreenRes 603 00:33:10.804 --> 00:33:13.356 for Screen Resolution 604 00:33:13.356 --> 00:33:15.772 So the size of screen 605 00:33:15.772 --> 00:33:21.000 And then compile and save it 606 00:33:21.000 --> 00:33:23.850 Then it is saved 607 00:33:23.850 --> 00:33:25.267 in the name of ScreenRes now 608 00:33:25.267 --> 00:33:28.911 On this Get All GR Geometries 609 00:33:31.653 --> 00:33:37.337 if you search Line Trace 610 00:33:37.337 --> 00:33:40.436 You would find Line Trace Tracked Objects 611 00:33:40.436 --> 00:33:42.742 Line Trace Tracked Objects 612 00:33:42.742 --> 00:33:44.792 Line Trace Tracked Objects detects 613 00:33:44.792 --> 00:33:47.673 with Line Trace 614 00:33:47.693 --> 00:33:52.208 what I'm tracing right now 615 00:33:52.208 --> 00:33:54.436 So use Line Trace Tracked Objects 616 00:33:54.436 --> 00:34:00.852 from specific location of screen 617 00:34:00.852 --> 00:34:05.485 shoot Line Trace if there are 618 00:34:05.485 --> 00:34:08.000 geometries recognized there 619 00:34:08.000 --> 00:34:10.000 Unlike Line Trace shooting from World 620 00:34:10.000 --> 00:34:11.921 we shoot it from camera 621 00:34:11.921 --> 00:34:14.139 so it is a bit different function 622 00:34:14.139 --> 00:34:16.439 in terms of shooting Line Trace 623 00:34:16.439 --> 00:34:18.604 by analyzing image of real world 624 00:34:18.604 --> 00:34:20.158 So the ScreenRes 625 00:34:20.158 --> 00:34:21.584 that we saved earlier 626 00:34:21.584 --> 00:34:24.614 Get this Screen Res value 627 00:34:24.614 --> 00:34:28.000 and pass it into here 628 00:34:28.000 --> 00:34:31.150 but if we just pass it 629 00:34:31.150 --> 00:34:32.861 then the resolution itself will be passed 630 00:34:32.861 --> 00:34:35.683 so it would be right bottom corner 631 00:34:35.683 --> 00:34:37.283 Half and half 632 00:34:37.283 --> 00:34:40.624 In order to make it half of width and height 633 00:34:40.624 --> 00:34:44.218 Use split to separate 634 00:34:44.218 --> 00:34:48.059 And multiply each value 635 00:34:48.059 --> 00:34:50.485 So Multiply node 636 00:34:50.485 --> 00:34:53.535 First, change this to Float 637 00:34:53.535 --> 00:34:57.000 and set it to 0.5 638 00:34:57.000 --> 00:34:59.000 Multiply 0.5 639 00:34:59.000 --> 00:35:05.228 And connect to another Multiply node 640 00:35:05.228 --> 00:35:10.000 and change this to Float Single 641 00:35:10.000 --> 00:35:14.000 and set 0.5 to it 642 00:35:16.495 --> 00:35:23.802 Therefore split the half values of width and height of resolution 643 00:35:23.802 --> 00:35:28.000 and connect to each Screen Coord 644 00:35:28.000 --> 00:35:31.750 X to X, Y to Y 645 00:35:31.750 --> 00:35:34.000 pass them in this way 646 00:35:39.317 --> 00:35:43.337 And Line Trace Tracked Objects 647 00:35:43.337 --> 00:35:45.000 there may or may not be it 648 00:35:45.000 --> 00:35:49.238 Center of screen 649 00:35:49.238 --> 00:35:53.851 may or may not point at plane 650 00:35:53.851 --> 00:35:58.000 Therefore we need to check 651 00:35:58.000 --> 00:36:00.654 whether there is object we are pointing at plane 652 00:36:00.654 --> 00:36:04.931 So the length of this array is 653 00:36:09.782 --> 00:36:11.693 greater than 0 654 00:36:11.693 --> 00:36:14.851 Then if it is greater than 0, then there are one or more 655 00:36:14.851 --> 00:36:17.337 which means something is detected 656 00:36:17.337 --> 00:36:22.327 If this value is True 657 00:36:22.327 --> 00:36:24.763 on Branch node, if greater than 0 is True 658 00:36:24.763 --> 00:36:29.089 it means there are one or more plane is recognized 659 00:36:29.089 --> 00:36:32.376 So if there are one or more recognized plane 660 00:36:32.376 --> 00:36:37.703 get value of index 0 from array 661 00:36:37.703 --> 00:36:40.475 using Get node as reference 662 00:36:40.475 --> 00:36:44.317 The first one of array, most of the time 663 00:36:44.317 --> 00:36:47.386 there won't be more than two recognized planes 664 00:36:47.386 --> 00:36:52.000 So get first recognized plane 665 00:36:52.000 --> 00:36:54.396 And get one location value from it 666 00:36:54.396 --> 00:36:58.693 Type get local to world transform 667 00:36:58.693 --> 00:37:01.871 to convert local coordinate 668 00:37:01.871 --> 00:37:06.485 of recognized plane to world coordinate 669 00:37:06.485 --> 00:37:10.485 So convert coordinate of plane we recognized 670 00:37:10.485 --> 00:37:13.228 to world coordinate 671 00:37:13.228 --> 00:37:16.733 and in accordance with it's location and rotation values 672 00:37:16.733 --> 00:37:19.515 we will generate Indicator 673 00:37:19.515 --> 00:37:22.188 Therefore if it is True 674 00:37:22.188 --> 00:37:29.198 type spawn actor from class 675 00:37:29.198 --> 00:37:30.495 to add 676 00:37:30.495 --> 00:37:33.247 Spawn Actor node 677 00:37:33.247 --> 00:37:35.416 Which class would that be? 678 00:37:35.416 --> 00:37:39.228 BP_Indicator 679 00:37:39.228 --> 00:37:42.554 BP_Indicator we created earlier 680 00:37:42.554 --> 00:37:44.802 we will generate this 681 00:37:44.802 --> 00:37:48.673 BP_Indicator 682 00:37:48.673 --> 00:37:51.733 In terms of Spawn Transform 683 00:37:51.733 --> 00:37:56.515 right click and select Split struct pin 684 00:37:56.515 --> 00:37:58.266 Location, Rotation, Scale 685 00:37:58.266 --> 00:38:01.356 then it splits into these three 686 00:38:01.356 --> 00:38:05.544 And this value, plain we recognized 687 00:38:05.544 --> 00:38:07.386 if we split this 688 00:38:07.386 --> 00:38:09.683 it will be split into 689 00:38:09.683 --> 00:38:11.366 Location, Rotation and Scale as well 690 00:38:11.366 --> 00:38:14.000 The reason I split it is 691 00:38:14.000 --> 00:38:18.257 to match location in accordance with recognized plane 692 00:38:18.257 --> 00:38:21.653 and match rotation in accordance with direction of rotation 693 00:38:21.653 --> 00:38:24.069 since the flat surface could be slope a bit 694 00:38:24.069 --> 00:38:28.000 so match the direction of rotation and all 695 00:38:28.000 --> 00:38:31.416 but I won't reflect Scale 696 00:38:31.416 --> 00:38:34.950 Because if the recognized target 697 00:38:34.950 --> 00:38:36.465 do Scale as well 698 00:38:36.465 --> 00:38:39.079 then the value of Scale we set before 699 00:38:39.079 --> 00:38:42.485 could be ruined 700 00:38:52.257 --> 00:38:54.129 In terms of Transform Scale 701 00:38:54.129 --> 00:38:57.683 we will keep it as 1 702 00:38:57.683 --> 00:39:00.445 So no matter how far 703 00:39:00.445 --> 00:39:01.505 or close it reflects 704 00:39:01.505 --> 00:39:04.247 if you want its size to be even 705 00:39:04.247 --> 00:39:06.535 you can split it like this 706 00:39:06.535 --> 00:39:09.198 And if you want the size of Indicator decrease when it is far 707 00:39:09.198 --> 00:39:12.238 and increase when it is close 708 00:39:12.238 --> 00:39:15.020 if you want it to be in accordance with the distance 709 00:39:15.020 --> 00:39:17.295 then you can connect Scale 710 00:39:17.295 --> 00:39:18.642 to here like this 711 00:39:18.642 --> 00:39:21.822 But now, I'll force the scale to 1 712 00:39:21.822 --> 00:39:24.950 to make the size of Indicator 713 00:39:24.950 --> 00:39:29.594 is always even for your practice 714 00:39:29.594 --> 00:39:33.228 To make it able to be spawned unconditionally when it spawn 715 00:39:33.228 --> 00:39:35.139 set it to Always Spawn 716 00:39:38.000 --> 00:39:40.634 Now compile and save it 717 00:39:40.634 --> 00:39:42.455 and let's test it 718 00:39:44.099 --> 00:39:48.607 Before that, let me make something important clear 719 00:39:48.607 --> 00:39:51.228 We are getting the values of resolution 720 00:39:51.228 --> 00:39:53.535 But these values 721 00:39:53.535 --> 00:39:57.614 we can not get these values as soon as app starts 722 00:39:57.614 --> 00:40:03.171 Because even if app has been started 723 00:40:03.171 --> 00:40:05.971 it takes physical times 724 00:40:05.971 --> 00:40:08.360 to read values of machine 725 00:40:08.360 --> 00:40:11.760 and little bit slow for phone 726 00:40:11.760 --> 00:40:15.360 give some delay value before here 727 00:40:15.360 --> 00:40:18.560 to give machine enough time 728 00:40:18.560 --> 00:40:21.160 to spend and read values 729 00:40:21.160 --> 00:40:23.480 and get Game User Settings 730 00:40:23.480 --> 00:40:25.480 And get values of resolution 731 00:40:25.480 --> 00:40:28.830 So I will give Duration here 732 00:40:28.830 --> 00:40:31.879 It is set to 0.2 as default 733 00:40:31.879 --> 00:40:35.229 and yes, I think 0.2 seconds would be enough 734 00:40:35.229 --> 00:40:38.329 Delay for 0.2 seconds 735 00:40:38.329 --> 00:40:39.929 then read data 736 00:40:39.929 --> 00:40:43.480 Read resolution data of your phone 737 00:40:43.480 --> 00:40:47.880 So compile and save it 738 00:40:47.880 --> 00:40:50.403 and package once more 739 00:40:50.403 --> 00:40:52.560 For the test 740 00:40:52.560 --> 00:40:56.060 still in the same folder, in Packages folder 741 00:40:56.060 --> 00:40:57.804 let's package it here 742 00:41:00.919 --> 00:41:03.919 Once packaging is done, then 743 00:41:03.919 --> 00:41:05.975 let's install on your phone again 744 00:41:09.400 --> 00:41:14.341 Copy apk file from Packages folder 745 00:41:14.341 --> 00:41:19.172 and delete exist file 746 00:41:21.478 --> 00:41:25.256 in your phone and paste this 747 00:41:29.080 --> 00:41:32.025 Now then unlock your phone 748 00:41:34.839 --> 00:41:37.136 and install file in My Files 749 00:41:39.879 --> 00:41:41.385 update this 750 00:41:43.760 --> 00:41:44.866 once again 751 00:41:50.919 --> 00:41:53.515 And start it when it's finished 752 00:41:57.199 --> 00:41:59.060 Now then you would be able to see 753 00:41:59.060 --> 00:42:01.160 Indicator at the center of screen 754 00:42:01.160 --> 00:42:03.310 It is recognized well enough 755 00:42:03.310 --> 00:42:05.697 but problem is that Indicator 756 00:42:05.697 --> 00:42:07.847 is remaining and stacking 757 00:42:07.847 --> 00:42:12.836 It is generated every Tick and it covers the screen gradually 758 00:42:17.051 --> 00:42:21.153 Generate object in accordance with slope of floor 759 00:42:22.496 --> 00:42:26.600 So come back to HunetPlayerPawn 760 00:42:26.600 --> 00:42:28.950 and let's edit little here 761 00:42:28.950 --> 00:42:32.500 Whenever it is recognized 762 00:42:32.500 --> 00:42:35.119 and there in recognized plane every Tick 763 00:42:35.119 --> 00:42:36.747 it should not generate unconditionally 764 00:42:39.600 --> 00:42:41.952 let's make this variable 765 00:42:41.952 --> 00:42:45.413 make generated Indicator to variable first 766 00:42:49.867 --> 00:42:51.415 The name of this variable 767 00:42:53.960 --> 00:43:00.360 I will name it IndicatorRef 768 00:43:00.360 --> 00:43:02.004 Ref for Reference 769 00:43:02.004 --> 00:43:04.054 make a variable 770 00:43:04.054 --> 00:43:06.504 named IndicatorRef 771 00:43:06.504 --> 00:43:09.688 Compile it 772 00:43:09.688 --> 00:43:13.638 Once it spawn then save it 773 00:43:13.638 --> 00:43:18.160 to variable IndicatorRef, so at first 774 00:43:18.160 --> 00:43:21.010 shoot from Line Trace of the center of screen 775 00:43:21.010 --> 00:43:23.710 and if it hit to recognized plane 776 00:43:23.710 --> 00:43:25.610 rather than generating it unconditionally 777 00:43:25.610 --> 00:43:27.880 but it will be checked once more 778 00:43:27.880 --> 00:43:30.380 Move this below like this 779 00:43:30.380 --> 00:43:32.780 If this is True 780 00:43:32.780 --> 00:43:35.320 the IndicatorRef 781 00:43:35.320 --> 00:43:36.889 we will check this one more time 782 00:43:36.889 --> 00:43:40.100 To see whether there actually is value in it 783 00:43:40.100 --> 00:43:43.987 add one is Valid node 784 00:43:43.987 --> 00:43:47.917 and connect True here 785 00:43:50.000 --> 00:43:54.800 So that whether there is something assigned to Indicator variable or not 786 00:43:54.800 --> 00:43:58.399 If not we needs to generate it 787 00:43:58.399 --> 00:44:01.969 And assign it to variable 788 00:44:01.969 --> 00:44:03.657 That's what we will do when there is not 789 00:44:07.279 --> 00:44:13.749 If there is generated one already 790 00:44:13.749 --> 00:44:18.249 then, on IndicatorRef 791 00:44:18.249 --> 00:44:23.440 use Set Actor Transform 792 00:44:23.440 --> 00:44:25.740 to change Transform 793 00:44:25.740 --> 00:44:28.959 And update location and rotation 794 00:44:28.959 --> 00:44:33.175 Split Transform 795 00:44:37.816 --> 00:44:42.359 And move these to organize 796 00:44:42.359 --> 00:44:46.091 So pass this Location value 797 00:44:46.091 --> 00:44:48.935 and Rotation value as well 798 00:44:52.679 --> 00:44:56.629 Let me organize lines since it's too messy 799 00:44:56.629 --> 00:44:59.516 set things like this 800 00:45:03.783 --> 00:45:06.983 and set new value 801 00:45:06.983 --> 00:45:09.040 to Location and Rotation 802 00:45:09.040 --> 00:45:13.213 Therefore if Indicator already exist, then change location 803 00:45:13.213 --> 00:45:17.963 and if not, then generate Indicator 804 00:45:17.963 --> 00:45:19.519 and assign it to variable 805 00:45:19.519 --> 00:45:23.011 By doing like this can prevent for Indicator 806 00:45:23.011 --> 00:45:25.399 to be generated every Tick 807 00:45:25.399 --> 00:45:28.199 Compile and save it 808 00:45:28.199 --> 00:45:30.499 and package one more time 809 00:45:30.499 --> 00:45:33.559 to check it 810 00:45:33.559 --> 00:45:35.066 Copy this 811 00:45:38.040 --> 00:45:44.600 And reinstall on your phone 812 00:45:44.600 --> 00:45:45.794 Update it 813 00:45:49.359 --> 00:45:52.178 And start when it's finished to be installed 814 00:45:56.527 --> 00:45:59.760 Now then how does it look like when it recognize plane 815 00:45:59.760 --> 00:46:03.260 In accordance with plane 816 00:46:03.260 --> 00:46:05.610 you can see it is recognized 817 00:46:05.610 --> 00:46:07.440 as it indicate that here center is flat surface 818 00:46:07.440 --> 00:46:09.413 If you point at somewhere not plane 819 00:46:09.413 --> 00:46:12.519 then it rotates while trying to find plane 820 00:46:12.519 --> 00:46:15.679 Try to rotate in accordance with surface 821 00:46:15.679 --> 00:46:18.279 It doesn't recognize wall yet 822 00:46:18.279 --> 00:46:20.929 since it doesn't recognize wall 823 00:46:20.929 --> 00:46:22.959 Indicator does not stick out well 824 00:46:22.959 --> 00:46:28.359 But you can see here is recognized well 825 00:46:28.359 --> 00:46:31.759 So now we recognize plane 826 00:46:31.759 --> 00:46:35.809 and indicate object on that recognized plane 827 00:46:35.809 --> 00:46:38.399 these are what we have done 828 00:46:38.399 --> 00:46:41.099 From now on, change a variety of 829 00:46:41.099 --> 00:46:46.099 objects other than Indicator 830 00:46:46.099 --> 00:46:47.899 and edit blueprint file 831 00:46:47.899 --> 00:46:51.788 to try to install various objects 832 00:46:52.720 --> 00:46:56.679 Let's put together what we learned in this lesson 833 00:46:56.679 --> 00:46:59.329 First, in order to use AR function 834 00:46:59.329 --> 00:47:01.329 we practiced to create new Level 835 00:47:01.329 --> 00:47:04.388 and the process to create GameModeBase class 836 00:47:04.388 --> 00:47:06.720 and PlayerPawn class 837 00:47:06.720 --> 00:47:10.041 Second, used Line Trace Tracked Objects node 838 00:47:10.041 --> 00:47:13.679 which is specifically designed for AR 839 00:47:13.679 --> 00:47:16.527 to fire Line Trace on specific pixel location 840 00:47:16.527 --> 00:47:18.477 of phone screen 841 00:47:18.477 --> 00:47:20.527 and implemented function 842 00:47:20.527 --> 00:47:23.480 detects if it is flat surface where Line Trace was hit 843 00:47:23.480 --> 00:47:27.630 Last, created Indicator Actor indicates location 844 00:47:27.630 --> 00:47:30.130 and direction of recognized plane 845 00:47:30.130 --> 00:47:34.230 and created Actor in accordance with floor which is actually recognized 846 00:47:34.230 --> 00:47:36.184 through phone camera 847 00:47:36.686 --> 00:47:38.686 Recognition of floor on real world create Level and Pawn Class for AR 848 00:47:38.686 --> 00:47:40.686 AR Session which synchronize with lifecycles of Unreal Engine and camera needs to be set for AR 849 00:47:40.686 --> 00:47:42.686 Set Session Type to World for plane recognition Set World Alignment to Gravity to align the direction of gravity 850 00:47:42.686 --> 00:47:44.662 Uncheck Vertical Plane Detection to make it recognize only for horizontal flat surface 851 00:47:44.662 --> 00:47:46.662 Function to prevent standby mode and get resolution information Prevent standby mode 852 00:47:46.662 --> 00:47:48.662 Drag execution pin from Start AR Session to Control Screensaver and uncheck Allow Screen Saver 853 00:47:48.662 --> 00:47:50.662 Function to get resolution information Add Game User Settings node to get center pixel coordinate of screen 854 00:47:50.662 --> 00:47:52.641 Half value of X, Y of variable ScreenRes to each socket of Screen Coord Check with Branch node whether there is recognized plane or not 855 00:47:52.641 --> 00:47:56.591 Generate object in accordance with slope of floor Create Actor on the location of actually recognized plane need to make generated Indicator to variable iwhen Indicators keep generated on plane 856 00:47:56.591 --> 00:47:58.591 Connect IndicatorRef to SpawnActor BP Indicator Add is Valid node to check whether it has actual value or not 857 00:47:58.591 --> 00:48:00.551 If value exist, use Set Actor Transform to update Location and Rotation of IndicatorRef