hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
1,533 lines (661 loc) • 18.1 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [RigidBody](./server.rigidbody.md)
## RigidBody class
Represents a rigid body in a world's physics simulation.
**Signature:**
```typescript
export default class RigidBody extends EventRouter
```
**Extends:** [EventRouter](./server.eventrouter.md)
## Remarks
Rigid bodies are the core of the physics simulation. They are used to represent physical objects (IE: entities) that can interact with each other.
## Constructors
<table><thead><tr><th>
Constructor
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[(constructor)(options)](./server.rigidbody._constructor_.md)
</td><td>
</td><td>
Constructs a new instance of the `RigidBody` class
</td></tr>
</tbody></table>
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[additionalMass](./server.rigidbody.additionalmass.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The additional mass of the rigid body.
</td></tr>
<tr><td>
[additionalSolverIterations](./server.rigidbody.additionalsolveriterations.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The additional solver iterations of the rigid body.
</td></tr>
<tr><td>
[angularDamping](./server.rigidbody.angulardamping.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The angular damping of the rigid body.
</td></tr>
<tr><td>
[angularVelocity](./server.rigidbody.angularvelocity.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The angular velocity of the rigid body.
</td></tr>
<tr><td>
[colliders](./server.rigidbody.colliders.md)
</td><td>
`readonly`
</td><td>
Set<[Collider](./server.collider.md)<!-- -->>
</td><td>
The colliders of the rigid body.
</td></tr>
<tr><td>
[directionFromRotation](./server.rigidbody.directionfromrotation.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The direction from the rotation of the rigid body. (-Z identity)
</td></tr>
<tr><td>
[dominanceGroup](./server.rigidbody.dominancegroup.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The dominance group of the rigid body.
</td></tr>
<tr><td>
[effectiveAngularInertia](./server.rigidbody.effectiveangularinertia.md)
</td><td>
`readonly`
</td><td>
[SpdMatrix3](./server.spdmatrix3.md) \| undefined
</td><td>
The effective angular inertia of the rigid body.
</td></tr>
<tr><td>
[effectiveInverseMass](./server.rigidbody.effectiveinversemass.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The effective inverse mass of the rigid body.
</td></tr>
<tr><td>
[effectiveWorldInversePrincipalAngularInertiaSqrt](./server.rigidbody.effectiveworldinverseprincipalangularinertiasqrt.md)
</td><td>
`readonly`
</td><td>
[SpdMatrix3](./server.spdmatrix3.md) \| undefined
</td><td>
The effective world inverse principal angular inertia square root of the rigid body.
</td></tr>
<tr><td>
[enabledPositions](./server.rigidbody.enabledpositions.md)
</td><td>
`readonly`
</td><td>
[Vector3Boolean](./server.vector3boolean.md)
</td><td>
The enabled axes of positional movement of the rigid body.
</td></tr>
<tr><td>
[enabledRotations](./server.rigidbody.enabledrotations.md)
</td><td>
`readonly`
</td><td>
[Vector3Boolean](./server.vector3boolean.md)
</td><td>
The enabled axes of rotational movement of the rigid body.
</td></tr>
<tr><td>
[gravityScale](./server.rigidbody.gravityscale.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The gravity scale of the rigid body.
</td></tr>
<tr><td>
[inverseMass](./server.rigidbody.inversemass.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The inverse mass of the rigid body.
</td></tr>
<tr><td>
[inversePrincipalAngularInertiaSqrt](./server.rigidbody.inverseprincipalangularinertiasqrt.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The inverse principal angular inertia square root of the rigid body.
</td></tr>
<tr><td>
[isCcdEnabled](./server.rigidbody.isccdenabled.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body has continuous collision detection enabled.
</td></tr>
<tr><td>
[isDynamic](./server.rigidbody.isdynamic.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is dynamic.
</td></tr>
<tr><td>
[isEnabled](./server.rigidbody.isenabled.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is enabled.
</td></tr>
<tr><td>
[isFixed](./server.rigidbody.isfixed.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is fixed.
</td></tr>
<tr><td>
[isKinematic](./server.rigidbody.iskinematic.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is kinematic.
</td></tr>
<tr><td>
[isKinematicPositionBased](./server.rigidbody.iskinematicpositionbased.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is kinematic position based.
</td></tr>
<tr><td>
[isKinematicVelocityBased](./server.rigidbody.iskinematicvelocitybased.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is kinematic velocity based.
</td></tr>
<tr><td>
[isMoving](./server.rigidbody.ismoving.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is moving.
</td></tr>
<tr><td>
[isRemoved](./server.rigidbody.isremoved.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body has been removed from the simulation.
</td></tr>
<tr><td>
[isSimulated](./server.rigidbody.issimulated.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is simulated.
</td></tr>
<tr><td>
[isSleeping](./server.rigidbody.issleeping.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the rigid body is sleeping.
</td></tr>
<tr><td>
[linearDamping](./server.rigidbody.lineardamping.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The linear damping of the rigid body.
</td></tr>
<tr><td>
[linearVelocity](./server.rigidbody.linearvelocity.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The linear velocity of the rigid body.
</td></tr>
<tr><td>
[localCenterOfMass](./server.rigidbody.localcenterofmass.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The local center of mass of the rigid body.
</td></tr>
<tr><td>
[mass](./server.rigidbody.mass.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The mass of the rigid body.
</td></tr>
<tr><td>
[nextKinematicPosition](./server.rigidbody.nextkinematicposition.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The next kinematic position of the rigid body.
</td></tr>
<tr><td>
[nextKinematicRotation](./server.rigidbody.nextkinematicrotation.md)
</td><td>
`readonly`
</td><td>
[QuaternionLike](./server.quaternionlike.md)
</td><td>
The next kinematic rotation of the rigid body.
</td></tr>
<tr><td>
[numColliders](./server.rigidbody.numcolliders.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The number of colliders in the rigid body.
</td></tr>
<tr><td>
[position](./server.rigidbody.position.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The position of the rigid body.
</td></tr>
<tr><td>
[principalAngularInertia](./server.rigidbody.principalangularinertia.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The principal angular inertia of the rigid body.
</td></tr>
<tr><td>
[principalAngularInertiaLocalFrame](./server.rigidbody.principalangularinertialocalframe.md)
</td><td>
`readonly`
</td><td>
[QuaternionLike](./server.quaternionlike.md) \| undefined
</td><td>
The principal angular inertia local frame of the rigid body.
</td></tr>
<tr><td>
[rawRigidBody](./server.rigidbody.rawrigidbody.md)
</td><td>
`readonly`
</td><td>
RAPIER.RigidBody \| undefined
</td><td>
The raw RAPIER rigid body instance.
</td></tr>
<tr><td>
[rotation](./server.rigidbody.rotation.md)
</td><td>
`readonly`
</td><td>
[QuaternionLike](./server.quaternionlike.md)
</td><td>
The rotation of the rigid body.
</td></tr>
<tr><td>
[softCcdPrediction](./server.rigidbody.softccdprediction.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The soft continuous collision detection prediction of the rigid body.
</td></tr>
<tr><td>
[type](./server.rigidbody.type.md)
</td><td>
`readonly`
</td><td>
[RigidBodyType](./server.rigidbodytype.md)
</td><td>
The type of the rigid body.
</td></tr>
<tr><td>
[worldCenterOfMass](./server.rigidbody.worldcenterofmass.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The world center of mass of the rigid body.
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[addChildColliderToSimulation(collider)](./server.rigidbody.addchildcollidertosimulation.md)
</td><td>
</td><td>
Adds an unsimulated child collider to the rigid body for the simulation it belongs to.
</td></tr>
<tr><td>
[addForce(force)](./server.rigidbody.addforce.md)
</td><td>
</td><td>
Adds a force to the rigid body.
</td></tr>
<tr><td>
[addTorque(torque)](./server.rigidbody.addtorque.md)
</td><td>
</td><td>
Adds a torque to the rigid body.
</td></tr>
<tr><td>
[addToSimulation(simulation)](./server.rigidbody.addtosimulation.md)
</td><td>
</td><td>
Adds the rigid body to a simulation.
</td></tr>
<tr><td>
[applyImpulse(impulse)](./server.rigidbody.applyimpulse.md)
</td><td>
</td><td>
Applies an impulse to the rigid body.
</td></tr>
<tr><td>
[applyImpulseAtPoint(impulse, point)](./server.rigidbody.applyimpulseatpoint.md)
</td><td>
</td><td>
Applies an impulse to the rigid body at a point.
</td></tr>
<tr><td>
[applyTorqueImpulse(impulse)](./server.rigidbody.applytorqueimpulse.md)
</td><td>
</td><td>
Applies a torque impulse to the rigid body.
</td></tr>
<tr><td>
[createAndAddChildCollider(colliderOptions)](./server.rigidbody.createandaddchildcollider.md)
</td><td>
</td><td>
Creates and adds a child collider to the rigid body for the simulation it belongs to.
</td></tr>
<tr><td>
[createAndAddChildColliders(colliderOptions)](./server.rigidbody.createandaddchildcolliders.md)
</td><td>
</td><td>
Creates and adds multiple child colliders to the rigid body for the simulation it belongs to.
</td></tr>
<tr><td>
[getCollidersByTag(tag)](./server.rigidbody.getcollidersbytag.md)
</td><td>
</td><td>
Gets the colliders of the rigid body by tag.
</td></tr>
<tr><td>
[lockAllPositions()](./server.rigidbody.lockallpositions.md)
</td><td>
</td><td>
Locks all positional movement of the rigid body.
</td></tr>
<tr><td>
[lockAllRotations()](./server.rigidbody.lockallrotations.md)
</td><td>
</td><td>
Locks all rotations of the rigid body.
</td></tr>
<tr><td>
[removeFromSimulation()](./server.rigidbody.removefromsimulation.md)
</td><td>
</td><td>
Removes the rigid body from the simulation it belongs to.
</td></tr>
<tr><td>
[resetAngularVelocity()](./server.rigidbody.resetangularvelocity.md)
</td><td>
</td><td>
Resets the angular velocity of the rigid body.
</td></tr>
<tr><td>
[resetForces()](./server.rigidbody.resetforces.md)
</td><td>
</td><td>
Resets the forces actiong on the rigid body.
</td></tr>
<tr><td>
[resetLinearVelocity()](./server.rigidbody.resetlinearvelocity.md)
</td><td>
</td><td>
Resets the linear velocity of the rigid body.
</td></tr>
<tr><td>
[resetTorques()](./server.rigidbody.resettorques.md)
</td><td>
</td><td>
Resets the torques acting on the rigid body.
</td></tr>
<tr><td>
[setAdditionalMass(additionalMass)](./server.rigidbody.setadditionalmass.md)
</td><td>
</td><td>
Sets the additional mass of the rigid body.
</td></tr>
<tr><td>
[setAdditionalMassProperties(additionalMassProperties)](./server.rigidbody.setadditionalmassproperties.md)
</td><td>
</td><td>
Sets the additional mass properties of the rigid body.
</td></tr>
<tr><td>
[setAdditionalSolverIterations(solverIterations)](./server.rigidbody.setadditionalsolveriterations.md)
</td><td>
</td><td>
Sets the additional solver iterations of the rigid body.
</td></tr>
<tr><td>
[setAngularDamping(angularDamping)](./server.rigidbody.setangulardamping.md)
</td><td>
</td><td>
Sets the angular damping of the rigid body.
</td></tr>
<tr><td>
[setAngularVelocity(angularVelocity)](./server.rigidbody.setangularvelocity.md)
</td><td>
</td><td>
Sets the angular velocity of the rigid body.
</td></tr>
<tr><td>
[setCcdEnabled(ccdEnabled)](./server.rigidbody.setccdenabled.md)
</td><td>
</td><td>
Sets whether the rigid body has continuous collision detection enabled.
</td></tr>
<tr><td>
[setCollisionGroupsForSensorColliders(collisionGroups)](./server.rigidbody.setcollisiongroupsforsensorcolliders.md)
</td><td>
</td><td>
Sets the collision groups for sensor colliders of the rigid body.
</td></tr>
<tr><td>
[setCollisionGroupsForSolidColliders(collisionGroups)](./server.rigidbody.setcollisiongroupsforsolidcolliders.md)
</td><td>
</td><td>
Sets the collision groups for solid colliders (non-sensor) of the rigid body.
</td></tr>
<tr><td>
[setDominanceGroup(dominanceGroup)](./server.rigidbody.setdominancegroup.md)
</td><td>
</td><td>
Sets the dominance group of the rigid body.
</td></tr>
<tr><td>
[setEnabled(enabled)](./server.rigidbody.setenabled.md)
</td><td>
</td><td>
Sets whether the rigid body is enabled.
</td></tr>
<tr><td>
[setEnabledPositions(enabledPositions)](./server.rigidbody.setenabledpositions.md)
</td><td>
</td><td>
Sets whether the rigid body has enabled positional movement.
</td></tr>
<tr><td>
[setEnabledRotations(enabledRotations)](./server.rigidbody.setenabledrotations.md)
</td><td>
</td><td>
Sets whether the rigid body has enabled rotations.
</td></tr>
<tr><td>
[setGravityScale(gravityScale)](./server.rigidbody.setgravityscale.md)
</td><td>
</td><td>
Sets the gravity scale of the rigid body.
</td></tr>
<tr><td>
[setLinearDamping(linearDamping)](./server.rigidbody.setlineardamping.md)
</td><td>
</td><td>
Sets the linear damping of the rigid body.
</td></tr>
<tr><td>
[setLinearVelocity(linearVelocity)](./server.rigidbody.setlinearvelocity.md)
</td><td>
</td><td>
Sets the linear velocity of the rigid body.
</td></tr>
<tr><td>
[setNextKinematicPosition(nextKinematicPosition)](./server.rigidbody.setnextkinematicposition.md)
</td><td>
</td><td>
Sets the next kinematic position of the rigid body.
</td></tr>
<tr><td>
[setNextKinematicRotation(nextKinematicRotation)](./server.rigidbody.setnextkinematicrotation.md)
</td><td>
</td><td>
Sets the next kinematic rotation of the rigid body.
</td></tr>
<tr><td>
[setPosition(position)](./server.rigidbody.setposition.md)
</td><td>
</td><td>
Sets the position of the rigid body.
</td></tr>
<tr><td>
[setRotation(rotation)](./server.rigidbody.setrotation.md)
</td><td>
</td><td>
Sets the rotation of the rigid body.
</td></tr>
<tr><td>
[setSleeping(sleeping)](./server.rigidbody.setsleeping.md)
</td><td>
</td><td>
Sets whether the rigid body is sleeping.
</td></tr>
<tr><td>
[setSoftCcdPrediction(softCcdPrediction)](./server.rigidbody.setsoftccdprediction.md)
</td><td>
</td><td>
Sets the soft ccd prediction of the rigid body.
</td></tr>
<tr><td>
[setType(type)](./server.rigidbody.settype.md)
</td><td>
</td><td>
Sets the type of the rigid body.
</td></tr>
<tr><td>
[sleep()](./server.rigidbody.sleep.md)
</td><td>
</td><td>
Explicitly puts the rigid body to sleep. Physics otherwise optimizes sleeping.
</td></tr>
<tr><td>
[wakeUp()](./server.rigidbody.wakeup.md)
</td><td>
</td><td>
Wakes up the rigid body. Physics otherwise optimizes waking it when necessary.
</td></tr>
</tbody></table>