Skip to main content

Physics

API for physics-related functions.

Constants

Physics.IS_DEBUGGER_AVAILABLE

Whether the physics debugger is available. True on debug builds, false otherwise.

Physics.IS_DEBUGGER_AVAILABLE: boolean

Functions

Physics.connectDebugger

Connects the PhysX Visual Debugger. This function is only available on debug builds.

Physics.connectDebugger(host: string, port: number, timeout: number)

Parameters

NameTypeDefault ValueDescription
hoststringRequiredThe host to connect to.
portnumberRequiredThe port to connect to.
timeoutnumberRequiredThe timeout in milliseconds.

Physics.disconnectDebugger

Disconnects the PhysX Visual Debugger. This function is only available on debug builds.

Physics.disconnectDebugger()

Physics.isDebuggerConnected

Checks if the PhysX Visual Debugger is connected. This function is only available on debug builds.

Physics.isDebuggerConnected(): boolean

Returns

NameTypeDescription
connectedbooleanWhether the debugger is connected.

Physics.getMass

Gets the mass of a rigid body.

Physics.getMass(entity: entity): number

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
massnumberThe mass of the rigid body.

Physics.setMass

Sets the mass of a rigid body.

Physics.setMass(entity: entity, mass: number)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
massnumberRequiredThe mass to set.

Physics.getLinearDamping

Gets the linear damping of a rigid body.

Physics.getLinearDamping(entity: entity): number

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
dampingnumberThe linear damping of the rigid body.

Physics.setLinearDamping

Sets the linear damping of a rigid body.

Physics.setLinearDamping(entity: entity, damping: number)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
dampingnumberRequiredThe linear damping to set.

Physics.getAngularDamping

Gets the angular damping of a rigid body.

Physics.getAngularDamping(entity: entity): number

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
dampingnumberThe angular damping of the rigid body.

Physics.setAngularDamping

Sets the angular damping of a rigid body.

Physics.setAngularDamping(entity: entity, damping: number)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
dampingnumberRequiredThe angular damping to set.

Physics.getLinearVelocity

Gets the linear velocity of a rigid body.

Physics.getLinearVelocity(entity: entity): vector

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
velocityvectorThe linear velocity of the rigid body.

Physics.getAngularVelocity

Gets the angular velocity of a rigid body.

Physics.getAngularVelocity(entity: entity): vector

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
velocityvectorThe angular velocity of the rigid body.

Physics.getLinearAcceleration

Gets the linear acceleration of a rigid body.

Physics.getLinearAcceleration(entity: entity): vector

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
accelerationvectorThe linear acceleration of the rigid body.

Physics.getAngularAcceleration

Gets the angular acceleration of a rigid body.

Physics.getAngularAcceleration(entity: entity): vector

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.

Returns

NameTypeDescription
accelerationvectorThe angular acceleration of the rigid body.

Physics.addForce

Adds a force to a rigid body.

Force accumulation

Forces are accumulated until the next physics step. To clear the accumulated forces, call clearForce.

Physics.addForce(entity: entity, force: vector, mode?: ForceMode)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
forcevectorRequiredThe force to add.
modeForceMode?"ForceMode.Force"The force mode.

Physics.addTorque

Adds a torque to a rigid body.

Torque accumulation

Torques are accumulated until the next physics step. To clear the accumulated torques, call clearTorque.

Physics.addTorque(entity: entity, torque: vector, mode?: ForceMode)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
torquevectorRequiredThe torque to add.
modeForceMode?"ForceMode.Force"The force mode.

Physics.clearForce

Clears the currently accumulated forces of a rigid body.

Physics.clearForce(entity: entity, mode?: ForceMode)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
modeForceMode?"ForceMode.Force"The force mode of the forces to clear.

Physics.clearTorque

Clears the currently accumulated torques of a rigid body.

Physics.clearTorque(entity: entity, mode?: ForceMode)

Parameters

NameTypeDefault ValueDescription
entityentityRequiredThe entity with the rigid body.
modeForceMode?"ForceMode.Force"The force mode of the torques to clear.

Enums

ForceMode

Force modes which describe the unit of the force or torque given to addForce and addTorque.

Value
Force
Impulse
VelocityChange
Acceleration