Unity2d Physics engine-rigidbody 2D

Source: Internet
Author: User

Although Rigidbody 2D can be seen as a rigidbody 2D, most of the functionality is consistent, but there are some details.

Some matters:

1. Any 2D collider component added to the same gameobject body or its sub-object is implicitly attached to that Rigidbody 2D.

2. When a collider component is attached to a rigidbody 2D, it follows the Rigidbody 2D movement. This should not be moved by directly setting the offset of the transform or collider.

3. All Collider, attached to the same rigidbody 2D, will not collide with each other.

Rigid body Type:

1. There are three types of rigidbody 2D: Dynamic, kinematic, Static

2. The type of rigid body mainly affects several elements:

A. Move behavior (position, rotation)

B. Collision body Interaction

3. Note that although Rigidbody is often described as colliding with other rigidbody, it is actually attached to the Rigidbody collider in the collision detection, rigidbody in the absence of Collider, It's impossible to collide with each other.

4. Changing the type of Rigidbody 2D is a tricky thing to do. When a rigid body type changes, many associated variables are reset immediately and need to be re-assigned, and all collider associated with the rigid body need to be re-recognized before the next fixiedupdate, which can lead to strange behavior.

Rigid body Type: Dynamic

In summary, this type is designed for physical simulation motion. (Making an object look more like real-world behavior) its motion is affected by gravity, mass, and other forces. And This type will collide with all other rigid body types .

    • Simulated: Whether the component interacts with simulation simulations.
    • Collision Detection: Collision detection between colliding bodies:
      • Discrete: During a physical update, physics can overlap and traverse each other. When the speed is too fast, the collision will only be detected in the latest position, which means that if the speed is too fast, there will be a problem with this option.
      • Continuous: There is no discete problem with this, but CPU consumption is high.
    • Sleeping Model: Under what circumstances, sleep to save performance.
      • Never sleep: Never Sleeps
      • Start Awake: The object was initially awake.
      • Start asleep: The object is initially dormant, but it wakes up when it encounters a collision.
    • Interpolate: An interpolation algorithm for moving objects in physical updates
      • None:
      • Interpolate: Interpolation simulation based on position of previous frame object
      • Extrapolate: Interpolation simulation based on prediction of the position of an object

Rigid body Type: kinematic

This type, object movement is also carried out under simulation, but it is under the premise of the user very clear control .

Attention

1. This type is not affected by force or gravity.

2. It uses the Rigidbody2d.moveposition or Rigidbody2d.moverotation API to move.

3. It uses the physics engine to query for collisions and to programmatically determine how the objects move.

4. In fact, this type still moves through its speed, but its speed is unaffected by any other force.

5. This type does not collide with other kinematic or static types

6. In the collision process, this type of object behaves as an infinite force (mass infinity).

    • Simulated: If you want to interact with a physical emulation at run time with other collider 2D, open it.
    • Use full kinematic constacts: Turn It on, the object can collide with any other type of rigidbody 2D.

Rigid body Type: Static

1. It collides only with the rigidbody of the Dynamic type.

2. Unable to have two Static rigidbody 2D.

Unity2d Physics engine-rigidbody 2D

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.