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
Name | Type | Default Value | Description |
---|---|---|---|
host | string | Required | The host to connect to. |
port | number | Required | The port to connect to. |
timeout | number | Required | The 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
Name | Type | Description |
---|---|---|
connected | boolean | Whether the debugger is connected. |
Physics.getMass
Gets the mass of a rigid body.
Physics.getMass(entity: entity): number
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
mass | number | The mass of the rigid body. |
Physics.setMass
Sets the mass of a rigid body.
Physics.setMass(entity: entity, mass: number)
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
mass | number | Required | The mass to set. |
Physics.getLinearDamping
Gets the linear damping of a rigid body.
Physics.getLinearDamping(entity: entity): number
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
damping | number | The linear damping of the rigid body. |
Physics.setLinearDamping
Sets the linear damping of a rigid body.
Physics.setLinearDamping(entity: entity, damping: number)
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
damping | number | Required | The linear damping to set. |
Physics.getAngularDamping
Gets the angular damping of a rigid body.
Physics.getAngularDamping(entity: entity): number
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
damping | number | The angular damping of the rigid body. |
Physics.setAngularDamping
Sets the angular damping of a rigid body.
Physics.setAngularDamping(entity: entity, damping: number)
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
damping | number | Required | The angular damping to set. |
Physics.getLinearVelocity
Gets the linear velocity of a rigid body.
Physics.getLinearVelocity(entity: entity): vector
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
velocity | vector | The linear velocity of the rigid body. |
Physics.getAngularVelocity
Gets the angular velocity of a rigid body.
Physics.getAngularVelocity(entity: entity): vector
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
velocity | vector | The angular velocity of the rigid body. |
Physics.getLinearAcceleration
Gets the linear acceleration of a rigid body.
Physics.getLinearAcceleration(entity: entity): vector
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
acceleration | vector | The linear acceleration of the rigid body. |
Physics.getAngularAcceleration
Gets the angular acceleration of a rigid body.
Physics.getAngularAcceleration(entity: entity): vector
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
Returns
Name | Type | Description |
---|---|---|
acceleration | vector | The 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
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
force | vector | Required | The force to add. |
mode | ForceMode? | "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
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
torque | vector | Required | The torque to add. |
mode | ForceMode? | "ForceMode.Force" | The force mode. |
Physics.clearForce
Clears the currently accumulated forces of a rigid body.
Physics.clearForce(entity: entity, mode?: ForceMode)
Parameters
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
mode | ForceMode? | "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
Name | Type | Default Value | Description |
---|---|---|---|
entity | entity | Required | The entity with the rigid body. |
mode | ForceMode? | "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 |