1 00:00:04,400 --> 00:00:09,380 ‫A very fundamental functionality in unity is the functionality of components. 2 00:00:09,380 --> 00:00:12,020 ‫And components are a super powerful tool. 3 00:00:12,050 --> 00:00:18,560 ‫They allow us to add functionality or looks or physics to an object. 4 00:00:18,560 --> 00:00:22,040 ‫So, for example, our player has a transformed component. 5 00:00:22,040 --> 00:00:26,630 ‫He has a sphere component, sphere measure and the rigid body and so forth. 6 00:00:26,630 --> 00:00:30,590 ‫And those components, they add functionality and looks to our player. 7 00:00:30,950 --> 00:00:36,020 ‫That's a very important aspect that you need to understand because every time that you want to add, 8 00:00:36,020 --> 00:00:38,360 ‫let's say, a different kind of behavior. 9 00:00:38,360 --> 00:00:43,520 ‫So let's say now we have player movement, but what you would like to have is player shooting so that 10 00:00:43,520 --> 00:00:44,780 ‫our player can shoot. 11 00:00:44,780 --> 00:00:51,170 ‫Then you would create a new component and that would be a script component and you would create a new 12 00:00:51,170 --> 00:00:55,130 ‫script or even here a new script and you would create a new script here. 13 00:00:56,090 --> 00:01:00,830 ‫Then you can have different components added to your object. 14 00:01:00,830 --> 00:01:03,200 ‫For example, you could add effects. 15 00:01:03,200 --> 00:01:05,720 ‫So what particle system to your object? 16 00:01:05,720 --> 00:01:12,470 ‫Or you could add even more physics, because so far we have only are a rigid body, we have our sphere 17 00:01:12,470 --> 00:01:14,210 ‫collider and those kind of things. 18 00:01:14,210 --> 00:01:20,690 ‫And what if you wanted to, you could add even an additional collider to our sphere, you could add 19 00:01:20,690 --> 00:01:21,770 ‫a box collider. 20 00:01:21,770 --> 00:01:25,790 ‫So as you can see now, our player has two different colliders, the Box and the Sphere. 21 00:01:25,790 --> 00:01:28,070 ‫Collider And that's a new component. 22 00:01:28,070 --> 00:01:33,770 ‫You can add components as you need them, and you can remove those components any time. 23 00:01:34,280 --> 00:01:40,010 ‫And what you also can do is you can copy components and add them to a different object. 24 00:01:40,010 --> 00:01:46,580 ‫So for example, if I would like to have this player movement component in a different object, I could 25 00:01:46,580 --> 00:01:53,990 ‫copy the component here called the component and add it, for example, to our game object. 26 00:01:53,990 --> 00:01:58,970 ‫So in here I would press there and paste component as new. 27 00:01:58,970 --> 00:02:04,400 ‫So press this little button here at the top, paste component as new, and then you have the player 28 00:02:04,400 --> 00:02:05,720 ‫component here as well. 29 00:02:06,260 --> 00:02:12,080 ‫Well, it doesn't make sense for that game object, so I'm just going to remove the component again. 30 00:02:12,710 --> 00:02:19,580 ‫Then if you would like to change the order of your components, you can simply move them up, for example. 31 00:02:19,580 --> 00:02:25,670 ‫So if I want to move this up, this player movement component, I can press and move up. 32 00:02:25,670 --> 00:02:29,440 ‫And as you can see, this action can break the prefab instance there. 33 00:02:29,450 --> 00:02:33,020 ‫Are you sure you want to continue and I'm just going to use cancel. 34 00:02:33,020 --> 00:02:35,030 ‫So let's do the same thing with the prefab. 35 00:02:35,030 --> 00:02:40,610 ‫Let's go to our player and let's move it up now. 36 00:02:40,970 --> 00:02:45,560 ‫So as you could see now, it wasn't very happy with changing that. 37 00:02:45,560 --> 00:02:52,250 ‫So if you want to move something up, for example, move a component up, do that with your prefab and 38 00:02:52,250 --> 00:02:59,150 ‫not with its instance in the hierarchy, because that player here is not the same as that player there. 39 00:02:59,150 --> 00:03:02,480 ‫This is the prefab and that one is the player itself. 40 00:03:02,480 --> 00:03:08,600 ‫So if you make any changes to your player instance within your hierarchy, you can apply it. 41 00:03:08,810 --> 00:03:16,770 ‫So let's say our player here has its player movement control component at the second lowest spot or 42 00:03:16,770 --> 00:03:20,600 ‫a third low spot, depending on what you consider as a component. 43 00:03:20,600 --> 00:03:25,010 ‫And that one has a speed of, let's say, 100. 44 00:03:25,010 --> 00:03:28,670 ‫So our player prefab has a speed of 100. 45 00:03:28,670 --> 00:03:36,080 ‫Our player itself now took over that, but we could change it here so we could change the speed of our 46 00:03:36,080 --> 00:03:37,820 ‫player to 20. 47 00:03:37,850 --> 00:03:41,870 ‫Our player prefab, however, would not be influenced by that. 48 00:03:42,440 --> 00:03:45,770 ‫So let's have a look at that if we want to apply this. 49 00:03:45,770 --> 00:03:52,280 ‫So if we want to save the information that we have changed in here and save them to our prefab, we 50 00:03:52,280 --> 00:03:54,170 ‫need to click apply. 51 00:03:56,510 --> 00:03:56,840 ‫All right. 52 00:03:56,840 --> 00:03:58,160 ‫So that's very important. 53 00:03:58,410 --> 00:04:02,480 ‫If you want to make any changes and apply them, press on apply. 54 00:04:02,480 --> 00:04:07,100 ‫And now our player prefab itself will also have the speed of 20. 55 00:04:07,520 --> 00:04:07,880 ‫All right. 56 00:04:07,880 --> 00:04:12,110 ‫So that's about components and a bit more on prefabs.