s&box docs

public sealed class Sandbox.Rigidbody : Sandbox.Component

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

Broader workflow and conceptual references connected to this API.

Constructors

Showing 1 constructors

Methods

Showing 14 methods

public void ApplyBuoyancy(Sandbox.Plane plane, float dt)

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

public void ApplyForce(Vector3 force)

Applies linear force to this body

public void ApplyForceAt(Vector3 position, Vector3 force)

Applies force to this body at given position.

public void ApplyImpulse(Vector3 force)

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

public void ApplyImpulseAt(Vector3 position, Vector3 force)

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

public void ApplyTorque(Vector3 force)

Applies angular velocity to this body.

public void ClearForces()

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

public Vector3 FindClosestPoint(Vector3 position)

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

public 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.

public BBox GetWorldBounds()

Get the world bounds of this object

public 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 `Sandbox.Rigidbody.InertiaTensor` or `Sandbox.Rigidbody.InertiaTensorRotation`.

public void SmoothRotate(Rotation rotation, float timeToArrive, float timeDelta)

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

Properties

Showing 27 properties

public float Sandbox.Rigidbody.AngularDamping { get; set; }

public bool Sandbox.Rigidbody.CollisionEventsEnabled { get; set; }

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.

public bool Sandbox.Rigidbody.CollisionUpdateEventsEnabled { get; set; }

Like CollisionEventsEnabled but means the OnCollisionUpdate gets called when the collision persists

public bool Sandbox.Rigidbody.EnableImpactDamage { get; set; }

Whether this rigidbody can deal damage to damageable objects on high-speed impacts.

public bool Sandbox.Rigidbody.EnhancedCcd { get; set; }

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.

public bool Sandbox.Rigidbody.Gravity { get; set; }

Is gravity enabled or not.

public float Sandbox.Rigidbody.GravityScale { get; set; }

Scale the gravity relative to `Sandbox.PhysicsWorld.Gravity`. 2 is double the gravity, etc.

public float Sandbox.Rigidbody.ImpactDamage { get; set; }

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.

public Vector3 Sandbox.Rigidbody.InertiaTensor { get; set; }

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 `Sandbox.Rigidbody.ResetInertiaTensor` is called.

public Rotation Sandbox.Rigidbody.InertiaTensorRotation { get; set; }

Gets or sets the rotation applied to the inertia tensor. Like `Sandbox.Rigidbody.InertiaTensor`, this acts as an override to the automatically calculated inertia tensor rotation and remains in effect until `Sandbox.Rigidbody.ResetInertiaTensor` is called.

public System.Collections.Generic.IReadOnlySet`1<Sandbox.Joint> Sandbox.Rigidbody.Joints { get; set; }

A list of joints that we're connected to, if any.

public float Sandbox.Rigidbody.LinearDamping { get; set; }

public float Sandbox.Rigidbody.Mass { get; set; }

public Vector3 Sandbox.Rigidbody.MassCenter { get; set; }

Center of mass for this rigidbody in local space coordinates.

public float Sandbox.Rigidbody.MassOverride { get; set; }

Override mass for this body, only when value is more than zero

public float Sandbox.Rigidbody.MinImpactDamageSpeed { get; set; }

The minimum speed required for an impact to cause damage.

public bool Sandbox.Rigidbody.MotionEnabled { get; set; }

public bool Sandbox.Rigidbody.OverrideMassCenter { get; set; }

public Sandbox.PhysicsBody Sandbox.Rigidbody.PhysicsBody { get; set; }

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.

public bool Sandbox.Rigidbody.Sleeping { get; set; }

public bool Sandbox.Rigidbody.StartAsleep { get; set; }

public System.Collections.Generic.IEnumerable`1<Sandbox.Collider> Sandbox.Rigidbody.Touching { get; set; }

This is a list of all of the triggers that we are touching.

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Rigidbody

On this page

Constructorspublic Rigidbody()Methodspublic System.Void ApplyBuoyancy(Sandbox.Plane plane, System.Single dt)public System.Void ApplyForce(Vector3 force)public System.Void ApplyForceAt(Vector3 position, Vector3 force)public System.Void ApplyImpulse(Vector3 force)public System.Void ApplyImpulseAt(Vector3 position, Vector3 force)public System.Void ApplyTorque(Vector3 force)public System.Void ClearForces()public Vector3 FindClosestPoint(Vector3 position)public Vector3 GetVelocityAtPoint(Vector3 position)public BBox GetWorldBounds()public System.Void ResetInertiaTensor()public System.Void SmoothMove(Transform transform, System.Single timeToArrive, System.Single timeDelta)public System.Void SmoothMove(Vector3 position, System.Single timeToArrive, System.Single timeDelta)public System.Void SmoothRotate(Rotation rotation, System.Single timeToArrive, System.Single timeDelta)Propertiespublic System.Single Sandbox.Rigidbody.AngularDamping { get; set; }public Vector3 Sandbox.Rigidbody.AngularVelocity { get; set; }public System.Boolean Sandbox.Rigidbody.CollisionEventsEnabled { get; set; }public System.Boolean Sandbox.Rigidbody.CollisionUpdateEventsEnabled { get; set; }public System.Boolean Sandbox.Rigidbody.EnableImpactDamage { get; set; }public System.Boolean Sandbox.Rigidbody.EnhancedCcd { get; set; }public System.Boolean Sandbox.Rigidbody.Gravity { get; set; }public System.Single Sandbox.Rigidbody.GravityScale { get; set; }public System.Single Sandbox.Rigidbody.ImpactDamage { get; set; }public Vector3 Sandbox.Rigidbody.InertiaTensor { get; set; }public Rotation Sandbox.Rigidbody.InertiaTensorRotation { get; set; }public System.Collections.Generic.IReadOnlySet`1<Sandbox.Joint> Sandbox.Rigidbody.Joints { get; set; }public System.Single Sandbox.Rigidbody.LinearDamping { get; set; }public Sandbox.PhysicsLock Sandbox.Rigidbody.Locking { get; set; }public System.Single Sandbox.Rigidbody.Mass { get; set; }public Vector3 Sandbox.Rigidbody.MassCenter { get; set; }public Vector3 Sandbox.Rigidbody.MassCenterOverride { get; set; }public System.Single Sandbox.Rigidbody.MassOverride { get; set; }public System.Single Sandbox.Rigidbody.MinImpactDamageSpeed { get; set; }public System.Boolean Sandbox.Rigidbody.MotionEnabled { get; set; }public System.Boolean Sandbox.Rigidbody.OverrideMassCenter { get; set; }public Sandbox.PhysicsBody Sandbox.Rigidbody.PhysicsBody { get; set; }public Sandbox.RigidbodyFlags Sandbox.Rigidbody.RigidbodyFlags { get; set; }public System.Boolean Sandbox.Rigidbody.Sleeping { get; set; }public System.Boolean Sandbox.Rigidbody.StartAsleep { get; set; }public System.Collections.Generic.IEnumerable`1<Sandbox.Collider> Sandbox.Rigidbody.Touching { get; set; }public Vector3 Sandbox.Rigidbody.Velocity { get; set; }Metadata