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: f32The angular drag of the object.
m_CollisionDetection: i32§m_Constraints: i32Controls which degrees of freedom are allowed for the simulation of this Rigidbody.
m_Drag: f32The drag of the object.
m_GameObject: PPtrThe 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: boolControls whether physics affects the rigidbody.
m_Mass: f32The mass of the rigidbody.
m_UseGravity: boolControls 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)