Rigidbody

Struct Rigidbody 

Source
pub struct Rigidbody {
Show 16 fields pub m_AngularDrag: f32, pub m_CollisionDetection: i32, pub m_Constraints: i32, pub m_Drag: f32, pub m_GameObject: PPtr, pub m_Interpolate: u8, pub m_IsKinematic: bool, pub m_Mass: f32, pub m_UseGravity: bool, pub m_CenterOfMass: Option<Vector3f>, pub m_ExcludeLayers: Option<BitField>, pub m_ImplicitCom: Option<bool>, pub m_ImplicitTensor: Option<bool>, pub m_IncludeLayers: Option<BitField>, pub m_InertiaRotation: Option<Quaternionf>, pub m_InertiaTensor: Option<Vector3f>,
}
Expand description

Rigidbody is a class of the Unity engine since version 3.4.0. Exert from Unity’s scripting documentation: Control of an object’s position through physics simulation. Adding a Rigidbody component to an object will put its motion under the control of Unity’s physics engine. Even without adding any code, a Rigidbody object will be pulled downward by gravity and will react to collisions with incoming objects if the right Collider component is also present.The Rigidbody also has a scripting API that lets you apply forces to the object and control it in a physically realistic way. For example, a car’s behaviour can be specified in terms of the forces applied by the wheels. Given this information, the physics engine can handle most other aspects of the car’s motion, so it will accelerate realistically and respond correctly to collisions.In a script, the FixedUpdate function is recommended as the place to apply forces and change Rigidbody settings (as opposed to Update, which is used for most other frame update tasks). The reason for this is that physics updates are carried out in measured time steps that don’t coincide with the frame update. FixedUpdate is called immediately before each physics update and so any changes made there will be processed directly.A common problem when starting out with Rigidbodies is that the game physics appears to run in “slow motion”. This is actually due to the scale used for your models. The default gravity settings assume that one world unit corresponds to one metre of distance. With non-physical games, it doesn’t make much difference if your models are all 100 units long but when using physics, they will be treated as very large objects. If a large scale is used for objects that are supposed to be small, they will appear to fall very slowly - the physics engine thinks they are very large objects falling over very large distances. With this in mind, be sure to keep your objects more or less at their scale in real life (so a car should be about 4 units = 4 metres, for example).

Fields§

§m_AngularDrag: f32

The angular drag of the object.

§m_CollisionDetection: i32§m_Constraints: i32

Controls which degrees of freedom are allowed for the simulation of this Rigidbody.

§m_Drag: f32

The drag of the object.

§m_GameObject: PPtr

The game object this component is attached to. A component is always attached to a game object. PPtr<GameObject>: (3.4.0 - 2022.3.2f1)

§m_Interpolate: u8§m_IsKinematic: bool

Controls whether physics affects the rigidbody.

§m_Mass: f32

The mass of the rigidbody.

§m_UseGravity: bool

Controls whether gravity affects this rigidbody.

§m_CenterOfMass: Option<Vector3f>

The center of mass relative to the transform’s origin. Vector3f: (2022.2.0b1 - 2022.3.2f1)

§m_ExcludeLayers: Option<BitField>

The additional layers that all Colliders attached to this Rigidbody should exclude when deciding if the Collider can come into contact with another Collider. BitField: (2022.2.0b1 - 2022.3.2f1)

§m_ImplicitCom: Option<bool>

bool: (2022.2.0b1 - 2022.3.2f1)

§m_ImplicitTensor: Option<bool>

bool: (2022.2.0b1 - 2022.3.2f1)

§m_IncludeLayers: Option<BitField>

The additional layers that all Colliders attached to this Rigidbody should include when deciding if the Collider can come into contact with another Collider. BitField: (2022.2.0b1 - 2022.3.2f1)

§m_InertiaRotation: Option<Quaternionf>

Quaternionf: (2022.2.0b1 - 2022.3.2f1)

§m_InertiaTensor: Option<Vector3f>

The inertia tensor of this body, defined as a diagonal matrix in a reference frame positioned at this body’s center of mass and rotated by Rigidbody.inertiaTensorRotation. Vector3f: (2022.2.0b1 - 2022.3.2f1)

Trait Implementations§

Source§

impl Debug for Rigidbody

Source§

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

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

impl<'de> Deserialize<'de> for Rigidbody

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 Rigidbody

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>,