Class Rigidbody3D
Inheritance
Namespace: Motphys.Rigidbody
Assembly: solution.dll
Syntax
public class Rigidbody3D : MonoBehaviour
Fields
MAX_MASS
Declaration
public const float MAX_MASS = 1E+09F
Field Value
Type | Description |
---|---|
System.Single | The maximum mass of a rigidbody. |
Properties
angularDrag
Declaration
public float angularDrag { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Angular drag can be used to slow down the rotation of an object. The higher the drag the more the rotation slows down. |
angularVelocity
Declaration
public Vector3 angularVelocity { get; set; }
Property Value
Type | Description |
---|---|
Vector3 | The angular velocity of the rigidbody in world space. If the rigidbody is kinematic, the velocity is always zero. |
centerOfMass
Declaration
public Vector3 centerOfMass { get; set; }
Property Value
Type | Description |
---|---|
Vector3 | The center of mass of the rigidbody in local space. |
detectCollisions
Declaration
public bool detectCollisions { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | This property is not serialized and not appeared in inspector. You can only set it in code. By default, it is always true. |
drag
Declaration
public float drag { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Drag can slow down the rigidbody. The higher the drag the more the object slows down. |
enablePostTransformControl
Declaration
public bool enablePostTransformControl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | If true, the gameobject's transform information will be synchronized to the physics engine. |
freezePosition
Declaration
public FreezeOptions freezePosition { get; set; }
Property Value
Type | Description |
---|---|
FreezeOptions | The position freeze options |
freezeRotation
Declaration
public FreezeOptions freezeRotation { get; set; }
Property Value
Type | Description |
---|---|
FreezeOptions | The rotation freeze options |
isKinematic
Declaration
public bool isKinematic { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Whether this rigidbody is a kinematic object. |
isSleeping
Declaration
public bool isSleeping { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Whether this rigidbody is sleeping. |
linearVelocity
Declaration
public Vector3 linearVelocity { get; set; }
Property Value
Type | Description |
---|---|
Vector3 | The linear velocity of the rigidbody in world space. If the rigidbody is kinematic, the velocity is always zero. |
mass
Declaration
public float mass { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The mass of the rigidbody. 0 means infinite mass. If the set value is negative, it will be clamped to 0. |
maxAngularVelocity
Declaration
public float maxAngularVelocity { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The maximum angular velocity this rigidbody can achieve. |
maxLinearVelocity
Declaration
public float maxLinearVelocity { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The maximum linear velocity this rigidbody can achieve. |
position
Declaration
public Vector3 position { get; set; }
Property Value
Type | Description |
---|---|
Vector3 | The position of the rigidbody in world space. Note: modifying this position won't immediately change the position of the transform. |
rotation
Declaration
public Quaternion rotation { get; set; }
Property Value
Type | Description |
---|---|
Quaternion | The rotation of the rigidbody in world space. Note: modifying this rotation won't immediately change the rotation of the transform. |
sleepThreshold
Declaration
public float sleepThreshold { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The mass-normalized energy threshold, below which objects start going to sleep. |
transform
Declaration
public Transform transform { get; }
Property Value
Type | Description |
---|---|
Transform | The transform component which the rigidbody attached to. |
useGravity
Declaration
public bool useGravity { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Whether the rigidbody is affected by gravity. |
worldCenterOfMass
Declaration
public Vector3 worldCenterOfMass { get; }
Property Value
Type | Description |
---|---|
Vector3 | The center of mass of the rigidbody in world space. |
Methods
AddForce(Vector3, ForceMode)
Add a force to the rigidbody at the centroid in world space.
Declaration
public void AddForce(Vector3 force, ForceMode forceMode)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | force | |
ForceMode | forceMode |
AddForceAtPosition(Vector3, Vector3, ForceMode)
Add a force to the rigidbody at the specified position in world space. The force is only accumulated at the time of call.
Declaration
public void AddForceAtPosition(Vector3 force, Vector3 position, ForceMode forceMode)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | force | |
Vector3 | position | |
ForceMode | forceMode |
AddRelativeForce(Vector3, ForceMode)
Add a force to the rigidbody at the centroid in local space.
Declaration
public void AddRelativeForce(Vector3 force, ForceMode forceMode)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | force | |
ForceMode | forceMode |
AddRelativeTorque(Vector3, ForceMode)
Add a torque to the rigidbody at the centroid in local space.
Declaration
public void AddRelativeTorque(Vector3 torque, ForceMode forceMode)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | torque | |
ForceMode | forceMode |
AddTorque(Vector3, ForceMode)
Add a torque to the rigidbody at the centroid in world space.
Declaration
public void AddTorque(Vector3 torque, ForceMode forceMode)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | torque | |
ForceMode | forceMode |
ResetBodyCenterOfMass()
Reset the center of mass of the rigidbody. Calculate the position of the center of mass automatically.
Declaration
public void ResetBodyCenterOfMass()
SetKinematicTarget(Vector3, Quaternion)
Set a target transform to the kinematic rigidbody. This is a physical moving.
Declaration
public void SetKinematicTarget(Vector3 position, Quaternion rotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | |
Quaternion | rotation |
WakeUp()
Wake up this rigidbody, to update its status.
Declaration
public void WakeUp()