pub struct Rigidbody2D {Show 18 fields
pub m_AngularDrag: f32,
pub m_CollisionDetection: i32,
pub m_GameObject: PPtr,
pub m_GravityScale: f32,
pub m_Interpolate: i32,
pub m_LinearDrag: f32,
pub m_Mass: f32,
pub m_SleepingMode: i32,
pub m_BodyType: Option<i32>,
pub m_Constraints: Option<i32>,
pub m_ExcludeLayers: Option<BitField>,
pub m_FixedAngle: Option<bool>,
pub m_IncludeLayers: Option<BitField>,
pub m_IsKinematic: Option<bool>,
pub m_Material: Option<PPtr>,
pub m_Simulated: Option<bool>,
pub m_UseAutoMass: Option<bool>,
pub m_UseFullKinematicContacts: Option<bool>,
}Expand description
Rigidbody2D is a class of the Unity engine since version 4.3.0. Exert from Unity’s scripting documentation: Rigidbody physics component for 2D sprites. The Rigidbody2D class essentially provides the same functionality in 2D that the Rigidbody class provides in 3D. Adding a Rigidbody2D component to a sprite puts it under the control of the physics engine. By itself, this means that the sprite will be affected by gravity and can be controlled from scripts using forces. By adding the appropriate collider component, the sprite will also respond to collisions with other sprites. This behaviour comes entirely from Unity’s physics system; very little code is required to get impressive and authentic physical behaviour and allows for “emergent” gameplay that was not explicitly coded into the game.See Also: Rigidbody class, SpriteRenderer class, Collider2D class, Joint2D class.
Fields§
§m_AngularDrag: f32Coefficient of angular drag.
m_CollisionDetection: i32§m_GameObject: PPtrThe game object this component is attached to. A component is always attached to a game object.
PPtr<GameObject>: (4.3.0 - 2022.3.2f1)
m_GravityScale: f32The degree to which this object is affected by gravity.
m_Interpolate: i32§m_LinearDrag: f32§m_Mass: f32Mass of the Rigidbody.
m_SleepingMode: i32§m_BodyType: Option<i32>The physical behaviour type of the Rigidbody2D. i32: (5.5.0f3 - 2022.3.2f1)
m_Constraints: Option<i32>Controls which degrees of freedom are allowed for the simulation of this Rigidbody2D. i32: (5.1.0f1 - 2022.3.2f1)
m_ExcludeLayers: Option<BitField>The additional Layers that all Collider2D attached to this Rigidbody2D should exclude when deciding if a contact with another Collider2D should happen or not. BitField: (2022.2.0b1 - 2022.3.2f1)
m_FixedAngle: Option<bool>bool: (4.3.0 - 5.0.4f1)
m_IncludeLayers: Option<BitField>The additional Layers that all Collider2D attached to this Rigidbody2D should include when deciding if a contact with another Collider2D should happen or not. BitField: (2022.2.0b1 - 2022.3.2f1)
m_IsKinematic: Option<bool>Should this rigidbody be taken out of physics control? bool: (4.3.0 - 5.4.6f3)
m_Material: Option<PPtr>PPtr<PhysicsMaterial2D>: (5.5.0f3 - 2022.3.2f1)
m_Simulated: Option<bool>Indicates whether the rigid body should be simulated or not by the physics system. bool: (5.5.0f3 - 2022.3.2f1)
m_UseAutoMass: Option<bool>Should the total rigid-body mass be automatically calculated from the [[Collider2D.density]] of attached colliders? bool: (5.3.0f1 - 2022.3.2f1)
m_UseFullKinematicContacts: Option<bool>Should kinematic/kinematic and kinematic/static collisions be allowed? bool: (5.5.0f3 - 2022.3.2f1)