In this tutorial, we going to learn Rigidbody. We going to learn Add Force, Magnitude, Velocity, and other methods. In this tutorial, understand all of Rigidbody.
What Is Rigidbody?
A rigidbody is a component that allows GameObject to react to real-time physics so shortly, rigidbody is the physics component of GameObject. Gravity, force, magnitude, velocity properties are found in the rigidbody component so if you want to use physics properties you can call the rigidbody component.
Preparation For Physics
if you want to prepare before the start, you can look at this youtube channel, this channel has physics and math subject for game development or just you can follow this tutorial.
firstly, we going to learn methods of rigidbody. In this part, we going to learn useGravity, constraints, freezeRotation, and, freezePosition.
useGravity is a boolean method so you can available or disable gravity in the project. Below, has an useGravity syntax.
constraints and freeze
Since constraints and freezing are nested, we will see them in the same section. Constraints are mostly applied for an object to don’t rotate 360 degrees as it falls, or it is used when an object is not desired to move. Below, has constraints and freeze syntax.
Add Force And Velocity In Rigidbody
Now, we going to learn AddForce and velocity, these subjects are generally used in all projects. We going to learn these subjects separately.
Step 1 – AddForce
used to apply force to an object. Force is applied to the object until it reaches the given vector value. They are very similar to velocity, but the biggest difference is that the AddForce function applies the force by dividing it, while velocity applies it directly. an AddForce can go to the given place in 1 second, with the velocity it can be reached in 30 milliseconds.
Step 2 – Velocity
The velocity function is similar to the AddForce function, as we mentioned above, the only difference is the application time of the force.
Extra Step – Creating Extra Gravity
Addforce can also be used to create gravity, we just need a force applied down the y-axis. We will use AddForce for this, not velocity, because gravity does not apply the force directly on you, over time to the force increases. Turn off gravity for a better result.
This topic will facilitate your physics operations, normally this topic is in vectors, but let’s make an additional introduction.
It can be used to compare the magnitudes of 2 vectors. It is found with formula so x * x + y * y + z * z = √¯a = M, but we don’t care about formula if you want to know the formula you can watch this video.