Let’s talk about Unity Rigidbody2d. The Unity Rigidbody component enables the imitation of physical movements as in the real world with the Unity physics engine. You can think of movements as objects falling by gravity in their simplest form, rounded objects remain constant while rounded objects are AND thanks to this component we can also give objects the ability to move realistically.
For example, in a model car, we can move the car forward by applying a rotational force (torque) to the wheels and moving it from right to left. to change the rotation of the wheels As you can see, the power of the physics engine offers us ease that should not be underestimated. Now let’s see what properties the Unity Rigidbody component has and what it looks like in the inspector.
Unity Rigidbody Component
First, I want you to add 1 layer and 1 sphere to the scene. Also, place the sphere a little higher than the flat object. These two objects are game objects with a collider-type component that we need to perform physical operations. If you don’t know the Rigidbody component in our sphere object, we can add a component (component) to each GameObject.Add GameObject and Component and more detailed information can be found at Unity – GameObject? can be found in our article.
All you have to do is click the “Add Component” button in the inspector area after selecting the object and then type “Rigidbody” in the search area. The required component appears and is added to the object when clicked. Now you can start the game for a little test drive and watch the ball move down. As I said, make sure he’s on the plane.
Unity Rigidbody features
If you look at the components pane in the Inspector panel, you will notice that there are some fields. These are properties that you can change through the control panel or code, and thanks to these properties you can run the physical simulations you want to create. exactly what you want. As in the real world, you will benefit from a little knowledge of physics and math, as this is where physical formulas are used. Now let’s examine the properties one by one and see what they do.
Represents the weight of the object in kilograms. It is important because of the physical forces you will be using. For example, the distance it covers when you hit an iron ball of the same size is different from the distance it covers when you hit a soccer ball. One of the most fundamental factors that determine this difference is weight.
The value of the drag/friction of the object when a force is applied. This value makes it less force affected, which means it creates slower movements. With a value of 0, there is no movement restriction, with a value of “infinite” the object stops immediately.
Angular Unity DG
Another type of UnityDG shows an object against force. Here we indicate how much resistance arises when rotating and not when rotating as opposed to the movement. Again, if we give a value of 0 it has no resistance, but using the infinite value here will not stop the rotation, rotation, completely.
This value, which takes the value True or False, indicates whether our object is influenced by gravity. If you want to create a gravity-free environment like space this can be very useful. Or in cases where objects are supposed to float slightly in the air. The possibilities are endless, aren’t they?
this variable, which in turn assumes the value true or false, makes it possible to exclude the object from all physical interactions. If it is true, no force will cause the movement, neither by code nor by hitting objects in the game, it is a function that makes your work easier when you use structures like Ragdoll or HingeJoint.
a property in which I determine whether to undergo a smoothing when calculating the movement of an object using physical operations. If you are experiencing tremors while providing the movement with Unity Rigidbody, tampering with this setting will solve your problem. There are 3 values it can take.