class
Rigidbody
Rigidbody is a dynamic physics object that can be moved using forces (or directly).
It will interact with other static and dynamic physics objects in the scene accordingly (it will push other non-kinematic rigidbodies, and collide with static objects).
The shape and mass of a rigidbody is governed by its colliders. At least one collider must be attached to the collider. To attach a collider, place it on the same scene object as the rigidbody, or a child scene object.
Public
Constructors
Rigidbody
Methods
Move
Moves the rigidbody to a specific position.
This method will ensure physically correct movement, meaning the body will collide with other objects along the way.
Rotate
Rotates the rigidbody.
This method will ensure physically correct rotation, meaning the body will collide with other objects along the way.
SetMass
Determines the mass of the object and all of its collider shapes.
Only relevant if RigidbodyFlag::AutoMass or RigidbodyFlag::AutoTensors is turned off. Value of zero means the object is immovable (but can be rotated).
GetMass
SetIsKinematic
Determines if the body is kinematic.
Kinematic body will not move in response to external forces (for example gravity, or another object pushing it), essentially behaving like collider. Unlike a collider though, you can still move the object and have other dynamic objects respond correctly (meaning it will push other objects).
GetIsKinematic
IsSleeping
Checks if the body is sleeping.
Objects that aren't moved/rotated for a while are put to sleep to reduce load on the physics system.
Sleep
Forces the object to sleep.
Useful if you know the object will not move in any significant way for a while.
WakeUp
Wakes an object up.
Useful if you modified properties of this object, and potentially surrounding objects which might result in the object being moved by physics (although the physics system will automatically wake the object up for majority of such cases).
SetSleepThreshold
Determines a threshold of force and torque under which the object will be considered to be put to sleep.
GetSleepThreshold
SetUseGravity
Determines whether or not the rigidbody will have the global gravity force applied to it.
GetUseGravity
SetVelocity
Determines the linear velocity of the body.
GetVelocity
SetAngularVelocity
Determines the angular velocity of the body.
GetAngularVelocity
SetDrag
Determines the linear drag of the body.
Higher drag values means the object resists linear movement more.
GetDrag
SetAngularDrag
Determines the angular drag of the body.
Higher drag values means the object resists angular movement more.
GetAngularDrag
SetInertiaTensor
Determines the inertia tensor in local mass space.
Inertia tensor determines how difficult is to rotate the object. Values of zero in the inertia tensor mean the object will be unable to rotate around a specific axis. Only relevant if RigidbodyFlag::AutoTensors is turned off.
GetInertiaTensor
SetMaxAngularVelocity
Determines the maximum angular velocity of the rigidbody.
Velocity will be clamped to this value.
GetMaxAngularVelocity
SetCenterOfMassPosition
Determines the rigidbody's center of mass position.
Only relevant if RigibodyFlag::AutoTensors is turned off.
GetCenterOfMassPosition
SetCenterOfMassRotation
Determines the rigidbody's center of mass rotation.
Only relevant if RigibodyFlag::AutoTensors is turned off.
GetCenterOfMassRotation
SetPositionSolverCount
Determines the number of iterations to use when solving for position.
Higher values can improve precision and numerical stability of the simulation.
GetPositionSolverCount
SetVelocitySolverCount
Determines the number of iterations to use when solving for velocity.
Higher values can improve precision and numerical stability of the simulation.
GetVelocitySolverCount
SetCollisionReportMode
Sets a value that determines which (if any) collision events are reported.
GetCollisionReportMode
Gets a value that determines which (if any) collision events are reported.
GetFlags
AddForce
Applies a force to the center of the mass of the rigidbody.
This will produce linear momentum.
- force
- Force to apply.
- mode
- Determines what is the type of .
AddTorque
Applies a torque to the rigidbody.
This will produce angular momentum.
- torque
- Torque to apply.
- mode
- Determines what is the type of .
AddForceAtPoint
Applies a force to a specific point on the rigidbody.
This will in most cases produce both linear and angular momentum.
- force
- Force to apply.
- position
- World position to apply the force at.
- mode
- Determines what is the type of .
GetVelocityAtPoint
Returns the total (linear + angular) velocity at a specific point.
- point
- Point in world space.
Returns: Total velocity of the point.
staticGetRttiStatic
Fields
OnCollisionBegin
Triggered when one of the colliders owned by the rigidbody starts colliding with another object.
OnCollisionStay
Triggered when a previously colliding collider stays in collision.
Triggered once per frame.
OnCollisionEnd
Triggered when one of the colliders owned by the rigidbody stops colliding with another object.
Internal
Methods
GetImplementation
Returns the low level rigidbody implementation.
SetParentJoint
Sets that joint that this rigidbody is attached to.
Allows the rigidbody to notify the joint when it moves.
UpdateMassDistribution
Recalculates rigidbody's mass, inertia tensors and center of mass depending on the currently set child colliders.
This should be called whenever relevant child collider properties change (like mass or shape).
If automatic tensor calculation is turned off then this will do nothing. If automatic mass calculation is turned off then this will use the mass set directly on the body using SetMass().
Protected
Constructors
Rigidbody
Methods
UpdateColliders
Searches child scene objects for Collider components and attaches them to the rigidbody.
Make sure to call ClearColliders() if you need to clear old colliders first.
AddCollider
Registers a new collider with the Rigidbody.
This collider will then be used to calculate Rigidbody's geometry used for collisions, and optionally (depending on set flags) total mass, inertia tensors and center of mass.
RemoveCollider
Unregisters the collider from the Rigidbody.
CheckForNestedRigibody
Checks if the rigidbody is nested under another rigidbody, and throws out a warning if so.
OnCreated
Called once when the component has been created.
Called regardless of the state the component is in.
OnDestroyed
Called once just before the component is destroyed.
Called regardless of the state the component is in.
OnDisabled
Called every time a component is placed into the Stopped state.
This includes component destruction if component wasn't already in Stopped state during destruction. When called during destruction it is called before OnDestroyed.
OnEnabled
Called every time a component leaves the Stopped state, if the component is enabled.
This includes component creation if requirements for leaving the Stopped state are met. When called during creation it is called after OnBeginPlay.
OnTransformChanged
Called when the component's parent scene object has changed.
Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().