WEBVTT 1 00:00:05.722 --> 00:00:09.890 Game Advanced Prototype 1 2 00:00:09.890 --> 00:00:12.091 GCC Academy 3 00:00:28.159 --> 00:00:28.958 Hello 4 00:00:28.958 --> 00:00:31.780 This is Youngho Lee for shooting game production 5 00:00:31.780 --> 00:00:34.299 Creating a game with Unity 6 00:00:34.299 --> 00:00:36.419 includes board games, shooting games 7 00:00:36.419 --> 00:00:40.459 FPS and TPS games 8 00:00:40.459 --> 00:00:43.259 and MMORPG games as well 9 00:00:43.259 --> 00:00:47.500 so variety of 2D or 3D games 10 00:00:47.500 --> 00:00:49.860 Making all these games of various genres 11 00:00:49.860 --> 00:00:52.700 means that there must be a virtual world 12 00:00:52.700 --> 00:00:54.740 simulated 13 00:00:54.740 --> 00:00:56.660 In shooting game production 14 00:00:56.660 --> 00:00:58.810 we will learn about mechanics and vector 15 00:00:58.810 --> 00:01:01.540 to create that virtual world 16 00:01:01.540 --> 00:01:04.860 and will create a shooting game 17 00:01:04.860 --> 00:01:06.739 Starting a project 18 00:01:06.739 --> 00:01:10.699 will be done in a practical way 19 00:01:10.699 --> 00:01:12.779 First, we'll separate the prototype version 20 00:01:12.779 --> 00:01:16.580 into four steps that create the core content of the game 21 00:01:16.580 --> 00:01:18.540 Then on alpha version 22 00:01:18.540 --> 00:01:21.220 to have all production elements included 23 00:01:21.220 --> 00:01:23.739 it will be done in two steps 24 00:01:23.739 --> 00:01:25.580 Lastly in beta version 25 00:01:25.580 --> 00:01:29.500 we will learn about the optimization and management of games 26 00:01:29.500 --> 00:01:32.220 Through this 3 step production process 27 00:01:32.220 --> 00:01:37.260 you'll get familiar with the overall project production process 28 00:01:37.260 --> 00:01:39.220 Let's first learn prototype 1 29 00:01:39.220 --> 00:01:42.099 for shooting game production 30 00:01:42.099 --> 00:01:44.339 In this unit 31 00:01:44.339 --> 00:01:45.820 we'll create a project 32 00:01:45.820 --> 00:01:49.580 and learn how to set that made project 33 00:01:49.580 --> 00:01:51.220 And major game objects 34 00:01:51.220 --> 00:01:54.459 that is, camera, lighting, and player 35 00:01:54.459 --> 00:01:57.180 will be made and we'll learn how to set them 36 00:01:57.180 --> 00:02:00.620 Lastly, in Unity Engine 37 00:02:00.620 --> 00:02:02.699 and main life cycle function 38 00:02:02.699 --> 00:02:03.860 and main life cycle function 39 00:02:04.491 --> 00:02:08.435 Project Production and Environment Setting 40 00:02:09.860 --> 00:02:11.539 Let's get started with 41 00:02:11.539 --> 00:02:15.419 project production and environment settings 42 00:02:15.419 --> 00:02:17.117 First open up Unity Hub 43 00:02:18.820 --> 00:02:20.834 and let's create a new project here 44 00:02:25.269 --> 00:02:26.660 We're currently 45 00:02:26.660 --> 00:02:33.619 creating a project with the 2022.3.49f1 version 46 00:02:33.619 --> 00:02:36.419 Here, we'll do basic project 47 00:02:36.419 --> 00:02:38.100 3D (Built-In Render Pipeline) 48 00:02:38.100 --> 00:02:39.500 Select this one 49 00:02:39.500 --> 00:02:44.699 and name that project Shooting 50 00:02:44.699 --> 00:02:47.979 Click on create project to create 51 00:02:57.740 --> 00:03:02.020 Once a Unity project is made 52 00:03:02.020 --> 00:03:04.300 it will load the necessary resources 53 00:03:04.300 --> 00:03:07.259 and compile 54 00:03:07.259 --> 00:03:08.779 Once it's made like this 55 00:03:08.779 --> 00:03:11.539 let's set the environment of this project 56 00:03:11.539 --> 00:03:13.675 First of all 57 00:03:13.675 --> 00:03:15.100 my screen looks like this 58 00:03:15.100 --> 00:03:17.020 which is how I organized it 59 00:03:17.020 --> 00:03:19.539 but your screen will have it 60 00:03:19.539 --> 00:03:21.820 like this by default 61 00:03:21.820 --> 00:03:25.660 This, from layout here 62 00:03:25.660 --> 00:03:28.899 click on the button 2 by 3 63 00:03:28.899 --> 00:03:30.940 and then the screen will look like this 64 00:03:30.940 --> 00:03:32.460 The layout has changed 65 00:03:32.460 --> 00:03:35.259 Hierarchy, Project, Inspector 66 00:03:35.259 --> 00:03:38.020 Here I'll drag the 67 00:03:38.020 --> 00:03:39.539 project tab 68 00:03:39.539 --> 00:03:41.259 to put it down here 69 00:03:41.259 --> 00:03:44.380 Put it under hierarchy 70 00:03:44.380 --> 00:03:47.802 Let me push this one a little and put it like this 71 00:03:50.129 --> 00:03:53.220 to make the layout neater 72 00:03:53.220 --> 00:03:56.820 Then on the left, we have the scene window 73 00:03:56.820 --> 00:03:59.059 and under that is the game window 74 00:03:59.059 --> 00:04:01.860 In the middle, hierarchy, and under that, project 75 00:04:01.860 --> 00:04:02.820 And lastly 76 00:04:02.820 --> 00:04:05.419 the inspector window 77 00:04:05.419 --> 00:04:08.860 This is how I'll have the layout be 78 00:04:08.860 --> 00:04:12.339 Then now we'll do a shooting project 79 00:04:12.339 --> 00:04:15.220 let's start with a 2D mode 80 00:04:15.220 --> 00:04:17.779 We're not actually making a 2D project 81 00:04:17.779 --> 00:04:22.660 but we'll expand from this 82 00:04:22.660 --> 00:04:25.059 like making a 3D project from a 2D project 83 00:04:25.059 --> 00:04:29.179 so let's start from here 84 00:04:29.179 --> 00:04:31.700 First, on the scene window 85 00:04:31.700 --> 00:04:34.299 switch that to 2D mode 86 00:04:34.299 --> 00:04:36.779 you can click on the 2D button 87 00:04:36.779 --> 00:04:39.100 but this way 88 00:04:39.100 --> 00:04:40.420 it might bother us during other parts of the production 89 00:04:40.420 --> 00:04:44.019 So don't click on the 2D button 90 00:04:44.019 --> 00:04:49.779 and instead on the top right 91 00:04:49.779 --> 00:04:51.299 there is Gizmos 92 00:04:51.299 --> 00:04:53.859 With that Gizmos 93 00:04:53.859 --> 00:04:55.980 Here it says persp 94 00:04:55.980 --> 00:04:57.899 which is short for perspective 95 00:04:57.899 --> 00:05:02.619 Click on this and change it to Iso mode 96 00:05:02.619 --> 00:05:08.019 Here there are X, Y, Z 97 00:05:08.019 --> 00:05:11.859 X, Y, Z 98 00:05:11.859 --> 00:05:14.019 There are these three axes 99 00:05:14.019 --> 00:05:18.179 Click on this and the Iso part 100 00:05:18.179 --> 00:05:19.820 will change 101 00:05:19.820 --> 00:05:21.220 Let's try 102 00:05:21.220 --> 00:05:24.940 Click on x and it changes to right 103 00:05:24.940 --> 00:05:27.459 Click on y and it changes to top 104 00:05:27.459 --> 00:05:30.220 and click on z and it will change to front 105 00:05:30.220 --> 00:05:32.859 2D mode is looking from the back 106 00:05:32.859 --> 00:05:35.380 so we'll have back mode 107 00:05:35.380 --> 00:05:39.540 I'll click the part 108 00:05:39.540 --> 00:05:42.980 opposite from z 109 00:05:42.980 --> 00:05:45.814 This is front so the back 110 00:05:45.814 --> 00:05:47.140 will obviously be here that you need to click 111 00:05:47.140 --> 00:05:51.420 Then it changes to back 112 00:05:51.420 --> 00:05:55.859 and there are Iso mode lines, three of them 113 00:05:55.859 --> 00:05:58.940 Then the perspective mode 114 00:05:58.940 --> 00:06:00.820 shows depth perception 115 00:06:00.820 --> 00:06:02.500 So when an object is in front it looks big 116 00:06:02.500 --> 00:06:04.899 and when it's far then it looks small 117 00:06:04.899 --> 00:06:06.401 When the object is behind there 118 00:06:06.401 --> 00:06:08.500 it will look small like this 119 00:06:08.500 --> 00:06:11.900 But these three Iso 120 00:06:11.900 --> 00:06:13.779 are Isometric view 121 00:06:13.779 --> 00:06:16.980 This is used in 2D mode production 122 00:06:16.980 --> 00:06:18.930 Usually 2D mode 123 00:06:18.930 --> 00:06:21.700 is expressed using only two axes 124 00:06:21.700 --> 00:06:23.980 We call this two axes ones 125 00:06:23.980 --> 00:06:25.940 orthopraphic 126 00:06:25.940 --> 00:06:28.540 and there is no depth 127 00:06:28.540 --> 00:06:31.299 Since there's no depth there is obviously no perspective 128 00:06:31.299 --> 00:06:32.997 So in 2D mode, we have it like this 129 00:06:32.997 --> 00:06:34.420 and work on it 130 00:06:34.420 --> 00:06:36.579 The 2D button here 131 00:06:36.579 --> 00:06:39.899 If you click on that, it only gets rid of the Gizmos 132 00:06:39.899 --> 00:06:42.579 the screen actually looks the same 133 00:06:42.579 --> 00:06:44.677 Let's me close the 2D mode again 134 00:06:46.459 --> 00:06:48.874 and work on it like this 135 00:06:49.897 --> 00:06:53.876 Camera and Lighting Placement & Player Object and Script Production 136 00:06:57.540 --> 00:07:02.403 Next we'll see camera and lighting placement 137 00:07:06.828 --> 00:07:09.059 On the screen, on hierarchy 138 00:07:09.059 --> 00:07:11.859 there are main camera and directional light 139 00:07:11.859 --> 00:07:14.980 We're in 2D mode so here, camera 140 00:07:14.980 --> 00:07:17.540 and directional light, these two are here 141 00:07:17.540 --> 00:07:19.790 The light part 142 00:07:19.790 --> 00:07:23.779 might not be needed for 2D 143 00:07:23.779 --> 00:07:25.940 The recently added Unity feature 144 00:07:25.940 --> 00:07:29.019 provides a function where light is applied in 2D mode 145 00:07:29.019 --> 00:07:30.940 but this is only when advanced features are used 146 00:07:30.940 --> 00:07:33.166 and in basic 2D, we do not need lighting that much 147 00:07:35.700 --> 00:07:39.509 First let's set the main camera 148 00:07:41.459 --> 00:07:44.906 The camera has perspective now 149 00:07:44.906 --> 00:07:49.019 I'll change it back to perspective mode 150 00:07:49.019 --> 00:07:53.220 Click here 151 00:07:53.220 --> 00:07:56.311 And when you select 152 00:07:56.311 --> 00:07:57.296 camera 153 00:07:59.820 --> 00:08:01.170 you can see 154 00:08:01.170 --> 00:08:03.205 I'll move a little faster 155 00:08:05.680 --> 00:08:08.100 Like this, a trapezoid 156 00:08:08.100 --> 00:08:10.430 shows up, right? 157 00:08:10.430 --> 00:08:13.019 It has this trapezoid shape 158 00:08:13.019 --> 00:08:14.569 From the side 159 00:08:17.291 --> 00:08:18.899 it has this shape 160 00:08:18.899 --> 00:08:21.140 Right? Like this 161 00:08:21.140 --> 00:08:25.179 Let's go back to 2D mode 162 00:08:25.179 --> 00:08:27.484 It'll look like this in 2D mode 163 00:08:31.956 --> 00:08:33.539 We call this part 164 00:08:33.539 --> 00:08:35.299 View Flow Stem 165 00:08:35.299 --> 00:08:38.099 and when we're expressing perspective 166 00:08:38.099 --> 00:08:40.940 it has this trapezoid shape 167 00:08:40.940 --> 00:08:42.900 Right? A trapezoid 168 00:08:42.900 --> 00:08:45.900 But we're going to work on it on 2D mode 169 00:08:45.900 --> 00:08:47.780 so this must change 170 00:08:47.780 --> 00:08:49.539 Once you've selected main camera 171 00:08:49.539 --> 00:08:52.140 on the right's inspector window 172 00:08:52.140 --> 00:08:56.020 we will be able to edit the detailed properties of the main camera 173 00:08:56.020 --> 00:09:00.219 Among the components, there is camera component 174 00:09:00.219 --> 00:09:03.539 Here, projection 175 00:09:03.539 --> 00:09:07.580 is what let's us change the camera property 176 00:09:07.580 --> 00:09:09.780 Projection is there too 177 00:09:09.780 --> 00:09:12.880 3D is basically 178 00:09:12.880 --> 00:09:15.140 expressed on a 2D screen 179 00:09:15.140 --> 00:09:18.700 There is a flow that it follows 180 00:09:18.700 --> 00:09:22.059 which is the 3D rendering pipeline 181 00:09:22.059 --> 00:09:24.500 Here, this projection 182 00:09:24.500 --> 00:09:27.900 the 3d rendering pipeline 183 00:09:27.900 --> 00:09:30.979 goes through the process of projection 184 00:09:30.979 --> 00:09:34.140 and here we choose if the object 185 00:09:34.140 --> 00:09:36.340 will have perspective 186 00:09:36.340 --> 00:09:38.780 or not, so if it'll be 2D 187 00:09:38.780 --> 00:09:43.099 You can think of it as the camera having 188 00:09:43.099 --> 00:09:45.739 a 3D lens or a 2D lens 189 00:09:45.739 --> 00:09:48.380 You can see perspective here 190 00:09:48.380 --> 00:09:51.780 this is what expresses the perspective 191 00:09:51.780 --> 00:09:52.680 And on the bottom 192 00:09:52.680 --> 00:09:54.780 open this by clicking on the dropdown button 193 00:09:54.780 --> 00:09:56.460 and it says orthopraphic 194 00:09:56.460 --> 00:09:59.900 This is what changes it to orthogonal coordinate system 195 00:09:59.900 --> 00:10:02.940 Then on the screen 196 00:10:02.940 --> 00:10:05.500 with main camera 197 00:10:05.500 --> 00:10:09.419 it shows a rectangular shape, unlike before 198 00:10:09.419 --> 00:10:12.917 Change this to Iso 199 00:10:12.917 --> 00:10:14.780 to Isometric view 200 00:10:14.780 --> 00:10:17.900 it shows this rectangular shape 201 00:10:17.900 --> 00:10:23.468 Then this has a orthogonal coordinate system 202 00:10:23.468 --> 00:10:26.140 which is perspectiveless and 2D 203 00:10:26.140 --> 00:10:29.780 On the 2D scene, not only this 204 00:10:29.780 --> 00:10:32.140 but when we're making a 2D project 205 00:10:32.140 --> 00:10:34.265 the camera also has this content applied 206 00:10:35.478 --> 00:10:36.557 Get it? 207 00:10:36.557 --> 00:10:40.253 Let's work on it like this 208 00:10:41.659 --> 00:10:44.299 Next is directional light 209 00:10:44.299 --> 00:10:47.900 In 2D mode, we don't need lighting 210 00:10:47.900 --> 00:10:52.300 So let's deactivate 211 00:10:52.300 --> 00:10:56.380 the light component and turn it off for a second 212 00:10:56.380 --> 00:10:57.940 You can also erase this 213 00:10:57.940 --> 00:11:01.659 or just turn it off like I did 214 00:11:01.659 --> 00:11:05.780 then there will be no light 215 00:11:05.780 --> 00:11:09.940 Then it will show dark images 216 00:11:09.940 --> 00:11:12.059 So now let's work on 217 00:11:12.059 --> 00:11:15.659 how it could show the original object image colors 218 00:11:15.659 --> 00:11:17.362 by working on the settings 219 00:11:20.619 --> 00:11:24.900 When you go to the very bottom in window 220 00:11:24.900 --> 00:11:27.020 it says rendering here 221 00:11:27.020 --> 00:11:29.020 Window menu, rendering 222 00:11:29.020 --> 00:11:32.940 and there's also lighting 223 00:11:32.940 --> 00:11:37.059 Let's open that 224 00:11:37.059 --> 00:11:41.340 Then a lighting window appears 225 00:11:41.340 --> 00:11:43.990 First, we'll check if the auto generate 226 00:11:43.990 --> 00:11:46.419 is deactivated 227 00:11:46.419 --> 00:11:47.419 If this is checked 228 00:11:47.419 --> 00:11:49.739 every time we move an object 229 00:11:49.739 --> 00:11:52.299 There's this thing called lightmapping 230 00:11:52.299 --> 00:11:54.249 It's putting light on objects 231 00:11:54.249 --> 00:11:57.340 giving an effect of a screenshot 232 00:11:57.340 --> 00:11:59.659 but that takes a long time 233 00:11:59.659 --> 00:12:01.900 and in 2D, we don't need that 234 00:12:01.900 --> 00:12:04.921 so let's have that deactivated 235 00:12:07.020 --> 00:12:08.900 Next, here on environment 236 00:12:08.900 --> 00:12:12.340 click on the second tab 237 00:12:12.340 --> 00:12:16.140 Here, in the world we're working on 238 00:12:16.140 --> 00:12:18.739 there are three lights 239 00:12:18.739 --> 00:12:22.243 The basic light 240 00:12:22.243 --> 00:12:25.099 is directional light 241 00:12:25.099 --> 00:12:26.940 Directional Light 242 00:12:26.940 --> 00:12:28.487 Directional Light 243 00:12:32.140 --> 00:12:37.299 This is like sun rays 244 00:12:37.299 --> 00:12:39.380 Only one direction 245 00:12:39.380 --> 00:12:40.380 Can that happen? 246 00:12:40.380 --> 00:12:44.530 Sun shines light to everywhere 247 00:12:44.530 --> 00:12:46.299 360 degrees, no? 248 00:12:46.299 --> 00:12:49.979 But from the Earth's perspective 249 00:12:49.979 --> 00:12:52.136 if the sun is here 250 00:12:52.136 --> 00:12:54.859 we view it as there being just one direction that's coming to Earth 251 00:12:54.859 --> 00:12:58.179 So it's one direction for afar 252 00:12:58.179 --> 00:13:01.729 This directional light 253 00:13:01.729 --> 00:13:04.739 when there is a person on Earth here 254 00:13:04.739 --> 00:13:06.639 how close we get to the sun 255 00:13:06.639 --> 00:13:08.059 might not matter much 256 00:13:08.059 --> 00:13:11.509 Us getting 100m closer to the sun 257 00:13:11.509 --> 00:13:14.299 doesn't make the light or energy from the sun different 258 00:13:14.299 --> 00:13:16.649 Getting 1,000km closer 259 00:13:16.649 --> 00:13:18.140 doesn't make that big of a difference 260 00:13:18.140 --> 00:13:21.090 Since we are millions of kilometers apart from it 261 00:13:21.090 --> 00:13:22.539 it really does not matter much 262 00:13:22.539 --> 00:13:25.939 But what angle the sun is shining on Earth 263 00:13:25.939 --> 00:13:30.219 does influence us 264 00:13:30.219 --> 00:13:32.619 So this directional light 265 00:13:32.619 --> 00:13:35.820 is not related to location 266 00:13:35.820 --> 00:13:38.659 but is with direction 267 00:13:38.659 --> 00:13:40.179 It is related with direction 268 00:13:40.179 --> 00:13:42.260 It influences us 269 00:13:42.260 --> 00:13:45.219 Next, apart from this directional light 270 00:13:45.219 --> 00:13:48.500 there is also point light 271 00:13:48.500 --> 00:13:51.059 This point light 272 00:13:51.059 --> 00:13:53.209 literally puts this point as the center 273 00:13:53.209 --> 00:13:57.140 and the light spreads in 360 degrees 274 00:13:57.140 --> 00:14:00.020 An example of this 275 00:14:00.020 --> 00:14:02.059 is a torch 276 00:14:02.059 --> 00:14:04.619 When we light a torch 277 00:14:04.619 --> 00:14:08.870 the light spreads in 360 degrees with this as the origin 278 00:14:08.870 --> 00:14:12.619 Right? Normal lights that we have at home 279 00:14:12.619 --> 00:14:17.020 Those are all like this 280 00:14:17.020 --> 00:14:18.780 So this point light 281 00:14:18.780 --> 00:14:20.900 means light that spreads 360 degrees 282 00:14:20.900 --> 00:14:22.750 from the center object 283 00:14:22.750 --> 00:14:24.820 the light as the origin 284 00:14:24.820 --> 00:14:27.539 Next is spot light 285 00:14:27.539 --> 00:14:30.859 and this is light car's headlights 286 00:14:30.859 --> 00:14:34.099 If a car is like this 287 00:14:34.099 --> 00:14:37.900 it'll also have wheels 288 00:14:37.900 --> 00:14:39.299 and with the car like this 289 00:14:39.299 --> 00:14:44.020 there will be light spreading from this car 290 00:14:44.020 --> 00:14:48.859 These lights, strangely 291 00:14:48.859 --> 00:14:50.940 spread in a circular sector shape 292 00:14:50.940 --> 00:14:54.539 like this 293 00:14:54.539 --> 00:14:58.539 We call lights like the car headlights 294 00:14:58.539 --> 00:15:00.460 a spot light 295 00:15:00.460 --> 00:15:04.780 So there are three main types of lights 296 00:15:04.780 --> 00:15:07.739 and each of them have their own directions 297 00:15:07.739 --> 00:15:09.979 Direction light goes in one direction 298 00:15:09.979 --> 00:15:13.539 and for point light, location matters 299 00:15:13.539 --> 00:15:15.140 Location matters to it 300 00:15:15.140 --> 00:15:17.059 and the direction is 360 301 00:15:17.059 --> 00:15:19.140 Right? 302 00:15:19.140 --> 00:15:22.380 And spot light 303 00:15:22.380 --> 00:15:24.020 is like headlights 304 00:15:24.020 --> 00:15:26.500 Depending on how close this is 305 00:15:26.500 --> 00:15:29.260 it can shine brighter or less 306 00:15:29.260 --> 00:15:30.979 So location matters 307 00:15:30.979 --> 00:15:35.619 and will have only certain direction 308 00:15:35.619 --> 00:15:38.340 only certain angles 309 00:15:38.340 --> 00:15:39.059 Right? 310 00:15:39.059 --> 00:15:42.219 Anyways these three lights 311 00:15:42.219 --> 00:15:45.380 have the common property that they have directions 312 00:15:45.380 --> 00:15:46.716 Understand? 313 00:15:46.716 --> 00:15:48.310 They all have directions 314 00:15:51.260 --> 00:15:54.260 So then if there is light 315 00:15:54.260 --> 00:15:58.020 These lights with directions 316 00:15:58.020 --> 00:16:01.780 When affecting our objects 317 00:16:01.780 --> 00:16:03.140 Shining light like this 318 00:16:03.140 --> 00:16:07.020 As it hits a surface 319 00:16:07.020 --> 00:16:09.619 it will be reflected 320 00:16:09.619 --> 00:16:11.659 Depending on the type of reflection 321 00:16:11.659 --> 00:16:13.940 Depending on how it's reflected 322 00:16:13.940 --> 00:16:17.380 it can again divided into three types 323 00:16:17.380 --> 00:16:19.780 Of course, apart from directional light 324 00:16:19.780 --> 00:16:21.260 spot light, and point light 325 00:16:21.260 --> 00:16:25.780 there might be other lightings according to different engines 326 00:16:25.780 --> 00:16:28.380 But those are not existent in real life 327 00:16:28.380 --> 00:16:31.700 but just made in the engine 328 00:16:31.700 --> 00:16:33.580 But basically in real life 329 00:16:33.580 --> 00:16:36.020 there are these three types of light 330 00:16:36.020 --> 00:16:37.739 Then what I'm going to tell you now 331 00:16:37.739 --> 00:16:39.619 is when this light hits a surface 332 00:16:39.619 --> 00:16:41.659 depending on how it's reflected 333 00:16:41.659 --> 00:16:43.739 it can again be divided into three 334 00:16:43.739 --> 00:16:46.419 First, the surface looks smooth 335 00:16:46.419 --> 00:16:48.140 but it might actually 336 00:16:48.140 --> 00:16:51.179 be bumpy if you look closer 337 00:16:51.179 --> 00:16:53.700 Then when light hits it 338 00:16:53.700 --> 00:16:55.299 like this 339 00:16:55.299 --> 00:16:56.859 what would happen? 340 00:16:56.859 --> 00:17:00.539 When the light came in like this 341 00:17:00.539 --> 00:17:04.099 it will hit the surface head to head 342 00:17:04.099 --> 00:17:05.660 and here 343 00:17:05.660 --> 00:17:11.780 the light will be reflected like this 344 00:17:11.780 --> 00:17:14.819 Right? Since lights reflect on surfaces 345 00:17:14.819 --> 00:17:16.500 Got it? 346 00:17:16.500 --> 00:17:18.699 So when light comes in 347 00:17:18.699 --> 00:17:20.500 the surface looks smooth 348 00:17:20.500 --> 00:17:22.979 but if there's actually 349 00:17:22.979 --> 00:17:24.300 tiny bumps on it 350 00:17:24.300 --> 00:17:27.380 the light isn't just reflected simply like this 351 00:17:27.380 --> 00:17:28.900 but how does it go? 352 00:17:28.900 --> 00:17:33.900 Diffuse reflection happens 353 00:17:33.900 --> 00:17:36.150 Right? We call this diffuse reflection 354 00:17:36.150 --> 00:17:39.339 or diffuse light 355 00:17:39.339 --> 00:17:43.219 Diffuse light or diffuse reflection 356 00:17:43.219 --> 00:17:46.540 Diffuse in English 357 00:17:46.540 --> 00:17:48.339 Diffuse light 358 00:17:48.339 --> 00:17:50.180 So when light comes in 359 00:17:50.180 --> 00:17:52.420 these have this property 360 00:17:52.420 --> 00:17:54.300 so this part diffuses 361 00:17:54.300 --> 00:17:56.579 and the part behind becomes dark 362 00:17:56.579 --> 00:17:58.660 This part is dark 363 00:17:58.660 --> 00:18:01.420 Why? Light doesn't reach here 364 00:18:01.420 --> 00:18:04.739 Right? Let me move this a little bit 365 00:18:04.739 --> 00:18:06.979 What other light is there 366 00:18:06.979 --> 00:18:10.819 This is called diffuse light 367 00:18:10.819 --> 00:18:13.459 Light comes in and gets reflected 368 00:18:13.459 --> 00:18:15.859 Let's say we're actually looking at this 369 00:18:15.859 --> 00:18:18.660 Like this, right here 370 00:18:18.660 --> 00:18:20.819 and light comes in 371 00:18:20.819 --> 00:18:23.979 then gets reflected and reaches our eyes 372 00:18:23.979 --> 00:18:25.420 It bounces off and reaches our eyes 373 00:18:25.420 --> 00:18:27.420 Then what happens? 374 00:18:27.420 --> 00:18:29.780 We say 'oh it's so shiny!' 375 00:18:29.780 --> 00:18:30.900 Glaring 376 00:18:30.900 --> 00:18:32.420 In that case, the surface looks 377 00:18:32.420 --> 00:18:33.819 like this 378 00:18:33.819 --> 00:18:35.099 Something like this 379 00:18:35.099 --> 00:18:37.819 You've seen something like this right? 380 00:18:37.819 --> 00:18:39.739 These are what? 381 00:18:39.739 --> 00:18:41.859 Lights that directly reach our eyes after being reflected 382 00:18:41.859 --> 00:18:47.260 We call them specular 383 00:18:47.260 --> 00:18:50.900 In English, specular 384 00:18:50.900 --> 00:18:54.660 Specular 385 00:18:54.660 --> 00:18:58.808 Next is a basic reflective property of light 386 00:18:58.808 --> 00:19:00.332 It has the property of infinite reflection 387 00:19:00.332 --> 00:19:03.232 Let's say that the light didn't hit the object 388 00:19:03.232 --> 00:19:06.082 but the cloud up here 389 00:19:06.082 --> 00:19:09.480 There are clouds, then the light will bounce off of it 390 00:19:09.480 --> 00:19:11.912 then it will bounce off the ozone layer and come back down 391 00:19:11.912 --> 00:19:14.862 reflect again on the ground, then on a desk 392 00:19:14.862 --> 00:19:18.512 infinitely on this object and that 393 00:19:18.512 --> 00:19:19.639 It will keep bouncing off of objects 394 00:19:19.639 --> 00:19:21.589 When infinite reflection happens 395 00:19:21.589 --> 00:19:25.189 Then at some point, when there is an object here 396 00:19:25.189 --> 00:19:28.320 Right? Light comes this way 397 00:19:28.320 --> 00:19:31.420 and will reflect this part again 398 00:19:31.420 --> 00:19:33.270 Then at this moment 399 00:19:33.270 --> 00:19:36.080 if you look at the bottom of your desk 400 00:19:36.080 --> 00:19:39.380 even the parts that aren't lit by light will not be completely dark 401 00:19:39.380 --> 00:19:42.780 Right? It has light in darker colors 402 00:19:42.780 --> 00:19:44.929 We call this ambient 403 00:19:48.137 --> 00:19:51.387 When you're studying 404 00:19:51.387 --> 00:19:54.587 or trying to get good sleep 405 00:19:54.587 --> 00:19:57.759 you listen to ASMR 406 00:19:57.759 --> 00:20:01.359 A from that means ambient 407 00:20:01.359 --> 00:20:06.639 and A of ambient is the short for ambient 408 00:20:06.639 --> 00:20:07.797 Ambient 409 00:20:07.797 --> 00:20:09.331 It's an m here 410 00:20:12.097 --> 00:20:13.826 Ambient 411 00:20:13.826 --> 00:20:16.776 So with these three types of reflections 412 00:20:16.776 --> 00:20:18.876 three lights are combined 413 00:20:18.876 --> 00:20:21.026 and it shows the 414 00:20:21.026 --> 00:20:23.919 object like this 415 00:20:23.919 --> 00:20:27.019 Good? 416 00:20:27.019 --> 00:20:30.619 When we look at our screen 417 00:20:30.619 --> 00:20:33.480 if you go to lighting setting and to environment 418 00:20:33.480 --> 00:20:36.430 Here, ambient 419 00:20:36.430 --> 00:20:39.378 From there, source to skybox 420 00:20:39.378 --> 00:20:43.330 so the sky color reflected in the sky 421 00:20:43.330 --> 00:20:47.760 will be applied as the ambient light 422 00:20:47.760 --> 00:20:50.168 Hitting the object surface, the ground 423 00:20:50.168 --> 00:20:53.868 the part that affects the object 424 00:20:53.868 --> 00:20:56.353 We choose which one? Skybox 425 00:20:56.353 --> 00:20:59.403 Skybox, it says box here 426 00:20:59.403 --> 00:21:02.380 These days, there's also spheres 427 00:21:02.380 --> 00:21:03.919 instead of a box 428 00:21:03.919 --> 00:21:08.019 but here, you can just think of it as a cube since it's a box 429 00:21:08.019 --> 00:21:12.479 Then how is it? 430 00:21:12.479 --> 00:21:14.279 Since it's a cube, there are 6 sides 431 00:21:14.279 --> 00:21:16.979 We have combined the images here 432 00:21:16.979 --> 00:21:19.479 Then where do we put the user? 433 00:21:19.479 --> 00:21:21.960 In the middle of the object 434 00:21:21.960 --> 00:21:25.848 Inside this box, then it can make it looks like 435 00:21:25.848 --> 00:21:27.919 we're in this world 436 00:21:27.919 --> 00:21:29.719 This is the process 437 00:21:29.719 --> 00:21:32.419 of making these environment in 3D 438 00:21:32.419 --> 00:21:35.319 The effects you see in the sky here 439 00:21:35.319 --> 00:21:37.800 This is what it means 440 00:21:37.800 --> 00:21:40.550 The part shown in the sky 441 00:21:40.550 --> 00:21:44.050 We're taking that as the ambient color 442 00:21:44.050 --> 00:21:45.850 So if an object is here like this 443 00:21:45.850 --> 00:21:49.207 the ambient bounced off 444 00:21:49.207 --> 00:21:51.157 We're going to use that color 445 00:21:51.157 --> 00:21:53.119 That's how it is 446 00:21:53.119 --> 00:21:56.369 But in 2D, we don't use that ambient as is 447 00:21:56.369 --> 00:22:01.219 but just the color we designate 448 00:22:01.219 --> 00:22:03.007 Here, on source 449 00:22:03.007 --> 00:22:06.657 choose color instead of skybox 450 00:22:06.657 --> 00:22:09.157 and the ambient color was 451 00:22:09.157 --> 00:22:10.520 dark grey, a dark color? 452 00:22:10.520 --> 00:22:12.270 Blue and dark color, right? 453 00:22:12.270 --> 00:22:14.920 Let's put white here 454 00:22:14.920 --> 00:22:17.980 white is 1 in numbers 455 00:22:17.980 --> 00:22:25.329 1, so in RGB 456 00:22:25.329 --> 00:22:30.320 we can express each colors from 0 to 1 457 00:22:30.320 --> 00:22:32.320 RGB, every color 458 00:22:32.320 --> 00:22:34.919 can be expressed in the range from 0 to 1 459 00:22:34.919 --> 00:22:36.919 So if the color is red 460 00:22:36.919 --> 00:22:40.188 we can have 1, 0, 0 461 00:22:40.188 --> 00:22:43.914 Then if I multiply this 462 00:22:43.914 --> 00:22:45.464 to the ambient color I made 463 00:22:45.464 --> 00:22:49.119 For a color to show it's color itself 464 00:22:49.119 --> 00:22:50.919 just multiply the number 1 465 00:22:50.919 --> 00:22:53.759 Then it shows its color as is, right? 466 00:22:53.759 --> 00:22:57.059 If it's 0.2, it will be darker right? 467 00:22:57.059 --> 00:23:02.080 So if you put white which corresponds to the number 1 468 00:23:02.080 --> 00:23:05.338 it shows the original color as is 469 00:23:07.559 --> 00:23:09.509 Great 470 00:23:09.509 --> 00:23:12.109 Let's put this as that 471 00:23:12.109 --> 00:23:15.059 We have now done camera, directional light 472 00:23:15.059 --> 00:23:17.040 and light setting 473 00:23:17.040 --> 00:23:21.440 Now let's move onto resolution settings 474 00:23:21.440 --> 00:23:25.740 On 2D as well, we're going to make 475 00:23:25.740 --> 00:23:27.600 a vertical scroll instead of horizontal 476 00:23:27.600 --> 00:23:29.950 So we'll put it here 477 00:23:29.950 --> 00:23:31.700 and put the plane here 478 00:23:31.700 --> 00:23:34.300 and we'll make it look like the enemies coming from 479 00:23:34.300 --> 00:23:35.600 top to bottom 480 00:23:35.600 --> 00:23:39.279 So let's set the resolution 481 00:23:39.279 --> 00:23:40.779 Here, free aspect 482 00:23:40.779 --> 00:23:42.572 Free aspect on the game window 483 00:23:42.572 --> 00:23:43.720 You'll see that 484 00:23:43.720 --> 00:23:47.480 Open this dropdown 485 00:23:47.480 --> 00:23:50.630 Right? Then click on the add button 486 00:23:50.630 --> 00:23:53.040 I, here 487 00:23:53.040 --> 00:23:55.840 then on the label 488 00:23:55.840 --> 00:24:00.585 let's say shooting 489 00:24:00.585 --> 00:24:05.185 Then for type, fixed resolution 490 00:24:05.185 --> 00:24:08.935 640 for width 491 00:24:08.935 --> 00:24:11.448 and Y, Y is height 492 00:24:11.448 --> 00:24:14.279 We'll put 960 493 00:24:14.279 --> 00:24:15.214 Ok 494 00:24:19.320 --> 00:24:21.470 Done? Now on the very bottom 495 00:24:21.470 --> 00:24:24.730 it says shooting, right? 496 00:24:24.730 --> 00:24:27.980 So it was free aspect on the game window 497 00:24:27.980 --> 00:24:30.130 Now we can see the screen 498 00:24:30.130 --> 00:24:32.320 set as shooting 499 00:24:32.320 --> 00:24:36.170 Now let's make the player object 500 00:24:36.170 --> 00:24:37.920 and script 501 00:24:37.920 --> 00:24:41.160 and move onto the next project 502 00:24:41.160 --> 00:24:43.910 First, we'll make a player object 503 00:24:43.910 --> 00:24:47.320 Click on the plus button on hierarchy 504 00:24:47.320 --> 00:24:50.970 and create a cube on 3D object 505 00:24:50.970 --> 00:24:54.760 We're working on the prototype now 506 00:24:54.760 --> 00:24:57.922 Prototyping basically verifies the logic 507 00:24:57.922 --> 00:25:00.322 and see if 508 00:25:00.322 --> 00:25:02.640 our project is fine 509 00:25:02.640 --> 00:25:05.190 So we make a cube 510 00:25:05.190 --> 00:25:07.472 and when we move onto the alpha version 511 00:25:07.472 --> 00:25:09.222 we'll add all 512 00:25:09.222 --> 00:25:11.492 the planned content 513 00:25:11.492 --> 00:25:16.119 so we'll update them all to practically used data 514 00:25:16.119 --> 00:25:19.769 Create a cube on 3D object 515 00:25:19.769 --> 00:25:21.880 and there's a cube 516 00:25:21.880 --> 00:25:23.130 This game object's name 517 00:25:23.130 --> 00:25:26.744 will be player 518 00:25:26.744 --> 00:25:28.244 Let's put player 519 00:25:28.244 --> 00:25:32.144 Then for location, from transform 520 00:25:32.144 --> 00:25:37.239 right click and reset 521 00:25:37.239 --> 00:25:40.339 Then you can see that all values for 522 00:25:40.339 --> 00:25:44.399 position, rotation, and scale are set back to default 523 00:25:44.399 --> 00:25:46.949 They're all 0, 0, 0 524 00:25:46.949 --> 00:25:49.640 In the game world 525 00:25:49.640 --> 00:25:52.990 Where is the player in this world? 526 00:25:52.990 --> 00:25:55.640 The very center of the virtual space 527 00:25:55.640 --> 00:25:59.239 0, 0, 0 528 00:25:59.239 --> 00:26:01.489 But below there 529 00:26:01.489 --> 00:26:04.880 on the game window, where is the player? 530 00:26:04.880 --> 00:26:06.630 It's here 531 00:26:06.630 --> 00:26:10.259 Isn't it a little more to the bottom? 532 00:26:10.259 --> 00:26:12.109 Right? The reason is 533 00:26:12.109 --> 00:26:14.559 This is in fact 0, 0, 0 534 00:26:14.559 --> 00:26:16.623 but the screen coming down like this 535 00:26:16.623 --> 00:26:20.173 The game object that shows the screen 536 00:26:20.173 --> 00:26:22.640 is the main camera 537 00:26:22.640 --> 00:26:24.840 This camera is currently at 538 00:26:24.840 --> 00:26:27.390 If you look at this scene window 539 00:26:27.390 --> 00:26:29.079 it's a little above here 540 00:26:29.079 --> 00:26:31.579 And on the right, the inspector window 541 00:26:31.579 --> 00:26:35.600 what's the y for position? 542 00:26:35.600 --> 00:26:38.450 It's 1 right? 543 00:26:38.450 --> 00:26:43.000 We'll set that lower to 0 544 00:26:43.000 --> 00:26:47.000 and z at -10 545 00:26:47.000 --> 00:26:49.499 Great 546 00:26:49.499 --> 00:26:55.185 Then the camera is, compared to the player 547 00:26:55.185 --> 00:26:58.291 Let me see form the side 548 00:26:58.291 --> 00:27:00.480 like this 549 00:27:00.480 --> 00:27:04.851 z means front or back 550 00:27:04.851 --> 00:27:06.760 Then the object is here 551 00:27:06.760 --> 00:27:09.860 and the main camera is behind there 552 00:27:09.860 --> 00:27:12.359 You can actually go there to see 553 00:27:12.359 --> 00:27:15.059 Main camera is here 554 00:27:15.059 --> 00:27:17.709 filming like this 555 00:27:17.709 --> 00:27:20.509 So the scene the main camera is seeing 556 00:27:20.509 --> 00:27:23.200 is the back of the player 557 00:27:23.200 --> 00:27:24.450 like this 558 00:27:24.450 --> 00:27:26.350 These objects will show up 559 00:27:26.350 --> 00:27:27.760 like this 560 00:27:27.760 --> 00:27:29.730 Then the screen captured by the camera 561 00:27:29.730 --> 00:27:31.706 shows up on the game window 562 00:27:34.159 --> 00:27:34.935 Good? 563 00:27:38.000 --> 00:27:41.400 So the position of the main camera will be 0, 0 564 00:27:41.400 --> 00:27:44.854 and -10 for z 565 00:27:46.559 --> 00:27:50.809 Then we now have done the basic resolution settings 566 00:27:50.809 --> 00:27:54.159 and also the camera and player 567 00:27:54.159 --> 00:27:57.709 We set the camera's location values as well 568 00:27:57.709 --> 00:27:59.259 and same for 569 00:27:59.259 --> 00:28:02.320 the player's location 570 00:28:02.320 --> 00:28:06.720 Then to control the player 571 00:28:06.720 --> 00:28:09.719 let's make a script 572 00:28:09.719 --> 00:28:11.769 First, on the project window 573 00:28:11.769 --> 00:28:16.003 Click on plus from asset folder to create a folder 574 00:28:16.003 --> 00:28:18.393 and name it script 575 00:28:21.601 --> 00:28:24.501 Go in to the script folder 576 00:28:24.501 --> 00:28:28.251 and let's make a script 577 00:28:28.251 --> 00:28:30.440 to control the player 578 00:28:30.440 --> 00:28:33.440 First, we're going to make the player write movement codes 579 00:28:33.440 --> 00:28:39.200 So on script, click on plus and then C# script 580 00:28:39.200 --> 00:28:43.458 and name it PlayerMove 581 00:28:45.440 --> 00:28:47.390 Good? 582 00:28:47.390 --> 00:28:51.590 What you should remember here is 583 00:28:51.590 --> 00:28:55.470 Look at this name in PlayerMove 584 00:28:55.470 --> 00:28:59.120 You have to keep the capital letters exactly like this 585 00:28:59.120 --> 00:29:01.703 P in capital 586 00:29:01.703 --> 00:29:05.203 and M as well 587 00:29:05.203 --> 00:29:07.799 plus no spaces 588 00:29:07.799 --> 00:29:09.399 Do not put spaces 589 00:29:09.399 --> 00:29:11.299 PlayerMove 590 00:29:11.299 --> 00:29:13.549 When you select this 591 00:29:13.549 --> 00:29:16.559 on the inspector window on the right 592 00:29:16.559 --> 00:29:20.259 it says public class PlayerMove right? 593 00:29:20.259 --> 00:29:23.059 This part that says PlayerMove 594 00:29:23.059 --> 00:29:24.919 and here where it says PlayerMove 595 00:29:24.919 --> 00:29:28.675 These two must be identical 596 00:29:28.675 --> 00:29:32.425 Only when the file name and class name are the same 597 00:29:32.425 --> 00:29:33.880 there will be no errors 598 00:29:33.880 --> 00:29:35.630 'But I wrote it wrong' 599 00:29:35.630 --> 00:29:38.130 then we'll fix it later on 600 00:29:38.130 --> 00:29:39.780 Go to edit 601 00:29:39.780 --> 00:29:42.514 and this part on the edit window 602 00:29:42.514 --> 00:29:46.414 change it back to PlayerMove 603 00:29:46.414 --> 00:29:48.214 If that worked properly 604 00:29:48.214 --> 00:29:50.614 Drag and drop PlayerMove 605 00:29:50.614 --> 00:29:52.679 to this player 606 00:29:52.679 --> 00:29:54.979 Drag and drop 607 00:29:54.979 --> 00:29:58.879 and then the PlayerMove is in here 608 00:29:58.879 --> 00:30:01.979 You can put it in with drag and drop 609 00:30:01.979 --> 00:30:04.692 Another thing, if you did it wrong 610 00:30:04.692 --> 00:30:06.042 right click 611 00:30:06.042 --> 00:30:09.760 and click on remove component 612 00:30:09.760 --> 00:30:13.910 Get it? We just put the player part here 613 00:30:13.910 --> 00:30:17.695 but now select the player and on the right 614 00:30:17.695 --> 00:30:19.495 We'll put it on the right side 615 00:30:19.495 --> 00:30:21.879 Drag and drop like this 616 00:30:21.879 --> 00:30:27.068 then the PlayerMove is added again 617 00:30:27.068 --> 00:30:29.018 There are two ways, the other one is 618 00:30:29.018 --> 00:30:32.318 You can add with component here 619 00:30:32.318 --> 00:30:33.840 but we usually don't do that 620 00:30:33.840 --> 00:30:36.290 Usually 621 00:30:36.290 --> 00:30:39.140 we use drag and drop 622 00:30:39.140 --> 00:30:41.480 or you can use add component 623 00:30:41.480 --> 00:30:45.506 by clicking here 624 00:30:45.506 --> 00:30:48.639 Great, now we put PlayerMove 625 00:30:48.639 --> 00:30:52.796 in our player game object 626 00:30:53.322 --> 00:30:57.025 Understanding Unity C#'s basic structure 627 00:30:57.480 --> 00:31:00.430 Now we'll really get into 628 00:31:00.430 --> 00:31:04.000 writing the script that controls the player 629 00:31:04.000 --> 00:31:07.600 To do that, it would be nice to see 630 00:31:07.600 --> 00:31:10.519 how Unity C# works 631 00:31:10.519 --> 00:31:12.580 So in this unit, we'll learn 632 00:31:12.580 --> 00:31:14.936 the basic structure of Unity C# 633 00:31:17.361 --> 00:31:19.561 Although you already learned C# 634 00:31:19.561 --> 00:31:23.351 the basic grammar used in C3 635 00:31:23.351 --> 00:31:26.360 can also be used the same in Unity C# 636 00:31:26.360 --> 00:31:33.320 But in Unity C# 637 00:31:33.320 --> 00:31:36.320 there is using UnityEngine 638 00:31:36.320 --> 00:31:37.919 This is called a name space 639 00:31:37.919 --> 00:31:43.183 We need to add the name space we're going to use here 640 00:31:43.183 --> 00:31:46.383 You need to say that you'll use UnityEngine 641 00:31:46.383 --> 00:31:50.433 to use other classes or API functions 642 00:31:50.433 --> 00:31:53.400 provided by Unity 643 00:31:53.400 --> 00:31:57.050 And if you see here 644 00:31:57.050 --> 00:31:59.200 on public class, the class name is 645 00:31:59.200 --> 00:32:01.000 PlayerMove 646 00:32:01.000 --> 00:32:02.534 If this part is wrong 647 00:32:02.534 --> 00:32:04.434 then you can just fix that 648 00:32:04.434 --> 00:32:06.834 And then after that 649 00:32:06.834 --> 00:32:09.880 there's a super class, MonoBehaviour 650 00:32:09.880 --> 00:32:13.030 If you follow this 651 00:32:13.030 --> 00:32:15.476 in API 652 00:32:15.476 --> 00:32:19.476 above this is 653 00:32:19.476 --> 00:32:21.880 Behaviour 654 00:32:21.880 --> 00:32:23.980 There's Behaviour 655 00:32:23.980 --> 00:32:25.780 and above that is 656 00:32:25.780 --> 00:32:29.320 Component 657 00:32:29.320 --> 00:32:34.270 So what's the most super of MonoBehaviour? Component 658 00:32:34.270 --> 00:32:36.070 and PlayerMove which inherits MonoBehaviour 659 00:32:36.070 --> 00:32:39.543 is also a component 660 00:32:39.543 --> 00:32:43.343 So what are we writing? 661 00:32:43.343 --> 00:32:44.880 Component 662 00:32:44.880 --> 00:32:46.780 So to game object 663 00:32:46.780 --> 00:32:51.520 There is the game object that we're using, Player 664 00:32:51.520 --> 00:32:54.920 We could drag and drop 665 00:32:54.920 --> 00:32:57.600 PlayerMove 666 00:32:57.600 --> 00:33:01.250 Why is that? Because this is a component 667 00:33:01.250 --> 00:33:03.500 Everything that consists the game object Player 668 00:33:03.500 --> 00:33:04.880 are components 669 00:33:04.880 --> 00:33:07.330 The reason why it can stick 670 00:33:07.330 --> 00:33:11.559 is because PlayerMove is a component 671 00:33:11.559 --> 00:33:13.548 Get it? Next 672 00:33:15.919 --> 00:33:19.369 Under here we have a function called void start 673 00:33:19.369 --> 00:33:22.720 and void update 674 00:33:22.720 --> 00:33:25.620 These two functions 675 00:33:25.620 --> 00:33:27.749 are what we call life cycle 676 00:33:30.080 --> 00:33:32.430 Life cycle function 677 00:33:32.430 --> 00:33:35.364 Life cycle is 678 00:33:35.364 --> 00:33:36.244 from birth 679 00:33:39.065 --> 00:33:42.515 then do you die right away? 680 00:33:42.515 --> 00:33:44.600 You can't go straight to the tomb 681 00:33:44.600 --> 00:33:47.595 That's a little dangerous 682 00:33:47.595 --> 00:33:51.320 It's cruel, we must let them live a little 683 00:33:51.320 --> 00:33:59.399 So they live, and then what do they do? 684 00:33:59.399 --> 00:34:03.000 They die 685 00:34:03.000 --> 00:34:05.900 I said birth but 686 00:34:05.900 --> 00:34:08.199 these are all verbs, to be birthed 687 00:34:08.199 --> 00:34:10.617 To live, right? 688 00:34:10.617 --> 00:34:16.079 Functions do the job of verbs 689 00:34:16.079 --> 00:34:17.929 They act as verbs 690 00:34:17.929 --> 00:34:18.917 Here 691 00:34:22.440 --> 00:34:24.976 Let me just move this away 692 00:34:28.065 --> 00:34:30.965 Let's talk about life cycle 693 00:34:30.965 --> 00:34:34.129 briefly 694 00:34:34.129 --> 00:34:35.329 Being born 695 00:34:35.329 --> 00:34:39.958 Can you know when you are being born? 696 00:34:39.959 --> 00:34:42.409 Could you? 697 00:34:42.409 --> 00:34:46.279 Can we know when a baby is being born? 698 00:34:46.279 --> 00:34:49.479 We can, why? 699 00:34:49.479 --> 00:34:53.546 When you visit an ob-gyn they tell you 700 00:34:53.546 --> 00:34:56.480 when the baby will be born, the date and time 701 00:34:56.480 --> 00:34:58.780 So we can know when they are born 702 00:34:58.780 --> 00:35:00.680 It is influenced by our wills 703 00:35:00.680 --> 00:35:04.679 In fact they do give births on their wish day by surgery 704 00:35:04.679 --> 00:35:08.329 If we say that we'll do this at this time 705 00:35:08.329 --> 00:35:11.129 we can designate when this action will 706 00:35:11.129 --> 00:35:14.399 be done 707 00:35:14.399 --> 00:35:15.699 And what about living? 708 00:35:15.699 --> 00:35:18.249 You live, but then dying? 709 00:35:18.249 --> 00:35:20.440 Do you know when you die? 710 00:35:20.440 --> 00:35:21.890 This is tricky 711 00:35:21.890 --> 00:35:25.340 And let's say we're meeting in real life 712 00:35:25.340 --> 00:35:27.000 and we're giving each other high fives 713 00:35:27.000 --> 00:35:31.786 Does the hand look AI? 714 00:35:31.786 --> 00:35:34.160 I don't think I'm much different from an AI 715 00:35:34.160 --> 00:35:39.410 Let's say we do high fives 716 00:35:39.410 --> 00:35:42.359 We clap them 717 00:35:42.359 --> 00:35:45.909 Two hands will clap 718 00:35:45.909 --> 00:35:47.961 Clap it now? Or not now? 719 00:35:47.961 --> 00:35:50.600 Can you tell when? 720 00:35:50.600 --> 00:35:52.800 You can't 721 00:35:52.800 --> 00:35:55.850 These things, dying, clapping 722 00:35:55.850 --> 00:35:59.160 these are hard to know when they'll happen 723 00:35:59.160 --> 00:36:01.398 So we say that these exist as events 724 00:36:04.119 --> 00:36:11.559 So in Unity, the birth is called start 725 00:36:11.559 --> 00:36:14.209 and life cycle isn't just about being birthed 726 00:36:14.209 --> 00:36:17.160 but there will be a point in time when the baby is made 727 00:36:17.160 --> 00:36:18.960 Then when their limbs develop 728 00:36:18.960 --> 00:36:21.320 Life cycle is cut into very tiny pieces 729 00:36:21.320 --> 00:36:23.720 But overall, we can just say that 730 00:36:23.720 --> 00:36:26.359 it's birth, life and death 731 00:36:26.359 --> 00:36:29.059 Being born is start 732 00:36:29.059 --> 00:36:32.937 and this start here is what this is 733 00:36:32.937 --> 00:36:36.487 Living is update 734 00:36:36.487 --> 00:36:38.480 which is here 735 00:36:38.480 --> 00:36:41.180 and did we say we know when we die? 736 00:36:41.180 --> 00:36:42.279 We can't 737 00:36:42.279 --> 00:36:46.123 So in Unity, it shows the events 738 00:36:46.123 --> 00:36:48.519 that we cannot predict when 739 00:36:48.519 --> 00:36:53.619 So those have On in front of them 740 00:36:53.619 --> 00:36:56.880 They have the prefix On 741 00:36:56.880 --> 00:37:01.330 So dying is OnDestroy 742 00:37:01.330 --> 00:37:06.020 The function name is designated 743 00:37:06.020 --> 00:37:07.970 These life cycle functions 744 00:37:07.970 --> 00:37:09.970 are what Unity provides 745 00:37:09.970 --> 00:37:12.920 It makes start and update 746 00:37:12.920 --> 00:37:15.770 once a class is made 747 00:37:15.770 --> 00:37:19.398 How many times is something born? 748 00:37:19.398 --> 00:37:21.148 Not like Samsara 749 00:37:21.148 --> 00:37:22.706 It's just once right? 750 00:37:22.706 --> 00:37:26.559 Living will just be lived 751 00:37:26.559 --> 00:37:28.609 until just before death 752 00:37:28.609 --> 00:37:32.166 And how many times do you die? Once 753 00:37:32.166 --> 00:37:36.200 So we can know how many times these functions are called 754 00:37:36.200 --> 00:37:38.600 Being born is matched with start 755 00:37:38.600 --> 00:37:41.100 so called how many times? Once 756 00:37:41.100 --> 00:37:45.160 Update will be called all the time while living 757 00:37:45.160 --> 00:37:48.060 and OnDestroy, just once 758 00:37:48.060 --> 00:37:52.160 when it dies 759 00:37:52.160 --> 00:37:57.810 You could remember the timing 760 00:37:57.810 --> 00:38:00.640 and number of calls of the functions 761 00:38:00.640 --> 00:38:06.140 And then with this, the core of programming 762 00:38:06.140 --> 00:38:09.376 let's put Hello World at first 763 00:38:09.376 --> 00:38:11.276 Let's try 764 00:38:11.276 --> 00:38:13.626 The player already 765 00:38:13.626 --> 00:38:16.079 has the PlayerMove component 766 00:38:16.079 --> 00:38:17.978 Let's open this one 767 00:38:26.278 --> 00:38:30.178 When PlayerMove script is opened on Visual Studio 768 00:38:30.178 --> 00:38:33.037 we can put codes here 769 00:38:33.037 --> 00:38:39.212 print, Hello World 770 00:38:39.212 --> 00:38:41.535 Let's type that in 771 00:38:45.658 --> 00:38:47.135 Save it 772 00:38:50.095 --> 00:38:51.595 and come back to Unity 773 00:38:53.387 --> 00:38:56.887 Then Unity immediately reads the saved part 774 00:38:56.887 --> 00:38:58.559 and shows us 775 00:38:58.559 --> 00:39:01.159 and automatically it recognizes 776 00:39:01.159 --> 00:39:03.195 the changed parts and memorizes it 777 00:39:04.145 --> 00:39:06.159 Let's click the play button 778 00:39:08.599 --> 00:39:10.199 Then it says hello world 779 00:39:10.199 --> 00:39:11.549 Where is it? 780 00:39:11.549 --> 00:39:13.249 Can you see? 781 00:39:13.249 --> 00:39:14.799 Look at my mouse cursor 782 00:39:14.799 --> 00:39:17.599 Down here, can you see? 783 00:39:17.599 --> 00:39:20.249 It says hello world, tiny 784 00:39:20.249 --> 00:39:23.440 If it's hard to see 785 00:39:23.440 --> 00:39:26.090 try clicking on hello world 786 00:39:26.090 --> 00:39:30.022 then it shows a console window 787 00:39:30.022 --> 00:39:32.522 Here it says hello world 788 00:39:32.522 --> 00:39:34.903 and also has collapse 789 00:39:34.903 --> 00:39:36.853 If this is pressed 790 00:39:36.853 --> 00:39:39.799 it shows how many times this was called at the end 791 00:39:39.799 --> 00:39:41.849 It means that we called it once 792 00:39:41.849 --> 00:39:44.306 Why? Because there is only one start 793 00:39:46.513 --> 00:39:49.015 Where should we put this console window 794 00:39:49.015 --> 00:39:50.665 Let's put it next to 795 00:39:50.665 --> 00:39:52.799 the project window, dock it 796 00:39:52.799 --> 00:39:55.731 Then I'll turn it off 797 00:39:57.028 --> 00:39:59.400 When you run it again 798 00:39:59.400 --> 00:40:01.450 From now on, on the console window 799 00:40:01.450 --> 00:40:04.118 you can see this part being marked over and over again 800 00:40:06.694 --> 00:40:09.694 So that was hello world 801 00:40:09.694 --> 00:40:13.937 But as I told you, life cycle function 802 00:40:16.317 --> 00:40:18.217 is called once in start 803 00:40:18.217 --> 00:40:20.667 continuously updated 804 00:40:20.667 --> 00:40:23.719 and death also called once 805 00:40:23.719 --> 00:40:26.417 Let's see if this 806 00:40:26.417 --> 00:40:27.919 actually does happen 807 00:40:27.919 --> 00:40:30.819 If there is start, for this part 808 00:40:30.819 --> 00:40:33.679 I'll put it in update 809 00:40:33.679 --> 00:40:36.479 Then it was called once 810 00:40:36.479 --> 00:40:38.629 Now let's see how this part is called 811 00:40:38.629 --> 00:40:40.006 Press play 812 00:40:42.359 --> 00:40:46.159 As you can see, at the end of hello world 813 00:40:46.159 --> 00:40:48.679 the number is increasing 814 00:40:48.679 --> 00:40:53.599 Right? This part is consistently increasing 815 00:40:53.599 --> 00:40:55.749 It means that this is being called constantly 816 00:40:55.749 --> 00:40:59.031 Why? Because update is called continuously during life 817 00:41:01.159 --> 00:41:02.709 Then let's see how 818 00:41:02.709 --> 00:41:04.919 OnDestroy is called 819 00:41:04.919 --> 00:41:06.669 OnDestroy 820 00:41:06.669 --> 00:41:10.760 If you put void OnDestroy 821 00:41:10.760 --> 00:41:13.760 Not on update but on OnDestroy 822 00:41:13.760 --> 00:41:15.479 and let's test that 823 00:41:15.479 --> 00:41:18.829 Save it, you must save it 824 00:41:18.829 --> 00:41:21.945 Play it again 825 00:41:23.836 --> 00:41:27.486 It doesn't show hello world now 826 00:41:27.486 --> 00:41:28.986 Let me turn it off 827 00:41:28.986 --> 00:41:31.559 Then only then hello world appears 828 00:41:31.559 --> 00:41:34.559 You can see it being called once 829 00:41:34.559 --> 00:41:39.479 So start, update, OnDestroy functions 830 00:41:39.479 --> 00:41:42.279 so the life cycle function 831 00:41:42.279 --> 00:41:44.080 is called like this 832 00:41:44.080 --> 00:41:46.680 and on start, when we're doing some sort of setting 833 00:41:46.680 --> 00:41:47.719 or such works 834 00:41:47.719 --> 00:41:50.219 When setting the initial values, put it in start 835 00:41:50.219 --> 00:41:52.489 because it's called just once when being born 836 00:41:52.489 --> 00:41:55.039 and update is after it starts living 837 00:41:55.039 --> 00:41:57.289 Here, animations 838 00:41:57.289 --> 00:42:00.400 like characters moving or receiving user input 839 00:42:00.400 --> 00:42:03.250 These are all done where? Update 840 00:42:03.250 --> 00:42:05.919 because it must perform it continuously while living 841 00:42:05.919 --> 00:42:09.019 While the game is running, it's all update 842 00:42:09.019 --> 00:42:12.669 And when we end it, returning resources 843 00:42:12.669 --> 00:42:14.799 or other such works are required sometimes 844 00:42:14.799 --> 00:42:17.879 Then we can do that on OnDestroy 845 00:42:20.200 --> 00:42:24.400 Then what structure does unity have 846 00:42:24.400 --> 00:42:26.750 making it possible for Unity editor 847 00:42:26.750 --> 00:42:28.719 to acknowledge and run it 848 00:42:28.719 --> 00:42:31.794 right away? 849 00:42:31.794 --> 00:42:36.799 C# files' extensions are .cs 850 00:42:36.799 --> 00:42:39.799 What makes C# files aren't just Visual Studio 851 00:42:39.799 --> 00:42:42.239 but other IDE tools as well 852 00:42:42.239 --> 00:42:44.539 There is also Visual Studio code now 853 00:42:44.539 --> 00:42:46.639 We are using Visual Studio 854 00:42:46.639 --> 00:42:47.960 community 855 00:42:47.960 --> 00:42:51.360 We can make C# flils with just a memo pad 856 00:42:51.360 --> 00:42:53.599 So C# file is made 857 00:42:53.599 --> 00:42:55.949 and once we do that 858 00:42:55.949 --> 00:42:59.399 How does Unity Engine recognize this? 859 00:42:59.399 --> 00:43:03.000 The C# file was edited on Unity 860 00:43:03.000 --> 00:43:05.800 then the editor is monitoring it 861 00:43:05.800 --> 00:43:08.250 Oh, C# file was edited 862 00:43:08.250 --> 00:43:11.080 Then it loads C# file 863 00:43:11.080 --> 00:43:14.430 and it's not just using the C# file 864 00:43:14.430 --> 00:43:18.730 Between here, the C# file we made 865 00:43:18.730 --> 00:43:21.679 is human language 866 00:43:21.679 --> 00:43:23.629 How is it? 867 00:43:23.629 --> 00:43:25.779 It's programming language 868 00:43:25.779 --> 00:43:29.679 It's a human language just to communicate with computers 869 00:43:29.679 --> 00:43:33.479 Then C# file made with human language 870 00:43:33.479 --> 00:43:35.640 must be performed where? 871 00:43:35.640 --> 00:43:39.890 On a machine, a computer 872 00:43:39.890 --> 00:43:43.690 So the language humans made 873 00:43:43.690 --> 00:43:47.520 the language we made in Korea 874 00:43:47.520 --> 00:43:50.365 must be translated to communicate 875 00:43:50.365 --> 00:43:54.193 with an American person 876 00:43:54.193 --> 00:43:58.366 Just like that, C# file's language 877 00:43:58.366 --> 00:44:00.799 must be translated into machine code 878 00:44:00.799 --> 00:44:03.042 What we call this translation is 879 00:44:03.042 --> 00:44:05.960 compiling 880 00:44:05.960 --> 00:44:07.660 Compile 881 00:44:07.660 --> 00:44:11.660 So when we bring a C# to Unity 882 00:44:11.660 --> 00:44:14.460 Unity loads that file 883 00:44:14.460 --> 00:44:16.799 and compiles it 884 00:44:16.799 --> 00:44:20.035 But uniquely, C 885 00:44:20.035 --> 00:44:23.635 or C++ is translated into machine code right away 886 00:44:23.635 --> 00:44:27.110 But it doesn't for C# 887 00:44:27.110 --> 00:44:30.060 and this is to secure the flexibility 888 00:44:30.060 --> 00:44:32.760 for many platforms 889 00:44:32.760 --> 00:44:36.160 We don't have just one OS 890 00:44:36.160 --> 00:44:39.400 When we put an app on OS 891 00:44:39.400 --> 00:44:42.550 then it changes into Window OS, Mac OS 892 00:44:42.550 --> 00:44:45.200 or iOS 893 00:44:45.200 --> 00:44:47.600 So according to the OS 894 00:44:47.600 --> 00:44:49.960 the app can only be very dependent 895 00:44:49.960 --> 00:44:51.860 Processing certain data 896 00:44:51.860 --> 00:44:55.310 is also different for these languages and C# 897 00:44:55.310 --> 00:44:59.080 So if an app becomes dependent on the OS 898 00:44:59.080 --> 00:45:00.748 when it's trying to correspond to other OS 899 00:45:00.748 --> 00:45:02.816 the application we made 900 00:45:02.816 --> 00:45:06.616 for iOS, iPhone, android phones 901 00:45:06.616 --> 00:45:09.799 Window, or steam 902 00:45:09.799 --> 00:45:12.599 it might be hard to correspond it to them 903 00:45:12.599 --> 00:45:17.359 Why? because each OS are different 904 00:45:17.359 --> 00:45:19.759 Then to correspond multi platform 905 00:45:19.759 --> 00:45:22.209 to one source code 906 00:45:22.209 --> 00:45:24.559 what should we do? 907 00:45:24.559 --> 00:45:27.309 If we translate it right away to machine code 908 00:45:27.309 --> 00:45:29.259 it becomes difficult 909 00:45:29.259 --> 00:45:34.320 so C# puts something in between here 910 00:45:34.320 --> 00:45:37.020 like this 911 00:45:37.020 --> 00:45:39.528 This is .NET 912 00:45:41.359 --> 00:45:42.218 .NET 913 00:45:44.520 --> 00:45:46.120 It's often called runtime 914 00:45:46.120 --> 00:45:47.702 So this part 915 00:45:47.702 --> 00:45:50.170 .NET 916 00:45:50.170 --> 00:45:53.000 the role of .NET is 917 00:45:53.000 --> 00:45:55.650 when we make an app, instead of going straight to the OS 918 00:45:55.650 --> 00:45:57.550 it goes through .NET first 919 00:45:57.550 --> 00:46:00.599 and then when running on the OS 920 00:46:00.599 --> 00:46:02.549 it determines for the OS 921 00:46:02.549 --> 00:46:05.399 and compile then 922 00:46:05.399 --> 00:46:07.649 Then does it not compile before that? 923 00:46:07.649 --> 00:46:09.269 It does, in what way? 924 00:46:09.269 --> 00:46:12.989 Here, you can see Make DLL 925 00:46:12.989 --> 00:46:16.640 These C# files 926 00:46:16.640 --> 00:46:18.990 are called Intermediate Language 927 00:46:18.990 --> 00:46:21.240 It makes this an interlanguage 928 00:46:21.240 --> 00:46:24.359 That is DLL 929 00:46:24.359 --> 00:46:26.859 In C#, we say assembly 930 00:46:26.859 --> 00:46:28.109 Make all these 931 00:46:28.109 --> 00:46:31.400 and the extension comes out as a DLL file 932 00:46:31.400 --> 00:46:35.700 C# is turned into a DLL file 933 00:46:35.700 --> 00:46:39.719 Then these are Intermediate Language 934 00:46:39.719 --> 00:46:42.569 Instead of going straight to the OS 935 00:46:42.569 --> 00:46:44.431 it goes through something in the middle 936 00:46:44.431 --> 00:46:46.799 making it an Intermediate Language beforehand 937 00:46:46.799 --> 00:46:51.249 After that, for Window OS or iOS 938 00:46:51.249 --> 00:46:56.280 Only then it compiles to machine codes 939 00:46:56.280 --> 00:46:59.130 suitable for the OS 940 00:46:59.130 --> 00:47:01.137 So compile at that moment 941 00:47:03.315 --> 00:47:04.716 when? That moment 942 00:47:07.560 --> 00:47:09.460 So it's called just in time 943 00:47:09.460 --> 00:47:13.359 and in short, JIT compile 944 00:47:13.359 --> 00:47:16.166 This leads to the final 945 00:47:16.166 --> 00:47:17.116 machine codes 946 00:47:17.116 --> 00:47:21.520 So C and C++ 947 00:47:21.520 --> 00:47:24.570 are compiled directly to OS 948 00:47:24.570 --> 00:47:27.108 into what fits the OS 949 00:47:27.108 --> 00:47:28.640 so it can be quicker 950 00:47:28.640 --> 00:47:31.290 But what about JAVA or C#? 951 00:47:31.290 --> 00:47:33.690 It goes through something 952 00:47:33.690 --> 00:47:37.040 So compared to C and C++ 953 00:47:37.040 --> 00:47:40.847 it might be a little slower 954 00:47:40.847 --> 00:47:43.297 These days though, thanks to hardware and compiler capacity 955 00:47:43.297 --> 00:47:46.237 this is also getting shorter 956 00:47:46.237 --> 00:47:49.187 Unity has this 957 00:47:49.187 --> 00:47:52.737 It's using C#, so this part is also included 958 00:47:52.737 --> 00:47:55.800 which is why what we're working on on Unity 959 00:47:55.800 --> 00:47:59.450 can be used in android, iOS, Console 960 00:47:59.450 --> 00:48:02.650 and even in web browsers 961 00:48:02.650 --> 00:48:04.667 We're making use of the pros of this part 962 00:48:07.244 --> 00:48:10.294 Then you'll be able to understand 963 00:48:10.294 --> 00:48:13.040 the basic structure of Unity C# 964 00:48:13.040 --> 00:48:16.340 Let's see what we've learned in this topic 965 00:48:16.340 --> 00:48:20.160 First, we created a project and set the environment 966 00:48:20.160 --> 00:48:22.846 Then we placed camera and lighting 967 00:48:24.816 --> 00:48:26.916 After that, we created player object 968 00:48:26.916 --> 00:48:29.116 and added script 969 00:48:29.116 --> 00:48:31.016 Lastly on Unity Engine 970 00:48:31.016 --> 00:48:35.560 we saw how C# works and it's components 971 00:48:35.560 --> 00:48:37.035 Good job 972 00:48:37.736 --> 00:48:39.359 Project production and environment setting Setting shooting game project 973 00:48:39.359 --> 00:48:41.087 Run Unity Hub and create ShootingGame project When ShootingGame project is made, Unity is ran 974 00:48:41.087 --> 00:48:42.696 Setting up production environment Change the Scene view to Iso mode and click Gizmos to set the screen to be a back view 975 00:48:42.696 --> 00:48:43.728 Camera and lighting placement, player object and script creation Camera Settings Camera components are attached to the camera to act as a camera 976 00:48:43.728 --> 00:48:44.801 Set main camera's projetion as orthographics Lighting setting Select direction light from hierarchy window and deactivate light component 977 00:48:44.801 --> 00:48:45.853 Open [winow-rendering-lighting settings] window and deactivate auto generate option at the very bottom of lighting window's scene tab 978 00:48:45.853 --> 00:48:46.849 Change Environment lighting source to color and designate ambient color to white on environemnt 979 00:48:46.849 --> 00:48:47.762 On game window, open resolution dropdown menu and blick + button and set resolution x, y value to 640x960 980 00:48:47.762 --> 00:48:49.012 Player object and script setting Click on + button from hierarchy window to create [3D Object - Cube] and name it Player 981 00:48:49.012 --> 00:48:50.262 Click on + buton from project window to select folder and name it Scripts 982 00:48:50.262 --> 00:48:51.512 Click on + button from script folder to make C# script and name it PlayerMove 983 00:48:51.512 --> 00:48:52.741 Drag PlayerMovve script and drop on hierarchy's player object 984 00:48:52.741 --> 00:48:53.991 Understanding basic structure of Unity C# Double click on PlayerMove.cs from Project window to open editor 985 00:48:53.991 --> 00:48:55.191 Input print("HeloWorld") to PlayerMove.cs' start function and run on Unity 986 00:48:55.191 --> 00:48:56.441 Life cycle function Unity object's life cycle is Start as birth, Spdate and life, and Ondestory as death 987 00:48:56.441 --> 00:48:57.681 C# script's run structure Change in CS file let's Unity Engine compile the file Usually compiled to Assembly-CSharp.dll