In this video, you will learn about the different collider types in unity.
As you have already seen in the presentation, there are different kinds of colliders and we already
have worked with two different collider types or actually even three.
So now let's have a look at those collider types.
For example, our player has a Sphere Collider, you can see that here.
So let's go to our player here.
And as you can see, there is this greenish line that you have around the player or around this circle,
and that is our sphere.
Collider It already has gotten automatically a radius of 0.5, which fits the size of our player.
So if I change that to, for example, one, my Sphere Collider will be bigger than the actual graphic
that we can see here.
So let's activate gravity for our player and let's run the game just to see what happens.
Now let's go back.
Let's go into the scene view here.
And as you can see, our ball is on top of the ground.
So it flies around.
It looks as if it flies, but in the end it has to do with the Sphere Collider Because the.
Sphere Collider So our ball collider that you can see here collides with the underground, which has
a mesh collider So that's already the second type of colliders.
This one has a different type of look and it's based on its mesh.
And you can find the mesh by clicking on the mesh here.
And you can see here at the bottom right side, this is the looks of the mesh and that can be very specific.
It can be based on the character.
For example, if your character is a car, then the mesh could be the whole surface of the car.
Mesh is used for surfaces and the mesh collider gives the surfaces a collider.
All right.
So our underground, for example, here has a mesh collider.
From the bottom.
You can see that there is nothing.
And from the top, it has this green color.
So we gave it this green color only from the top.
Now, if we want to have a higher layer for the collider of our mesh collider, we can add convex what
it does.
As you can see now, it has a collider towards the top and towards the bottom of its actual surface
and you can even inflate that.
So if you want to inflate it and make it bigger, you can go ahead and inflate the the collider of our
mesh or of our on the ground.
So if you have a look now, now our ball will be even higher.
So now it's on top of this physics piece.
So if we go ahead and reduce the radius of oh to 0.5, our ball will still be on top of this physics
collider.
So the colliders don't have to be the same size as the objects themselves, but it does of course make
sense to have that in most games.
Maybe your game type is exactly so that it doesn't fit well with each other.
Then you can of course change that.
What you also can do is you can change the center of your collider, at least in this case.
So, for example, the center of my collider could be, let's say, one higher than my ball itself.
So now if we look at it, the Y position is at one.
So now our ball is inside of our underground.
And at the same time, as you can see now, that's how it looks out moves now.
And the physics themselves, they move as intended.
All right.
So it just looks so weird because the radius is bigger and the position of the center is different.
So 000 is the center point of our sphere.
And well, if we change any of that, we'll change the center of the collider.
Now, let's go back to 0.5.
Let's set that back because that's the standard.
Collider Well, that's the sphere.
Collider Let's have a quick look at some other colliders, for example, the Capsule Collider So that
one is our capsule collider And as you can see, it has the form of a capsule and it also has the attributes
of center, it has a radius and it has a height, and you can even change the axis towards which you
want to.
Collider To be.
So y axis is going up, x axis is going to decide, as you can see here, and z axis is going towards
the other side, as you can see here now.
All right.
So let's put that back to y axis because the standard and now what I want to do is start my game.
So I'm going to start the player here.
So now let's try to hit that collider here and make it fall off because now it does have a collider.
So let's see.
And as you can see, it doesn't do anything.
We can't hit it off.
Why is that?
Is it so strong?
Is it so powerful now?
It has to do with, well, maybe you can figure it out.
Just try to think of it.
What could it be?
All right.
Yeah, it's lacking a rigid body.
So let's add a physics rigid body to our capsule.
And now let's try to hit it with our ball and see what happens.
So let's hit it.
Boom.
And we see it falls off.
So it automatically gets the physics.
And you could use that in order to create a bowling game or a domino game or something like that.
All right.
Next, there is a box collider, so let's create a cube.
And as you can see, the cube has a greenish line here as well.
That is the box.
Collider And you can change the size of the box collider as you can see now I changed the X position
to two or an exercise to do.
You can do that for Y and for Z as well.
So you can make the collider bigger than the actual box itself, as you can see.
And of course the center could also be moved.
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,
and you can even put it on top of the cube.
So now the cube will fall through, but at the same time, it will still be here.
It will still hang at the bottom of our plane.
Yeah.
So let's add a physics body to that.
Otherwise it won't see it.
Let's add a rigid body, as you can see now.
So now our cube is at the bottom.
Well, actually, the graphics are at the bottom, but the physics themselves are on top of our plane.
All right, then there's one more thing that I would like to show you.
And I'm going to delete my cube and I'm going to delete the capsule as well.
But I'm going to keep the player and I'm going to put it towards the bottom as well.
So now let's say we want to have an underground which is bouncy, actually, let's put the ball up again.
If I want to have an underground that is bouncy.
So let's say this is a huge bouncy on the ground here.
What we need to do is to add a material.
So here you can see that our mesh collider from underground doesn't have any material yet and we can
create a new material.
So let's go to assets create and then it's called physics material.
So you can find physics material.
It's open that up and let's call that bouncy ground.
And that bouncy ground has a dynamic friction, a static friction, a bouncy ness.
And you can combine fractions here so you can multiply frictions and multiply bounce units based on
the objects that collide with each other or that touch each other.
So let's get rid of the friction.
So let's set those to zero and let's add a bouncy ness of one.
So the value of bouncing this is between zero and one.
Usually bouncy ness of one means that it will bounce back with the same force that it came with.
So if we have a look at it now, actually, let's save that with that, with those values, go to the
underground and now let's drag our bounce ground as it's material or let's choose it.
Here you can see you can choose bounce ground and let's start it.
And now you will see our ball bounces and the ball bounces off again.
Now why doesn't it bounce back the same way?
Let's add the bouncing is to the player as well.
So let's add this physics material to the player.
And let's have a look.
Now it will bounce the same height before it didn't because it was influenced by the unbound thickness
of our ball.
And now actually, based on the settings that you have set up for the multiplier, it will bounce even
higher and higher every single time that it bounces.
So if we have a look at bounce ground, it has a bounce index of one and the friction combine is average
and the bounce combined is average as well.
If we now multiply, which is multiplied, they will multiply with each other and they will go even
faster and higher.
So that's how bounce in his works.
You can use bounce illness to bounce off of something that's great.
For example, for our pong game we will use bounce in is there.
Now let's have a look at friction.
So let's.
Delete the bounce ground from our player.
So let's go to none here and let's add a friction to the ground itself.
So the on the ground has our bouncy ground yet or still.
So let's rename that bounce and or bouncy and friction or fricative ground.
I think that's the right term.
So now let's add a friction as well, a dynamic and a static friction.
Now let's start it off.
So we have a friction of one static and dynamic and now let's have a look what happens.
So our ball falls off and now if I move it, it will be reduced.
So the speed of it will be reduced a little bit.
Let's add a physics body to our player as well now.
So let's add it back to our player and let's have a look now.
So they both have a friction of one while they actually have a bounce in us as well.
Actually, our ball has a bounce in this.
Or both of them have a bond.
And so let's put that to zero.
So they won't bounce anymore, but they will still have the friction.
So now we can barely see it here because our ball has a specific speed.
But what it does, it will reduce the tempo of our ball.
So it's like you can imagine it like asphalt in comparison to a very slippery ground.
So if we have no friction, then it's like a slippery ground.
If you have friction of one, that means that you have a very raw ground which is rough and which will
slow down our game object.
All right.
So that's about the colliders.
So whenever you want to add a collider to an object, you can do that.
And as you can see, it will change the behavior of it.
So now let's save the scene and see you in the next video where we'll have a look at triggers.