We'll come back.
In this video, we will have a look at the rigid body.
And therefore, what I'll do first is save my scene.
So let's save the scene as and I'm going to call that main because what we haven't done yet is save
scenes and you should that should do that regularly.
So you should save your scene.
And now you can see that here it says Main now.
So whenever you make a change and you want to keep that, you always should press control, save.
Or you could go here to save scenes.
All right.
So now let's go ahead and choose our player, because he already has a rigid body.
And as I said, there are multiple different properties.
We only had to look at use gravity yet.
So now let's have a look at the mass, for example, and therefore I would like to make our world a
bit bigger.
So I'm going to scale the underground up to five, five and five.
Actually, the Y value can stay one.
It doesn't matter because it doesn't really have a height.
Our plane.
So now let's have a look at our game mode.
All right, that's good.
And now I would like to use my own layout, which allows me to see my game from the scene view and the
game view.
At the same time here 2D is activated, so now I can only see the game from a 2D angle.
So I'm going to change that.
I'm deactivating this to two D button and now I can see it here as well.
So that can be useful in some occasions.
All right.
So now that is my game and my ball.
And now let's move the ball.
Let's run the game.
And as you can see, the ball is moving.
So now I'm activating or opening my hierarchy view.
I'm going to go to player.
And what I can do here is, for example, change the mass.
So if I change the mass to 2000 now and I'm going to pause the game, I'm going to change the mass to
2000, I'm going to start the game again.
And now I can barely move my ball, or even not at all, because my force that I'm applying is way too
little, or actually just a little bit.
I can move the ball very, very slowly.
So I'm applying the force, and that has to do with the speed and the mass, of course.
So the speed applies, some force multiplied with whether we press forward or backward.
So if I extend the speed to, let's say, 200 now, my ball will start to move after a while because
200 is enough force for the ball to be moving.
But it moves super slowly, as you can see here.
All right.
And then if I try to go backward or it's too too hard, if I change the mass to one again, now you
can see, whoa, the ball is moving super duper fast.
And it fell off my screen or my my area.
Even so, if I change the mass to one again and my speed to, let's say 50 and let's start the game
again.
Now my ball will be much, much faster and it will constantly apply force so that the ball will become
faster and faster and faster.
And that's something that you can change.
So you can add and drag to your ball or to your game object so that the speed is limited.
So let's add a drag of ten, as you can see.
Now, my ball, even if I'm pressing for a long time, it will not exceed a specific speed.
So that's the speed that it goes with and it can't go any faster because it has a drag assigned to it.
It's the same thing with the angular drag.
If I want to change the rotation speed of my object, I could change the angular drag here.
Now use gravity.
We've seen that.
If we activate that, then we use the gravity so our ball can fall off.
Or it fall down.
As you can see now, it falls down slowly.
And if I deactivate the gravity, my ball will stay in the air.
As you can see now, it's still in the air.
You can see it here even better.
Let's use gravity and but we still can move our ball.
As you can see, it doesn't apply any gravity, but we can still move the ball.
However, if we apply is kinematic, we cannot move the ball anymore.
So what is kinetic?
Does it will deactivate any kind of movement so it's not influenced by the physics world anymore, which
means adding force within our player movement script does not do anything because as I said, it doesn't
care about the physics world anymore.
All right, so it's kinematic.
We can use that for walls if we don't want them to be influenced by physics, but still be walls.
So still be a force to reckon with or something that just stops our player or our game object.
Then we can use interpolate.
As I explained in the last video, that's for the case that you animate your player and you want it
to be dependent on the physics world.
So that could be important if you use that.
So then you could use interpolate or extrapolate.
Then the collision detection is discrete by default, which is most of the time completely fine.
Continuous dynamic is if you have super fast movement, then you want the collision detection to be
extremely fast.
Then continuous dynamic is the better choice and otherwise continuous is fine as well.
So continuous dynamic is for very, very fast games where physics is very important and goes very quickly.
But as I said, discrete is is fine for most of the cases and it's also the best in terms of resources.
And finally, let's have a look at constraints.
You can freeze positions and freeze rotations.
So, for example, if I choose my player and now I move my player to the top and I wanted to not go
down, of course I could use use gravity or I can simply activate freeze position y.
So now the y position will be frozen and our ball will never fall off.
We can still move it, but the y position is simply fixed and we can even activate gravity.
It will not influence our ball because the y position is.
Fixed or is frozen.
Now the same thing goes with the X position.
So that means now I can move the ball downwards.
Let's activate gravity, but I cannot move it to the right and left.
I can only move it backwards and forwards.
Same goes with the Z position.
So if I activate that and I deactivate the X position now, I can not move forward.
Actually, it's not used.
It doesn't use gravity.
So now I cannot go forward.
I can only go to the left and to the right.
Same goes with the rotation.
So in our case we have this little ball, so or this little player.
Let's give him another 3D object which can be, let's say, a cube.
So I wanted to have a little cube on top of it and I'm going to make it 0.2 and oh point.
Well, actually, let's use one here.
Now you can see it better.
So now that's our ball.
Let's click on the player and let's activate gravity again.
So if I move to the left and right, as you can see, it rotates.
And now even even flies sometimes, because as you can see, the cube changes the behavior of our ball
relatively quickly.
And what you can do is freeze the rotation towards X, for example.
Now, it will only rotate in a certain direction.
Let's freeze the rotation towards Y as well.
As you can see, the Y rotation is not influenced anymore, so our ball only rotates towards the z coordinate
currently.
And if I deactivate that as well now, it will not rotate anymore.
It will only move around in our physics world, which might be the behavior that you want to have.
So what can happen is if you have an object that could fall off and if you don't have the functionality
program that it stands up again, what you can do is freeze rotation so it will never fall down or fall
forward or to decide something.
So you could freeze rotations for that.
All right.
So that's about the rigid body.
It's really important if you want to impact anything via physics, it needs to have a rigid body, otherwise
it won't work.
All right.
So I'm going to get rid of the cube again.
As you can see, you can get some very funny behavior with your ball here, with your player if you
add a cube to it or if you change the shape.
So please go ahead and play with it and have some fun.
And yeah, in the next video we will have a look at the colliders.
So there are different types of colliders and we're going to have a look at the most important ones.
So see you there, by the way.
Don't forget to save your scene.
So see you in the next video.