Original document address:Http://unity3d.com/support/documentation/Components/class-Rigidbody.html
A rigid body allows your game objects to be controlled by the physical engine. It can achieve real physical performance through thrust and torsion. All game objects must contain Rigid Body components to achieve gravity, apply force through scripts, or interact with other objects, all through the NVIDIA physx physical engine.
Attribute
Mass Quality, in kg. We recommend that you do not set the quality difference between objects to more than 100 times.
Drag air resistance. 0 indicates no resistance, and infinity indicates stop moving immediately.
Angular drag torque resistance. The numerical value is the same as above.
Whether use gravity is affected by gravity
Is whether kinematic is a kinematic rigid body. If this parameter is enabled, the object is not controlled by physics. It can only be operated by directly setting the position, rotation, and scaling. It is generally used to implement mobile platforms, or an animated rigid body with hingejoint
Interpolate if your rigid body motion is jittery, try to modify this parameter. None indicates no interpolation, and interpolate indicates smooth interpolation based on the position of the previous vertex, extrapoate indicates smooth interpolation based on the predicted position of the next vertex.
Freeze rotation If this option is selected, the rigid body will not rotate due to external force or torque. You can only operate through the rotation function of the script.
Collision Detection collision detection algorithm, used to prevent a rigid body from moving through other objects quickly
Constraints on the motion of a constraints rigid body, including the position and rotation constraints. If this option is selected, such operations are not allowed on the coordinate.
Detailed description
The rigid body puts your game objects under the control of the physical engine, opening the door for real collision, various connection types, and various other effects. Moving a rigid body by applying an external force is very different from moving it by setting its position transformation. Generally, you do not operate on Rigid Bodies and transformations at the same time. You only use one of them.
The biggest difference between the two lies in the use of the force (Forces), just physical acceptance of the thrust and torque, the conversion is not acceptable. Location change and rotation can also be achieved through the transformation, but this is different from the physical engine. Applying force to a rigid body also affects the transformation value of the object, which is one of the reasons why only the two can be used. If the transformation of a rigid body is directly operated at the same time, there will be problems when performing collision and other operations.
You must add the Rigid Body component to your game object as shown in the following figure. Use the menu item component->
Physics-> The Rigidbody can be added. After that, the object is under the control of the physical engine. It will be affected by the gravity and fall. It can also be forced by the script, however, you may need to add a collider or joint to make it more like what you expected.
Parenting
When an object is under the control of a physical engine, its motion is semi-independent from the movement of its parent object. If you move any parent object, they will pull the sub-object of the rigid body. However, the rigid body will fall under the influence of gravity and collision.
Scripting
The method to control the Rigid Body is to apply the thrust and torque through the script, and call the addforce () and addtorque () Methods on the rigid body object. Once again, when you use a physical engine to control the rigid body, do not directly operate on the transformed value of the object.
Animation
In some cases, you may need to switch between animation and physical control when creating the paper doll effect. You can set the rigid body to iskinematic. When it is set to kinematic mode, it will not be affected by external forces. At this time, you can only operate on objects by means of transformation, but the kinematic rigid body will affect other rigid bodies, but it will not be controlled by the physical engine itself. For example, joints connected to the kinematic rigid body will continue to affect the connection of another non-Kinematic rigid body, and can also generate collision force for other rigid bodies.
Colcyclers
A collision body is another type of component that must be manually added to enable object collision. When two rigid bodies come into contact with each other, the physical engine will not calculate their collision unless the collision attribute is set for both rigid bodies. A rigid body without a collision body will simply pass through other rigid bodies during physical simulation.
Composed colcyclers
It is composed of multiple basic collision objects and plays an independent collision object. When you have a complex model and you cannot use mesh collider, you can use a combination of collision bodies.
Continuous Collision Detection
CCD is used to prevent fast moving objects from passing through other objects. When the default discrete collision detection is used, if the object is on the wall side in the previous half, the object has reached the other side of the wall in the next half, then, the collision detection algorithm will not detect the collision. You can set the collision detection attribute of this object to continuous. Then, the collision detection algorithm will prevent the object from passing through all static collision bodies, if it is set to continuous dynamic, it will also prevent other rigid bodies that are also set to continuous or continuous dynamic. CCD only supports collision bodies of box, sphere and capsule.
Use the right size
When using the physical engine, the size of the game object is more important than the quality of the rigid body. If you find that the behavior of a rigid body is not what you expected, such as moving too slowly, floating, or failing to correctly collide, try to modify the scaling value of your model. The default unit of unity is 1 unit = 1 meter, and the calculation of the physical engine is based on this unit. For example, the collapse of a skyscraper is totally different from that of a toy house built by building blocks. Therefore, objects of different sizes should be in a unified proportion During modeling.
For a human role model, it should be 2 meters high. You can create a box as a reference object. The default box is 1 meter, so a role should be twice as high as a box.
Of course, you can also adjust the proportion by modifying the scaling of the import model, if you cannot directly modify the model itself. Select a model on the project panel and adjust its importer attribute. Note that the model is not scaled in the transformation.
If your game requires you to instantiate an object with different scaling values, you can also adjust the scaling value in the transformation, but the physical engine will do more work when creating this object, this may cause some performance problems. This problem is not too serious, but the performance is obviously lower than the above two methods. It should also be noted that non-uniform scales may also cause some problems, if this object has a parent object. Based on the above reasons, we try to build a model based on the ratio of unity when creating the model.
Hints
The relative quality of the two rigid bodies determines how they will respond during the collision.
Setting a higher quality for a rigid body does not make it drop faster. To achieve this, use the drag parameter.
The low resistance makes the object look heavier, and the high resistance makes the object look lighter. The typical drag value is between 0.001 (solid metal) and 10 (feather.
If you want to use both transformation and physics to control objects, give it a rigid body component and set it to kinematic.
If you want to move an object through transformation and receive the collision message of the object, you must give it a rigid body component.
Original article, reprinted Please note:Reprinted fromAll-iPad.net
Link:
Unity 3D physics-Rigidbody Rigid Body
Mass (quality ):
Everyone who has learned physics knows that the larger the quality, the greater the inertia. The units here can be defined by themselves, but the official suggestion is that the object quality in the scenario should not differ by more than 100. It is estimated that the collision between two mass objects will lead to an excessively high speed, thus affecting the game performance.
Drag (resistance): this refers to air resistance. When a game object receives a force, the larger the value, the more difficult it is to move. If it is set to an infinite number, the object will immediately stop moving.
Angular drag (angle resistance ):
It also refers to air resistance, but it is used to prevent the rotation of objects. If it is set to an infinite number, the object will immediately stop rotating.
Use gravity (gravity ):
If this option is selected, the game object will be affected by gravity.
Is kinematic (dynamic or not ):
Selecting this option will not affect the game object from the physical engine, but it is not the same as having no rigid body components. This is usually used for rigid bodies that require animation control, so that animation will not be affected by inertia.
Interplate:
None (no difference value): The difference value is not used for smoothing.
Interpolate: smooth movement based on the previous frame.
Extrapoate: calculates the position of the next object to move smoothly.
Collision Detection (Collision Detection Method ):
Discrete (discrete): the default collision detection method. However, when object a moves fast, it is possible that the previous frame is still in front of object B, and the next frame is behind object B. In this case, the collision event will not be triggered, therefore, if you need to detect this situation, you must use the last two detection methods.
Continuous (continuous): This method can be used to perform Collision Detection with Game objects with static mesh referer.
Continuous Dynamic: This method can be used to perform Collision Detection with all game objects with 2 or 3 sets.
Freeze position/rotation (freeze position/rotation ):
You can lock the position/rotation of an object on the X, Y, and Z axes. The position/rotation won't change even if it is subjected to the corresponding force, but it can be modified through the script.At last, let's take a look at the constant force component (constant force). Since it is easier to understand, I will not elaborate on it. There are a total of four parameters, namely Force/relative force (World/relative force) and torque/relative torque (World/relative torque ). These parameters represent the size of the constant force in the direction of the XYZ axis attached to the rigid body. In addition, you must note that the constant force can be added only to the rigid body. If you are interested, you can try to give the object a Y-axis force, and the object will fly to the sky like a rocket, haha.