1 00:00:04,060 --> 00:00:08,290 ‫In this video, you will learn about the different collider types in unity. 2 00:00:08,830 --> 00:00:13,930 ‫As you have already seen in the presentation, there are different kinds of colliders and we already 3 00:00:13,930 --> 00:00:17,740 ‫have worked with two different collider types or actually even three. 4 00:00:17,950 --> 00:00:20,640 ‫So now let's have a look at those collider types. 5 00:00:20,650 --> 00:00:25,810 ‫For example, our player has a Sphere Collider, you can see that here. 6 00:00:25,810 --> 00:00:29,020 ‫So let's go to our player here. 7 00:00:29,200 --> 00:00:36,250 ‫And as you can see, there is this greenish line that you have around the player or around this circle, 8 00:00:36,250 --> 00:00:38,250 ‫and that is our sphere. 9 00:00:38,260 --> 00:00:48,370 ‫Collider It already has gotten automatically a radius of 0.5, which fits the size of our player. 10 00:00:48,370 --> 00:00:55,210 ‫So if I change that to, for example, one, my Sphere Collider will be bigger than the actual graphic 11 00:00:55,210 --> 00:00:56,470 ‫that we can see here. 12 00:00:56,470 --> 00:01:03,460 ‫So let's activate gravity for our player and let's run the game just to see what happens. 13 00:01:04,930 --> 00:01:06,820 ‫Now let's go back. 14 00:01:07,330 --> 00:01:09,190 ‫Let's go into the scene view here. 15 00:01:09,190 --> 00:01:16,150 ‫And as you can see, our ball is on top of the ground. 16 00:01:16,150 --> 00:01:17,740 ‫So it flies around. 17 00:01:18,580 --> 00:01:23,860 ‫It looks as if it flies, but in the end it has to do with the Sphere Collider Because the. 18 00:01:23,860 --> 00:01:31,660 ‫Sphere Collider So our ball collider that you can see here collides with the underground, which has 19 00:01:31,660 --> 00:01:35,770 ‫a mesh collider So that's already the second type of colliders. 20 00:01:35,770 --> 00:01:41,350 ‫This one has a different type of look and it's based on its mesh. 21 00:01:41,350 --> 00:01:44,650 ‫And you can find the mesh by clicking on the mesh here. 22 00:01:44,650 --> 00:01:52,810 ‫And you can see here at the bottom right side, this is the looks of the mesh and that can be very specific. 23 00:01:52,810 --> 00:01:55,480 ‫It can be based on the character. 24 00:01:55,480 --> 00:02:01,720 ‫For example, if your character is a car, then the mesh could be the whole surface of the car. 25 00:02:01,750 --> 00:02:08,350 ‫Mesh is used for surfaces and the mesh collider gives the surfaces a collider. 26 00:02:09,240 --> 00:02:09,540 ‫All right. 27 00:02:09,540 --> 00:02:16,350 ‫So our underground, for example, here has a mesh collider. 28 00:02:16,770 --> 00:02:17,490 ‫From the bottom. 29 00:02:17,490 --> 00:02:19,080 ‫You can see that there is nothing. 30 00:02:19,500 --> 00:02:21,740 ‫And from the top, it has this green color. 31 00:02:21,750 --> 00:02:25,050 ‫So we gave it this green color only from the top. 32 00:02:25,500 --> 00:02:33,960 ‫Now, if we want to have a higher layer for the collider of our mesh collider, we can add convex what 33 00:02:33,960 --> 00:02:34,350 ‫it does. 34 00:02:34,350 --> 00:02:41,520 ‫As you can see now, it has a collider towards the top and towards the bottom of its actual surface 35 00:02:41,730 --> 00:02:43,260 ‫and you can even inflate that. 36 00:02:43,260 --> 00:02:50,970 ‫So if you want to inflate it and make it bigger, you can go ahead and inflate the the collider of our 37 00:02:50,970 --> 00:02:54,120 ‫mesh or of our on the ground. 38 00:02:54,120 --> 00:02:58,770 ‫So if you have a look now, now our ball will be even higher. 39 00:02:58,770 --> 00:03:03,060 ‫So now it's on top of this physics piece. 40 00:03:03,060 --> 00:03:11,700 ‫So if we go ahead and reduce the radius of oh to 0.5, our ball will still be on top of this physics 41 00:03:11,700 --> 00:03:12,330 ‫collider. 42 00:03:12,330 --> 00:03:19,800 ‫So the colliders don't have to be the same size as the objects themselves, but it does of course make 43 00:03:19,800 --> 00:03:21,600 ‫sense to have that in most games. 44 00:03:21,600 --> 00:03:25,650 ‫Maybe your game type is exactly so that it doesn't fit well with each other. 45 00:03:25,650 --> 00:03:27,270 ‫Then you can of course change that. 46 00:03:27,930 --> 00:03:32,730 ‫What you also can do is you can change the center of your collider, at least in this case. 47 00:03:32,730 --> 00:03:39,180 ‫So, for example, the center of my collider could be, let's say, one higher than my ball itself. 48 00:03:39,180 --> 00:03:43,080 ‫So now if we look at it, the Y position is at one. 49 00:03:43,380 --> 00:03:48,420 ‫So now our ball is inside of our underground. 50 00:03:49,230 --> 00:03:53,490 ‫And at the same time, as you can see now, that's how it looks out moves now. 51 00:03:53,670 --> 00:03:58,860 ‫And the physics themselves, they move as intended. 52 00:03:59,460 --> 00:04:00,120 ‫All right. 53 00:04:00,240 --> 00:04:05,280 ‫So it just looks so weird because the radius is bigger and the position of the center is different. 54 00:04:05,280 --> 00:04:09,930 ‫So 000 is the center point of our sphere. 55 00:04:10,200 --> 00:04:14,910 ‫And well, if we change any of that, we'll change the center of the collider. 56 00:04:15,450 --> 00:04:17,490 ‫Now, let's go back to 0.5. 57 00:04:17,490 --> 00:04:20,190 ‫Let's set that back because that's the standard. 58 00:04:20,190 --> 00:04:22,380 ‫Collider Well, that's the sphere. 59 00:04:22,380 --> 00:04:29,580 ‫Collider Let's have a quick look at some other colliders, for example, the Capsule Collider So that 60 00:04:29,580 --> 00:04:38,040 ‫one is our capsule collider And as you can see, it has the form of a capsule and it also has the attributes 61 00:04:38,040 --> 00:04:43,860 ‫of center, it has a radius and it has a height, and you can even change the axis towards which you 62 00:04:43,860 --> 00:04:44,250 ‫want to. 63 00:04:44,250 --> 00:04:45,000 ‫Collider To be. 64 00:04:45,000 --> 00:04:54,120 ‫So y axis is going up, x axis is going to decide, as you can see here, and z axis is going towards 65 00:04:54,120 --> 00:04:55,890 ‫the other side, as you can see here now. 66 00:04:56,610 --> 00:04:57,030 ‫All right. 67 00:04:57,030 --> 00:05:04,650 ‫So let's put that back to y axis because the standard and now what I want to do is start my game. 68 00:05:04,650 --> 00:05:07,020 ‫So I'm going to start the player here. 69 00:05:07,050 --> 00:05:12,330 ‫So now let's try to hit that collider here and make it fall off because now it does have a collider. 70 00:05:12,330 --> 00:05:13,140 ‫So let's see. 71 00:05:13,320 --> 00:05:15,270 ‫And as you can see, it doesn't do anything. 72 00:05:15,270 --> 00:05:17,160 ‫We can't hit it off. 73 00:05:17,160 --> 00:05:17,730 ‫Why is that? 74 00:05:17,730 --> 00:05:18,690 ‫Is it so strong? 75 00:05:18,690 --> 00:05:20,130 ‫Is it so powerful now? 76 00:05:20,130 --> 00:05:23,040 ‫It has to do with, well, maybe you can figure it out. 77 00:05:23,040 --> 00:05:24,450 ‫Just try to think of it. 78 00:05:24,450 --> 00:05:25,410 ‫What could it be? 79 00:05:26,730 --> 00:05:27,090 ‫All right. 80 00:05:27,090 --> 00:05:30,150 ‫Yeah, it's lacking a rigid body. 81 00:05:30,150 --> 00:05:34,710 ‫So let's add a physics rigid body to our capsule. 82 00:05:34,710 --> 00:05:39,270 ‫And now let's try to hit it with our ball and see what happens. 83 00:05:40,050 --> 00:05:41,310 ‫So let's hit it. 84 00:05:41,610 --> 00:05:41,970 ‫Boom. 85 00:05:41,970 --> 00:05:43,920 ‫And we see it falls off. 86 00:05:44,340 --> 00:05:46,410 ‫So it automatically gets the physics. 87 00:05:46,410 --> 00:05:53,280 ‫And you could use that in order to create a bowling game or a domino game or something like that. 88 00:05:54,240 --> 00:05:54,870 ‫All right. 89 00:05:54,870 --> 00:06:00,840 ‫Next, there is a box collider, so let's create a cube. 90 00:06:00,840 --> 00:06:06,300 ‫And as you can see, the cube has a greenish line here as well. 91 00:06:06,300 --> 00:06:07,050 ‫That is the box. 92 00:06:07,050 --> 00:06:13,290 ‫Collider And you can change the size of the box collider as you can see now I changed the X position 93 00:06:13,290 --> 00:06:15,420 ‫to two or an exercise to do. 94 00:06:15,510 --> 00:06:17,820 ‫You can do that for Y and for Z as well. 95 00:06:17,820 --> 00:06:22,770 ‫So you can make the collider bigger than the actual box itself, as you can see. 96 00:06:22,770 --> 00:06:24,900 ‫And of course the center could also be moved. 97 00:06:24,900 --> 00:06:32,430 ‫So now you could move it to one so that it's higher or that it's at the center pretty much of our cube, 98 00:06:33,120 --> 00:06:35,760 ‫and you can even put it on top of the cube. 99 00:06:35,760 --> 00:06:40,470 ‫So now the cube will fall through, but at the same time, it will still be here. 100 00:06:40,470 --> 00:06:43,770 ‫It will still hang at the bottom of our plane. 101 00:06:43,770 --> 00:06:43,970 ‫Yeah. 102 00:06:43,980 --> 00:06:46,200 ‫So let's add a physics body to that. 103 00:06:46,830 --> 00:06:48,420 ‫Otherwise it won't see it. 104 00:06:48,450 --> 00:06:50,910 ‫Let's add a rigid body, as you can see now. 105 00:06:50,910 --> 00:06:53,880 ‫So now our cube is at the bottom. 106 00:06:53,880 --> 00:07:00,180 ‫Well, actually, the graphics are at the bottom, but the physics themselves are on top of our plane. 107 00:07:01,710 --> 00:07:05,310 ‫All right, then there's one more thing that I would like to show you. 108 00:07:05,460 --> 00:07:11,550 ‫And I'm going to delete my cube and I'm going to delete the capsule as well. 109 00:07:12,240 --> 00:07:17,090 ‫But I'm going to keep the player and I'm going to put it towards the bottom as well. 110 00:07:17,100 --> 00:07:23,830 ‫So now let's say we want to have an underground which is bouncy, actually, let's put the ball up again. 111 00:07:23,850 --> 00:07:25,800 ‫If I want to have an underground that is bouncy. 112 00:07:25,800 --> 00:07:29,940 ‫So let's say this is a huge bouncy on the ground here. 113 00:07:30,240 --> 00:07:33,240 ‫What we need to do is to add a material. 114 00:07:33,270 --> 00:07:39,480 ‫So here you can see that our mesh collider from underground doesn't have any material yet and we can 115 00:07:39,480 --> 00:07:41,150 ‫create a new material. 116 00:07:41,160 --> 00:07:47,010 ‫So let's go to assets create and then it's called physics material. 117 00:07:47,010 --> 00:07:48,750 ‫So you can find physics material. 118 00:07:48,750 --> 00:07:52,980 ‫It's open that up and let's call that bouncy ground. 119 00:07:54,480 --> 00:08:00,660 ‫And that bouncy ground has a dynamic friction, a static friction, a bouncy ness. 120 00:08:00,900 --> 00:08:09,840 ‫And you can combine fractions here so you can multiply frictions and multiply bounce units based on 121 00:08:09,840 --> 00:08:14,610 ‫the objects that collide with each other or that touch each other. 122 00:08:14,910 --> 00:08:17,250 ‫So let's get rid of the friction. 123 00:08:17,250 --> 00:08:21,750 ‫So let's set those to zero and let's add a bouncy ness of one. 124 00:08:21,750 --> 00:08:25,230 ‫So the value of bouncing this is between zero and one. 125 00:08:25,230 --> 00:08:30,120 ‫Usually bouncy ness of one means that it will bounce back with the same force that it came with. 126 00:08:30,120 --> 00:08:36,360 ‫So if we have a look at it now, actually, let's save that with that, with those values, go to the 127 00:08:36,360 --> 00:08:41,730 ‫underground and now let's drag our bounce ground as it's material or let's choose it. 128 00:08:41,730 --> 00:08:48,510 ‫Here you can see you can choose bounce ground and let's start it. 129 00:08:49,550 --> 00:08:54,380 ‫And now you will see our ball bounces and the ball bounces off again. 130 00:08:55,160 --> 00:08:57,740 ‫Now why doesn't it bounce back the same way? 131 00:08:57,890 --> 00:09:00,200 ‫Let's add the bouncing is to the player as well. 132 00:09:00,380 --> 00:09:03,110 ‫So let's add this physics material to the player. 133 00:09:04,320 --> 00:09:05,370 ‫And let's have a look. 134 00:09:08,000 --> 00:09:14,440 ‫Now it will bounce the same height before it didn't because it was influenced by the unbound thickness 135 00:09:14,480 --> 00:09:15,380 ‫of our ball. 136 00:09:16,520 --> 00:09:23,210 ‫And now actually, based on the settings that you have set up for the multiplier, it will bounce even 137 00:09:23,210 --> 00:09:27,180 ‫higher and higher every single time that it bounces. 138 00:09:27,200 --> 00:09:33,380 ‫So if we have a look at bounce ground, it has a bounce index of one and the friction combine is average 139 00:09:33,380 --> 00:09:35,360 ‫and the bounce combined is average as well. 140 00:09:35,390 --> 00:09:41,990 ‫If we now multiply, which is multiplied, they will multiply with each other and they will go even 141 00:09:41,990 --> 00:09:43,220 ‫faster and higher. 142 00:09:44,180 --> 00:09:45,710 ‫So that's how bounce in his works. 143 00:09:45,710 --> 00:09:50,450 ‫You can use bounce illness to bounce off of something that's great. 144 00:09:50,450 --> 00:09:53,630 ‫For example, for our pong game we will use bounce in is there. 145 00:09:54,880 --> 00:09:56,350 ‫Now let's have a look at friction. 146 00:09:56,350 --> 00:09:57,400 ‫So let's. 147 00:09:58,670 --> 00:10:00,680 ‫Delete the bounce ground from our player. 148 00:10:00,680 --> 00:10:05,600 ‫So let's go to none here and let's add a friction to the ground itself. 149 00:10:05,600 --> 00:10:10,010 ‫So the on the ground has our bouncy ground yet or still. 150 00:10:10,010 --> 00:10:24,590 ‫So let's rename that bounce and or bouncy and friction or fricative ground. 151 00:10:24,590 --> 00:10:25,970 ‫I think that's the right term. 152 00:10:26,150 --> 00:10:32,540 ‫So now let's add a friction as well, a dynamic and a static friction. 153 00:10:33,650 --> 00:10:34,880 ‫Now let's start it off. 154 00:10:34,880 --> 00:10:40,850 ‫So we have a friction of one static and dynamic and now let's have a look what happens. 155 00:10:40,850 --> 00:10:46,850 ‫So our ball falls off and now if I move it, it will be reduced. 156 00:10:46,850 --> 00:10:49,280 ‫So the speed of it will be reduced a little bit. 157 00:10:49,910 --> 00:10:53,180 ‫Let's add a physics body to our player as well now. 158 00:10:53,270 --> 00:10:57,380 ‫So let's add it back to our player and let's have a look now. 159 00:10:58,610 --> 00:11:03,650 ‫So they both have a friction of one while they actually have a bounce in us as well. 160 00:11:03,650 --> 00:11:05,600 ‫Actually, our ball has a bounce in this. 161 00:11:07,270 --> 00:11:08,500 ‫Or both of them have a bond. 162 00:11:08,530 --> 00:11:10,420 ‫And so let's put that to zero. 163 00:11:11,110 --> 00:11:14,830 ‫So they won't bounce anymore, but they will still have the friction. 164 00:11:14,920 --> 00:11:21,190 ‫So now we can barely see it here because our ball has a specific speed. 165 00:11:21,250 --> 00:11:27,790 ‫But what it does, it will reduce the tempo of our ball. 166 00:11:28,090 --> 00:11:35,460 ‫So it's like you can imagine it like asphalt in comparison to a very slippery ground. 167 00:11:35,470 --> 00:11:39,110 ‫So if we have no friction, then it's like a slippery ground. 168 00:11:39,130 --> 00:11:46,390 ‫If you have friction of one, that means that you have a very raw ground which is rough and which will 169 00:11:46,390 --> 00:11:48,460 ‫slow down our game object. 170 00:11:48,640 --> 00:11:49,060 ‫All right. 171 00:11:49,060 --> 00:11:50,650 ‫So that's about the colliders. 172 00:11:51,220 --> 00:11:55,360 ‫So whenever you want to add a collider to an object, you can do that. 173 00:11:55,360 --> 00:11:59,110 ‫And as you can see, it will change the behavior of it. 174 00:11:59,200 --> 00:12:04,960 ‫So now let's save the scene and see you in the next video where we'll have a look at triggers.