Provides physics movement and other dynamics, and the ability to attach Collider2D to it.
The Rigidbody2D is a fundamental physics component that provides multiple simulation dynamics, such as Rigidbody2D.position and Rigidbody2D.rotation for pose control, and Rigidbody2D.linearVelocity and Rigidbody2D.angularVelocity for velocity control.
You can attach multiple Collider2D to a Rigidbody2D to detect collisions and provide a collision response when you set Rigidbody2D.bodyType to RigidbodyType2D.Dynamic.
| Property | Description |
|---|---|
| angularDamping | The angular damping of the Rigidbody2D angular velocity. |
| angularVelocity | Angular velocity in degrees per second. |
| attachedColliderCount | Returns the number of Collider2D attached to this Rigidbody2D. |
| bodyType | The physical behaviour type of the Rigidbody2D. |
| centerOfMass | The center of mass of the rigidBody in local space. |
| collisionDetectionMode | The method used by the physics engine to check if two objects have collided. |
| constraints | Controls which degrees of freedom are allowed for the simulation of this Rigidbody2D. |
| excludeLayers | The additional Layers that all Collider2D attached to this Rigidbody2D should exclude when deciding if a contact with another Collider2D should happen or not. |
| freezeRotation | Controls whether physics will change the rotation of the object. |
| gravityScale | The degree to which this object is affected by gravity. |
| includeLayers | The additional Layers that all Collider2D attached to this Rigidbody2D should include when deciding if a contact with another Collider2D should happen or not. |
| inertia | The Rigidbody's resistance to changes in angular velocity (rotation). |
| interpolation | Physics interpolation used between updates. |
| linearDamping | The linear damping of the Rigidbody2D linear velocity. |
| linearVelocity | The linear velocity of the Rigidbody2D represents the rate of change over time of the Rigidbody2D position in world-units. |
| linearVelocityX | The X component of the linear velocity of the Rigidbody2D in world-units per second. |
| linearVelocityY | The Y component of the linear velocity of the Rigidbody2D in world-units per second. |
| localToWorldMatrix | The transformation matrix used to transform the Rigidbody2D to world space. |
| mass | Mass of the Rigidbody. |
| position | The position of the rigidbody. |
| rotation | The rotation of the rigidbody. |
| sharedMaterial | The PhysicsMaterial2D that is applied to all Collider2D attached to this Rigidbody2D. |
| simulated | Indicates whether the rigid body should be simulated or not by the physics system. |
| sleepMode | The sleep state that the rigidbody will initially be in. |