Rigidbodyclass

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

objectComponentRigidbody
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.Rigidbody : Sandbox.Component

Constructors1

Showing 1 constructors

Methods15

Showing 15 methods

public void ApplyForce(Vector3 force)PUBLIC

Applies linear force to this body

ParameterTypeDescription
forceVector3
Returns:void

public void ApplyForceAt(Vector3 position, Vector3 force)PUBLIC

Applies force to this body at given position.

ParameterTypeDescription
positionVector3
forceVector3
Returns:void

public void ApplyImpulse(Vector3 force)PUBLIC

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

ParameterTypeDescription
forceVector3
Returns:void

public void ApplyImpulseAt(Vector3 position, Vector3 force)PUBLIC

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

ParameterTypeDescription
positionVector3
forceVector3
Returns:void

public void ApplyTorque(Vector3 force)PUBLIC

Applies angular velocity to this body.

ParameterTypeDescription
forceVector3
Returns:void

public void ClearForces()PUBLIC

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.

Returns:void

public Vector3 FindClosestPoint(Vector3 position)PUBLIC

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

ParameterTypeDescription
positionVector3
Returns:Vector3

public Vector3 GetVelocityAtPoint(Vector3 position)PUBLIC

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

ParameterTypeDescription
positionVector3
Returns:Vector3

public BBox GetWorldBounds()PUBLIC

Get the world bounds of this object

Returns:BBox

public void ResetInertiaTensor()PUBLIC

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

Returns:void

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

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

ParameterTypeDescription
rotationRotation
timeToArrivefloat
timeDeltafloat
Returns:void

Properties28

Showing 28 properties

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

Returns:float

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

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.

Returns:bool

public bool Sandbox.Rigidbody.CollisionUpdateEventsEnabled { get; set; }PUBLICGETSETPER-FRAME

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

Returns:bool

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

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

Returns:bool

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

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.

Returns:bool

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

Is gravity enabled or not.

Returns:bool

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

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

Returns:float

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

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.

Returns:float

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

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.

Returns:Vector3

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

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.

Returns:Rotation

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

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

Returns:IReadOnlySet<Joint>

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

Returns:float

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

Returns:float

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

Center of mass for this rigidbody in local space coordinates.

Returns:Vector3

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

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

Returns:float

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

The minimum speed required for an impact to cause damage.

Returns:float

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

Returns:bool

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

Returns:bool

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

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.

Returns:PhysicsBody

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

Returns:bool

public float Sandbox.Rigidbody.SleepThreshold { get; set; }PUBLICGETSET

The speed threshold below which this body will be put to sleep. Units per second. Increase this to make the body sleep sooner, which is useful for stacking stability.

Returns:float

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

Returns:bool

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

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

Returns:IEnumerable<Collider>

On this page

Constructorspublic Rigidbody()Methodspublic System.Void ApplyBuoyancy(Sandbox.Plane plane, System.Single fluidDensity, System.Single linearDrag, System.Single angularDrag, Vector3 fluidVelocity, System.Single dt)public 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.Single Sandbox.Rigidbody.SleepThreshold { 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