"Unity" 11.2 rigid Body (rigidbody)

Source: Internet
Author: User
Tags unity 5

Categories: Unity, C #, VS2015

Date Created: 2016-05-02 I. INTRODUCTION

The Rigidbody (rigid body) component allows the game object to be controlled in the physical system, allowing the body to accept external forces and torque forces to make the game object move as it does in the real world.

Any game object that has a rigid component added to it can be affected by gravity.

By scripting the forces added to the game object, and by interacting with other game objects through the Nvidla physics engine, you need to add a rigidbody component to the game object. Ii. How to add a rigid body to an object

The way to add a rigid body component to a game object in Unity 5.x is to select the game object to which you want to add a rigid body--"Component"--"Physics" and "rigidbody" to add a rigid body to the object.

After you add a rigid body and a collision body, select the object and you'll see it surrounded by a layer of green border:

The purpose of adding rigid bodies and colliding bodies is primarily to detect collisions between the object and other objects. The collision body can be achieved either in capsules or with other colliding body components. Third, related attributes

The properties associated with the Rigidbody are as follows.

1, Mass (quality)

The quality of the object (any unit). The mass should not be 100 times times larger or smaller than the mass of other rigid bodies (Rigidbody).

2. Drag (Resistance)

The degree to which the air resistance affects the object when moved due to the force exerted. 0 means no air resistance, the air resistance is infinite and the object stops moving immediately.

3. Angular Drag (angular resistance)

The degree to which the air resistance affects an object when it is rotated by imposing a torque on it. 0 means no air resistance. Note: You cannot stop rotation simply by setting its "angular resistance" (Angular Drag) to an Infinity Ambassador object.

4, use Gravity (whether using gravity)

If enabled, the object will be affected by gravity.

5, is kinematic (whether to open kinematics)

If enabled, the object is not driven by the physical engine, but can only be processed by applying transformations (Transform) to it. For mobile platforms such as mobile phones, or for animating a rigid body (rigidbody) with a hinged joint (hingejoint) attached, it is useful to turn on kinematics for an object.

6, Interpolate (interpolation processing)

This item is used to control the jitter of the rigid body motion. Try one of these options only if you find the instability in the rigid body (rigidbody) Move:

None: Interpolation is not applied.

Interpolate: interpolated. Transformations (Transform) are smoothed based on the transformation of the previous frame (Transform).

Extrapolate: outer plug. Transformations (Transform) are smoothed based on the next frame's estimated transform (Transform).

7, collision Detection (Collision detection)

This property is used to control the game object that avoids high-speed movement through other objects without collisions. Options are:

(1) discrete (discrete)

All other colliding bodies (Collider) in the scene use discrete (discreet) collision detection. The item is the default value.

(2) continuous (continuous)

When conducting a collision test on a rigid body (rigidbody), a discrete (discreet) collision detection is used for a dynamic collision body (Collider) with a rigid body, and a continuous (static mesh Collider) without a rigid body (continuous ) Collision detection.

(3) Continuous dynamic (continuous)

This option is available for fast-moving objects.

Use continuous (continuous) collision detection for objects that are set to "continuous" (continuous) and "continuous dynamic" (continuous dynamic) collisions. It also uses continuous (continuous) collision detection for static mesh collisions without rigid bodies. For all other colliding bodies (Collider), use discrete (discreet) collision detection.

NOTE: Continuous dynamic (continuous dynamic) detection of objects that need to collide with them has a very large impact on physical performance and should be set to "discrete" (discreet) rather than continuous dynamic if there is no problem with collisions of fast objects.

8. Constraints (Constraint)

Restrictions on the movement of rigid bodies (Rigidbody).

(1) Freeze Position (frozen position)

Selectively stops rigid body (rigidbody) movement on world coordinates X, Y, and Z axes. That is, the movement of the rigid object's X, Y, and 4 in the world coordinate system by the direction (tick state) will not be valid.

(2) Freeze Rotation (frozen rotation)

Selectively stops the rotation of the rigid body (rigidbody) around world coordinates X, Y, and Z axes. That is, the rotation of the rigid object's X, Y, and 4 in the world coordinate system by the direction (tick state) will not be valid. Third, the matters needing attention

1, Rigidbody and transform can only two select one

A rigid body (rigidbody) causes the game object to move under the control of the physical engine, for example, to open doors or calculate other behaviors in the form of a real collision. By adding forces to a rigid body to manipulate the game object, this is significantly different from the visual and the perception of the direct adjustment of the transform component. In general, it is not necessary to manipulate the transform of an object rigid body, but only two is required.

The biggest difference between manipulating the game object's rigidbody and manipulating the object's transform is that the rigid body has a force, and the rigid body can accept external forces and torques, but transform cannot achieve the effect. Transform can move and rotate game objects, which is not the same as using physics.

Adding an external force or torque to a rigid body can actually change the movement and rotation of the object's transform component, which is why the two need only be selected. Using the physical manipulation of the object while changing its transform can lead to problems with collisions and other related computations.

A rigid body must be explicitly added to a game object before it is affected by the physical engine, and then the object will be affected by gravity and the forces added by the script, but depending on the actual situation it may also be necessary to add a collision body or joint to achieve the desired behavioral effect.

2. Parent-Child (parenting)

When an object is under physical control, it moves in a way that is semi-independent of how its transformation parent moves. If any parent is moved, the children of the rigid body (rigidbody) are pulled along with them. However, the rigid body (rigidbody) will still fall due to the action of gravity and respond to the collision event.

3. Script Processing

To control a rigid body (rigidbody), use a script to add force or torque. This can be done by calling Addforce () and Addtorque () on the object's rigid body (rigidbody).

Remember: You should not change the transformation of an object directly (Transform) when using physics.

4. Animation

In some cases, if you need to create a ragdoll effect, you need to switch the control of the object between the animation and the physical system. Therefore, when a rigid body is marked as a kinetic (iskinematic) mode, it is not affected by collisions, forces, or other physical effects, which means that the object needs to be manipulated directly by manipulating its transform component properties. A kinetic rigid body (kinematic rigidbody) affects other objects, but is not affected by the physical system itself. For example, those bound to a dynamic (kinematic) object (Joint) constrain other rigid bodies (Rigidbody) bound to the object, and dynamic rigid bodies (kinematic rigidbody) will shadow other rigid bodies as they collide.

"Unity" 11.2 rigid Body (rigidbody)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.