Skip to main content

Class: RigidbodyManager

Creates and updates rigidbody components.

Constructors​

Constructor​

new RigidbodyManager(): RigidbodyManager;

Returns​

RigidbodyManager

Methods​

Create()​

static Create(entity): Promise<boolean>;

Creates a rigidbody component on an entity.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.

Returns​

Promise<boolean>

A promise that resolves to true if the rigidbody component was created, or false otherwise.


Destroy()​

static Destroy(entity): Promise<boolean>;

Removes a rigidbody component from an entity.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.

Returns​

Promise<boolean>

A promise that resolves to true if the rigidbody component was removed, or false otherwise.


HasComponent()​

static HasComponent(entity): Promise<boolean>;

Checks whether an entity has a rigidbody component.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<boolean>

A promise that resolves to true if the entity has a rigidbody component, or false otherwise.


GetLinearVelocity()​

static GetLinearVelocity(entity): Promise<vec3>;

Gets the linear velocity of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<vec3>

A promise that resolves to the linear velocity in meters per second.


GetAngularVelocity()​

static GetAngularVelocity(entity): Promise<vec3>;

Gets the angular velocity of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<vec3>

A promise that resolves to the angular velocity in radians per second.


AddForce()​

static AddForce(
entity,
force,
forceMode?): Promise<void>;

Adds force to a rigidbody.

The force is expressed in newtons for ForceMode.Force, meters per second squared for ForceMode.Acceleration, newton-seconds for ForceMode.Impulse, and meters per second for ForceMode.VelocityChange.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
forcevec3The force vector.
forceMode?ForceModeThe force application mode. Defaults to ForceMode.Force.

Returns​

Promise<void>

A promise that resolves when the force has been applied.


AddForceAtPosition()​

static AddForceAtPosition(
entity,
force,
position,
forceMode?): Promise<boolean>;

Adds force to a rigidbody at a world position.

The force is expressed in newtons for ForceMode.Force, meters per second squared for ForceMode.Acceleration, newton-seconds for ForceMode.Impulse, and meters per second for ForceMode.VelocityChange.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
forcevec3The force vector.
positionvec3The world position where the force is applied, in meters.
forceMode?ForceModeThe force application mode. Defaults to ForceMode.Force.

Returns​

Promise<boolean>

A promise that resolves to true if the force was applied, or false otherwise.


AddTorque()​

static AddTorque(
entity,
torque,
forceMode?): Promise<void>;

Adds torque to a rigidbody.

The torque is expressed in newton-meters for ForceMode.Force, radians per second squared for ForceMode.Acceleration, newton-meter-seconds for ForceMode.Impulse, and radians per second for ForceMode.VelocityChange.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
torquevec3The torque vector.
forceMode?ForceModeThe force application mode. Defaults to ForceMode.Force.

Returns​

Promise<void>

A promise that resolves when the torque has been applied.


GetIsKinematic()​

static GetIsKinematic(entity): Promise<boolean>;

Gets whether a rigidbody is kinematic.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<boolean>

A promise that resolves to true if the rigidbody is kinematic, or false otherwise.


SetIsKinematic()​

static SetIsKinematic(entity, isKinematic): Promise<void>;

Sets whether a rigidbody is kinematic.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
isKinematicbooleanWhether the rigidbody is kinematic.

Returns​

Promise<void>

A promise that resolves when the kinematic setting has been changed.


GetUseGravity()​

static GetUseGravity(entity): Promise<boolean>;

Gets whether a rigidbody uses gravity.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<boolean>

A promise that resolves to true if the rigidbody uses gravity, or false otherwise.


SetUseGravity()​

static SetUseGravity(entity, useGravity): Promise<void>;

Sets whether a rigidbody uses gravity.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
useGravitybooleanWhether the rigidbody uses gravity.

Returns​

Promise<void>

A promise that resolves when the gravity setting has been changed.


GetMass()​

static GetMass(entity): Promise<number>;

Gets the mass of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<number>

A promise that resolves to the mass in kilograms.


SetMass()​

static SetMass(entity, mass): Promise<void>;

Sets the mass of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
massnumberThe mass in kilograms.

Returns​

Promise<void>

A promise that resolves when the mass has been changed.


GetLinearDamping()​

static GetLinearDamping(entity): Promise<number>;

Gets the linear damping of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<number>

A promise that resolves to the linear damping.


SetLinearDamping()​

static SetLinearDamping(entity, linearDamping): Promise<void>;

Sets the linear damping of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
linearDampingnumberThe linear damping.

Returns​

Promise<void>

A promise that resolves when the linear damping has been changed.


GetAngularDamping()​

static GetAngularDamping(entity): Promise<number>;

Gets the angular damping of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns​

Promise<number>

A promise that resolves to the angular damping.


SetAngularDamping()​

static SetAngularDamping(entity, angularDamping): Promise<void>;

Sets the angular damping of a rigidbody.

Parameters​

ParameterTypeDescription
entitynumberThe Entity to update.
angularDampingnumberThe angular damping.

Returns​

Promise<void>

A promise that resolves when the angular damping has been changed.