Api Sandbox Rigidbody
class

Rigidbody

public sealed class Rigidbody : Component

Adds physics properties to an object. Requires a collider to be attached to the same object.

Constructors

Rigidbody()

Properties

Name Type Description
Gravity Boolean Is gravity enabled or not.
GravityScale Single Scale the gravity relative to Gravity. 2 is double the gravity, etc.
LinearDamping Single
AngularDamping Single
MassOverride Single Override mass for this body, only when value is more than zero
Mass Single
OverrideMassCenter Boolean
MassCenterOverride Vector3
MassCenter Vector3 Center of mass for this rigidbody in local space coordinates.
Locking PhysicsLock
StartAsleep Boolean
RigidbodyFlags RigidbodyFlags
EnableImpactDamage Boolean Whether this rigidbody can deal damage to damageable objects on high-speed impacts.
MinImpactDamageSpeed Single The minimum speed required for an impact to cause damage.
ImpactDamage Single The amount of damage this rigidbody deals to other objects when it collides at high speed. If set to 0 or less, this will be calculated from the mass of the rigidbody.
Velocity Vector3
AngularVelocity Vector3
MotionEnabled Boolean
CollisionEventsEnabled Boolean Enable or disable touch events. If you disable the events then ICollisionListener won't get any touch events and you won't get things like collision sounds.
CollisionUpdateEventsEnabled Boolean Like CollisionEventsEnabled but means the OnCollisionUpdate gets called when the collision persists
Sleeping Boolean
InertiaTensor Vector3 Gets or sets the inertia tensor for this body. By default, the inertia tensor is automatically calculated from the shapes attached to the body. Setting this property overrides the automatically calculated inertia tensor until ResetInertiaTensor is called.
InertiaTensorRotation Rotation Gets or sets the rotation applied to the inertia tensor. Like InertiaTensor, this acts as an override to the automatically calculated inertia tensor rotation and remains in effect until ResetInertiaTensor is called.
EnhancedCcd Boolean Enable enhanced continuous collision detection (CCD) for this body. When enabled, the body performs CCD against dynamic bodies (but not against other bodies with enhanced CCD enabled). This is useful for fast-moving objects like bullets or rockets that need reliable collision detection.
PhysicsBody PhysicsBody Get the actual physics body that was created by this component. You should be careful, this can of course be null when the object is not enabled or the physics world is not available. It might also get deleted and re-created, so best use this to access, but don't store it.
Touching IEnumerable<Collider> This is a list of all of the triggers that we are touching.
Joints IReadOnlySet<Joint> A list of joints that we're connected to, if any.

Methods

Void ApplyBuoyancy(Plane plane, Single dt)

Applies buoyancy and drag to the rigidbody relative to a plane to simulate things floating in water.

Void ResetInertiaTensor()

Resets the inertia tensor and its rotation to the values automatically calculated from the attached colliders. This removes any custom overrides set via InertiaTensor or InertiaTensorRotation.

Vector3 FindClosestPoint(Vector3 position)

Returns the closest point to the given one between all convex shapes of this body.

Vector3 GetVelocityAtPoint(Vector3 position)

Returns the world space velocity of a point of the object. This is useful for objects rotating around their own axis/origin.

Void ApplyForceAt(Vector3 position, Vector3 force)

Applies force to this body at given position.

Void ApplyForce(Vector3 force)

Applies linear force to this body

Void ApplyTorque(Vector3 force)

Applies angular velocity to this body.

Void ApplyImpulseAt(Vector3 position, Vector3 force)

Applies instant linear impulse (i.e. a bullet impact) to this body at given position

Void ApplyImpulse(Vector3 force)

Applies instant linear impulse (i.e. a bullet impact) to this body

Void ClearForces()

Clear accumulated linear forces (ApplyForce(Vector3@) and ApplyForceAt(Vector3@,Vector3@)) during this physics frame that were not yet applied to the physics body.

Void SmoothMove(Transform transform, Single timeToArrive, Single timeDelta)

Move body to this position in a way that cooperates with the physics system. This is quite good for things like grabbing and moving objects.

Void SmoothMove(Vector3 position, Single timeToArrive, Single timeDelta)

Move body to this position in a way that cooperates with the physics system. This is quite good for things like grabbing and moving objects.

Void SmoothRotate(Rotation rotation, Single timeToArrive, Single timeDelta)

Rotate the body to this position in a way that cooperates with the physics system.

BBox GetWorldBounds()

Get the world bounds of this object

Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.Rigidbody