Rigidbody2D

Struct Rigidbody2D 

Source
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: f32

Coefficient of angular drag.

§m_CollisionDetection: i32§m_GameObject: PPtr

The 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: f32

The degree to which this object is affected by gravity.

§m_Interpolate: i32§m_LinearDrag: f32§m_Mass: f32

Mass 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)

Trait Implementations§

Source§

impl Debug for Rigidbody2D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Rigidbody2D

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Rigidbody2D

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,