# Class RigidBody

A rigid-body.

- Defined in dynamics/rigid_body.d.ts:42

#####
Index

### Constructors

constructor

### Properties

colliderSet
handle
rawSet
userData?

### Methods

addForce
addForceAtPoint
addTorque
additionalSolverIterations
angularDamping
angvel
applyImpulse
applyImpulseAtPoint
applyTorqueImpulse
bodyType
collider
dominanceGroup
effectiveAngularInertia
effectiveInvMass
effectiveWorldInvInertia
enableCcd
finalizeDeserialization
gravityScale
invMass
invPrincipalInertia
isCcdEnabled
isDynamic
isEnabled
isFixed
isKinematic
isMoving
isSleeping
isValid
linearDamping
linvel
localCom
lockRotations
lockTranslations
mass
nextRotation
nextTranslation
numColliders
principalInertia
recomputeMassPropertiesFromColliders
resetForces
resetTorques
restrictTranslations
rotation
setAdditionalMass
setAdditionalMassProperties
setAdditionalSolverIterations
setAngularDamping
setAngvel
setBodyType
setDominanceGroup
setEnabled
setEnabledTranslations
setGravityScale
setLinearDamping
setLinvel
setNextKinematicRotation
setNextKinematicTranslation
setRotation
setSoftCcdPrediction
setTranslation
sleep
softCcdPrediction
translation
userForce
userTorque
velocityAtPoint
wakeUp
worldCom

## Constructors

### constructor

- new RigidBody(rawSet, colliderSet, handle): RigidBody

- #### Parameters

  - rawSet: RawRigidBodySet
  - colliderSet: ColliderSet
  - handle: number

  #### Returns RigidBody

  - Defined in dynamics/rigid_body.d.ts:50

## Properties

### `Private` colliderSet

colliderSet: any

- Defined in dynamics/rigid_body.d.ts:44

### `Readonly` handle

handle: number

- Defined in dynamics/rigid_body.d.ts:45

### `Private` rawSet

rawSet: any

- Defined in dynamics/rigid_body.d.ts:43

### `Optional` userData

userData?: unknown

An arbitrary user-defined object associated with this rigid-body.

- Defined in dynamics/rigid_body.d.ts:49

## Methods

### addForce

- addForce(force, wakeUp): void

- Adds a force at the center-of-mass of this rigid-body.

  #### Parameters

  - force: Vector

    the world-space force to add to the rigid-body.

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:433

### addForceAtPoint

- addForceAtPoint(force, point, wakeUp): void

- Adds a force at the given world-space point of this rigid-body.

  #### Parameters

  - force: Vector

    the world-space force to add to the rigid-body.

  - point: Vector

    the world-space point where the impulse is to be applied on the rigid-body.

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:462

### addTorque

- addTorque(torque, wakeUp): void

- Adds a torque at the center-of-mass of this rigid-body.

  #### Parameters

  - torque: number

    the torque to add to the rigid-body.

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:447

### additionalSolverIterations

- additionalSolverIterations(): number

- The number of additional solver iterations that will be run for this rigid-body and everything that interacts with it directly or indirectly through contacts or joints.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:104

### angularDamping

- angularDamping(): number

- The angular damping coefficient of this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:361

### angvel

- angvel(): number

- The angular velocity of this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:240

### applyImpulse

- applyImpulse(impulse, wakeUp): void

- Applies an impulse at the center-of-mass of this rigid-body.

  #### Parameters

  - impulse: Vector

    the world-space impulse to apply on the rigid-body.

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:440

### applyImpulseAtPoint

- applyImpulseAtPoint(impulse, point, wakeUp): void

- Applies an impulse at the given world-space point of this rigid-body.

  #### Parameters

  - impulse: Vector

    the world-space impulse to apply on the rigid-body.

  - point: Vector

    the world-space point where the impulse is to be applied on the rigid-body.

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:470

### applyTorqueImpulse

- applyTorqueImpulse(torqueImpulse, wakeUp): void

- Applies an impulsive torque at the center-of-mass of this rigid-body.

  #### Parameters

  - torqueImpulse: number

    the torque impulse to apply on the rigid-body.

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:454

### bodyType

- bodyType(): RigidBodyType

- The status of this rigid-body: static, dynamic, or kinematic.

  #### Returns RigidBodyType

  - Defined in dynamics/rigid_body.d.ts:329

### collider

- collider(i): Collider

- Retrieves the `i-th` collider attached to this rigid-body.

  #### Parameters

  - i: number

    The index of the collider to retrieve. Must be a number in `[0, this.numColliders()[`. This index is not the same as the unique identifier of the collider.

  #### Returns Collider

  - Defined in dynamics/rigid_body.d.ts:315

### dominanceGroup

- dominanceGroup(): number

- The dominance group, in [-127, +127] this rigid-body is part of.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:92

### effectiveAngularInertia

- effectiveAngularInertia(): number

- The effective world-space angular inertia (that takes the potential rotation locking into account) of this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:282

### effectiveInvMass

- effectiveInvMass(): Vector

- The inverse mass taking into account translation locking.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:248

### effectiveWorldInvInertia

- effectiveWorldInvInertia(): number

- The world-space inverse angular inertia tensor of the rigid-body, taking into account rotation locking.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:277

### enableCcd

- enableCcd(enabled): void

- Enable or disable CCD (Continuous Collision Detection) for this rigid-body.

  #### Parameters

  - enabled: boolean

    If `true`, CCD will be enabled for this rigid-body.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:122

### finalizeDeserialization

- finalizeDeserialization(colliderSet): void
- `Internal`

  #### Parameters

  - colliderSet: ColliderSet

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:52

### gravityScale

- gravityScale(): number

- The scale factor applied to the gravity affecting this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:180

### invMass

- invMass(): number

- The inverse of the mass of a rigid-body.

  If this is zero, the rigid-body is assumed to have infinite mass.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:254

### invPrincipalInertia

- invPrincipalInertia(): number

- The inverse of the principal angular inertia of the rigid-body.

  Components set to zero are assumed to be infinite along the corresponding principal axis.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:268

### isCcdEnabled

- isCcdEnabled(): boolean

- Is CCD enabled for this rigid-body?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:304

### isDynamic

- isDynamic(): boolean

- Is this rigid-body dynamic?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:353

### isEnabled

- isEnabled(): boolean

- Is this rigid-body enabled?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:325

### isFixed

- isFixed(): boolean

- Is this rigid-body static?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:345

### isKinematic

- isKinematic(): boolean

- Is this rigid-body kinematic?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:349

### isMoving

- isMoving(): boolean

- Is the velocity of this rigid-body not zero?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:341

### isSleeping

- isSleeping(): boolean

- Is this rigid-body sleeping?

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:337

### isValid

- isValid(): boolean

- Checks if this rigid-body is still valid (i.e. that it has not been deleted from the rigid-body set yet.

  #### Returns boolean

  - Defined in dynamics/rigid_body.d.ts:57

### linearDamping

- linearDamping(): number

- The linear damping coefficient of this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:357

### linvel

- linvel(): Vector

- The linear velocity of this rigid-body.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:232

### localCom

- localCom(): Vector

- The center of mass of a rigid-body expressed in its local-space.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:258

### lockRotations

- lockRotations(locked, wakeUp): void

- Locks or unlocks the ability of this rigid-body to rotate.

  #### Parameters

  - locked: boolean

    If `true`, this rigid-body will no longer rotate due to torques and impulses.

  - wakeUp: boolean

    If `true`, this rigid-body will be automatically awaken if it is currently asleep.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:71

### lockTranslations

- lockTranslations(locked, wakeUp): void

- Locks or unlocks the ability of this rigid-body to translate.

  #### Parameters

  - locked: boolean

    If `true`, this rigid-body will no longer translate due to forces and impulses.

  - wakeUp: boolean

    If `true`, this rigid-body will be automatically awaken if it is currently asleep.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:64

### mass

- mass(): number

- The mass of this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:244

### nextRotation

- nextRotation(): number

- The world-space next orientation of this rigid-body.

  If this rigid-body is kinematic this value is set by the `setNextKinematicRotation` method and is used for estimating the kinematic body velocity at the next timestep. For non-kinematic bodies, this value is currently unspecified.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:160

### nextTranslation

- nextTranslation(): Vector

- The world-space next translation of this rigid-body.

  If this rigid-body is kinematic this value is set by the `setNextKinematicTranslation` method and is used for estimating the kinematic body velocity at the next timestep. For non-kinematic bodies, this value is currently unspecified.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:152

### numColliders

- numColliders(): number

- The number of colliders attached to this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:308

### principalInertia

- principalInertia(): number

- The angular inertia along the principal inertia axes of the rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:272

### recomputeMassPropertiesFromColliders

- recomputeMassPropertiesFromColliders(): void

- Recompute the mass-properties of this rigid-bodies based on its currently attached colliders.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:371

### resetForces

- resetForces(wakeUp): void

- Resets to zero the user forces (but not torques) applied to this rigid-body.

  #### Parameters

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:420

### resetTorques

- resetTorques(wakeUp): void

- Resets to zero the user torques applied to this rigid-body.

  #### Parameters

  - wakeUp: boolean

    should the rigid-body be automatically woken-up?

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:426

### restrictTranslations

- restrictTranslations(enableX, enableY, wakeUp): void

- Locks or unlocks the ability of this rigid-body to translation along individual coordinate axes.

  #### Parameters

  - enableX: boolean

    If `false`, this rigid-body will no longer rotate due to torques and impulses, along the X coordinate axis.

  - enableY: boolean

    If `false`, this rigid-body will no longer rotate due to torques and impulses, along the Y coordinate axis.

  - wakeUp: boolean

    If `true`, this rigid-body will be automatically awaken if it is currently asleep.

  #### Returns void

  #### Deprecated

  use `this.setEnabledTranslations` with the same arguments instead.

  - Defined in dynamics/rigid_body.d.ts:88

### rotation

- rotation(): number

- The world-space orientation of this rigid-body.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:144

### setAdditionalMass

- setAdditionalMass(mass, wakeUp): void

- Sets the rigid-body's additional mass.

  The total angular inertia of the rigid-body will be scaled automatically based on this additional mass. If this scaling effect isn’t desired, use Self::additional_mass_properties instead of this method.

  This is only the "additional" mass because the total mass of the rigid-body is equal to the sum of this additional mass and the mass computed from the colliders (with non-zero densities) attached to this rigid-body.

  That total mass (which includes the attached colliders’ contributions) will be updated at the name physics step, or can be updated manually with `this.recomputeMassPropertiesFromColliders`.

  This will override any previous additional mass-properties set by `this.setAdditionalMass`, `this.setAdditionalMassProperties`, `RigidBodyDesc::setAdditionalMass`, or `RigidBodyDesc.setAdditionalMassfProperties` for this rigid-body.

  #### Parameters

  - mass: number

    The additional mass to set.

  - wakeUp: boolean

    If `true` then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:391

### setAdditionalMassProperties

- setAdditionalMassProperties(mass, centerOfMass, principalAngularInertia, wakeUp): void

- Sets the rigid-body's additional mass-properties.

  This is only the "additional" mass-properties because the total mass-properties of the rigid-body is equal to the sum of this additional mass-properties and the mass computed from the colliders (with non-zero densities) attached to this rigid-body.

  That total mass-properties (which include the attached colliders’ contributions) will be updated at the name physics step, or can be updated manually with `this.recomputeMassPropertiesFromColliders`.

  This will override any previous mass-properties set by `this.setAdditionalMass`, `this.setAdditionalMassProperties`, `RigidBodyDesc.setAdditionalMass`, or `RigidBodyDesc.setAdditionalMassProperties` for this rigid-body.

  If `wake_up` is true then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

  #### Parameters

  - mass: number
  - centerOfMass: Vector
  - principalAngularInertia: number
  - wakeUp: boolean

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:408

### setAdditionalSolverIterations

- setAdditionalSolverIterations(iters): void

- Sets the number of additional solver iterations that will be run for this rigid-body and everything that interacts with it directly or indirectly through contacts or joints.

  Compared to increasing the global `World.numSolverIteration`, setting this value lets you increase accuracy on only a subset of the scene, resulting in reduced performance loss.

  #### Parameters

  - iters: number

    The new number of additional solver iterations (default: 0).

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:116

### setAngularDamping

- setAngularDamping(factor): void

- Sets the linear damping factor applied to this rigid-body.

  #### Parameters

  - factor: number

    The damping factor to set.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:414

### setAngvel

- setAngvel(vel, wakeUp): void

- Sets the angular velocity fo this rigid-body.

  #### Parameters

  - vel: number

    The angular velocity to set.

  - wakeUp: boolean

    Forces the rigid-body to wake-up if it was asleep.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:204

### setBodyType

- setBodyType(type, wakeUp): void

- Set a new status for this rigid-body: static, dynamic, or kinematic.

  #### Parameters

  - type: RigidBodyType
  - wakeUp: boolean

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:333

### setDominanceGroup

- setDominanceGroup(group): void

- Sets the dominance group of this rigid-body.

  #### Parameters

  - group: number

    The dominance group of this rigid-body. Must be a signed integer in the range [-127, +127].

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:98

### setEnabled

- setEnabled(enabled): void

- Sets whether this rigid-body is enabled or not.

  #### Parameters

  - enabled: boolean

    Set to `false` to disable this rigid-body and all its attached colliders.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:321

### setEnabledTranslations

- setEnabledTranslations(enableX, enableY, wakeUp): void

- Locks or unlocks the ability of this rigid-body to translation along individual coordinate axes.

  #### Parameters

  - enableX: boolean

    If `false`, this rigid-body will no longer rotate due to torques and impulses, along the X coordinate axis.

  - enableY: boolean

    If `false`, this rigid-body will no longer rotate due to torques and impulses, along the Y coordinate axis.

  - wakeUp: boolean

    If `true`, this rigid-body will be automatically awaken if it is currently asleep.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:79

### setGravityScale

- setGravityScale(factor, wakeUp): void

- Sets the scale factor applied to the gravity affecting this rigid-body.

  #### Parameters

  - factor: number

    The scale factor to set. A value of 0.0 means that this rigid-body will on longer be affected by gravity.

  - wakeUp: boolean

    Forces the rigid-body to wake-up if it was asleep.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:189

### setLinearDamping

- setLinearDamping(factor): void

- Sets the linear damping factor applied to this rigid-body.

  #### Parameters

  - factor: number

    The damping factor to set.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:367

### setLinvel

- setLinvel(vel, wakeUp): void

- Sets the linear velocity of this rigid-body.

  #### Parameters

  - vel: Vector

    The linear velocity to set.

  - wakeUp: boolean

    Forces the rigid-body to wake-up if it was asleep.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:175

### setNextKinematicRotation

- setNextKinematicRotation(angle): void

- If this rigid body is kinematic, sets its future rotation after the next timestep integration.

  This should be used instead of `rigidBody.setRotation` to make the dynamic object interacting with this kinematic body behave as expected. Internally, Rapier will compute an artificial velocity for this rigid-body from its current position and its next kinematic position. This velocity will be used to compute forces on dynamic bodies interacting with this body.

  #### Parameters

  - angle: number

    The kinematic rotation angle, in radians.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:228

### setNextKinematicTranslation

- setNextKinematicTranslation(t): void

- If this rigid body is kinematic, sets its future translation after the next timestep integration.

  This should be used instead of `rigidBody.setTranslation` to make the dynamic object interacting with this kinematic body behave as expected. Internally, Rapier will compute an artificial velocity for this rigid-body from its current position and its next kinematic position. This velocity will be used to compute forces on dynamic bodies interacting with this body.

  #### Parameters

  - t: Vector

    The kinematic translation to set.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:216

### setRotation

- setRotation(angle, wakeUp): void

- Sets the rotation angle of this rigid-body.

  #### Parameters

  - angle: number

    The rotation angle, in radians.

  - wakeUp: boolean

    Forces the rigid-body to wake-up so it is properly affected by forces if it wasn't moving before modifying its position.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:197

### setSoftCcdPrediction

- setSoftCcdPrediction(distance): void

- Sets the soft-CCD prediction distance for this rigid-body.

  See the documentation of `RigidBodyDesc.setSoftCcdPrediction` for additional details.

  #### Parameters

  - distance: number

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:129

### setTranslation

- setTranslation(tra, wakeUp): void

- Sets the translation of this rigid-body.

  #### Parameters

  - tra: Vector

    The world-space position of the rigid-body.

  - wakeUp: boolean

    Forces the rigid-body to wake-up so it is properly affected by forces if it wasn't moving before modifying its position.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:168

### sleep

- sleep(): void

- Put this rigid body to sleep.

  A sleeping body no longer moves and is no longer simulated by the physics engine unless it is waken up. It can be woken manually with `this.wakeUp()` or automatically due to external forces like contacts.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:290

### softCcdPrediction

- softCcdPrediction(): number

- Gets the soft-CCD prediction distance for this rigid-body.

  See the documentation of `RigidBodyDesc.setSoftCcdPrediction` for additional details.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:136

### translation

- translation(): Vector

- The world-space translation of this rigid-body.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:140

### userForce

- userForce(): Vector

- Retrieves the constant force(s) the user added to this rigid-body Returns zero if the rigid-body is not dynamic.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:475

### userTorque

- userTorque(): number

- Retrieves the constant torque(s) the user added to this rigid-body Returns zero if the rigid-body is not dynamic.

  #### Returns number

  - Defined in dynamics/rigid_body.d.ts:480

### velocityAtPoint

- velocityAtPoint(point): Vector

- The velocity of the given world-space point on this rigid-body.

  #### Parameters

  - point: Vector

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:236

### wakeUp

- wakeUp(): void

- Wakes this rigid-body up.

  A dynamic rigid-body that does not move during several consecutive frames will be put to sleep by the physics engine, i.e., it will stop being simulated in order to avoid useless computations. This methods forces a sleeping rigid-body to wake-up. This is useful, e.g., before modifying the position of a dynamic body so that it is properly simulated afterwards.

  #### Returns void

  - Defined in dynamics/rigid_body.d.ts:300

### worldCom

- worldCom(): Vector

- The world-space center of mass of the rigid-body.

  #### Returns Vector

  - Defined in dynamics/rigid_body.d.ts:262