PhysXComponent
PhysXComponent
Native physx rigid body component
Provides access to a native mesh component instance. Only available when using physx enabled runtime, see “Project Settings > Runtime”.
Kind: global class
- PhysXComponent
- .static
- .static
- .kinematic
- .kinematic ⇒ boolean
- .shape
- .shape ⇒ Shape
- .shapeData
- .shapeData
- .extents
- .extents
- .staticFriction
- .staticFriction
- .dynamicFriction
- .dynamicFriction
- .restitution
- .restitution
- .linearDamping
- .linearDamping
- .angularDamping
- .angularDamping
- .linearVelocity
- .linearVelocity ⇒ Float32Array
- .angularVelocity
- .angularVelocity ⇒ Float32Array
- .mass
- .mass ⇒ number
- .massSpaceInteriaTensor
- .addForce(f, m, localForce, p, local)
- .addTorque(f, m)
- .onCollision(callback)
- .onCollisionWith(otherComp, callback) ⇒ number
- .removeCollisionCallback(callbackId)
.static
Set whether this rigid body is static
Setting this property only takes effect once the component switches from inactive to active.
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
b | boolean | Whether the rigid body should be static |
.static
Whether this rigid body is static
This property returns whether the rigid body is effectively static. If static property was set while the rigid body was active, it will not take effect until the rigid body is set inactive and active again. Until the component is set inactive, this getter will return whether the rigidbody is actually static.
Kind: instance property of PhysXComponent
.kinematic
Set whether this rigid body is kinematic
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
b | boolean | Whether the rigid body should be kinematic |
.kinematic ⇒ boolean
Kind: instance property of PhysXComponent
Returns: boolean - Whether this rigid body is kinematic
.shape
Set the shape for collision detection
Kind: instance property of PhysXComponent
0.8.5+
Param | Type | Description |
---|---|---|
s | Shape | New shape |
.shape ⇒ Shape
The shape for collision detection
Kind: instance property of PhysXComponent
Returns: Shape - Currently set shape
.shapeData
Set additional data for the shape.
Retrieved only from #shapeData().
Kind: instance property of PhysXComponent
.shapeData
Additional data for the shape.
null
for None, Sphere, Capsule,
Box, Plane, Shape.. {index: n}
for
TriangleMesh and Shape.ConvexHull.
This data is currently only for passing onto or creatin other PhysXComponent.
Kind: instance property of PhysXComponent
.extents
Set the shape extents for collision detection
Kind: instance property of PhysXComponent
0.8.5+
Param | Type | Description |
---|---|---|
e | Array.<number> | New extents for the shape |
.extents
The shape extents for collision detection
Kind: instance property of PhysXComponent
.staticFriction
Get staticFriction
Kind: instance property of PhysXComponent
.staticFriction
Set staticFriction
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | number | New staticFriction |
.dynamicFriction
Get dynamicFriction
Kind: instance property of PhysXComponent
.dynamicFriction
Set dynamicFriction
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | number | New dynamicDamping |
.restitution
Get restitution
Kind: instance property of PhysXComponent
.restitution
Set restitution
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | number | New restitution |
.linearDamping
Get linearDamping
Kind: instance property of PhysXComponent
.linearDamping
Set linearDamping
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | number | New linearDamping |
.angularDamping
Get angularDamping
Kind: instance property of PhysXComponent
.angularDamping
Set angularDamping
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | number | New angularDamping |
.linearVelocity
Set linear velocity
Has no effect, if the component is not active.
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | Array.<number> | New linear velocity |
.linearVelocity ⇒ Float32Array
Kind: instance property of PhysXComponent
Returns: Float32Array - Linear velocity or [0, 0, 0]
if the component is not active.
.angularVelocity
Set angular velocity
Has no effect, if the component is not active.
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | Array.<number> | New angular velocity |
.angularVelocity ⇒ Float32Array
Kind: instance property of PhysXComponent
Returns: Float32Array - Angular velocity or [0, 0, 0]
if the component is not active.
.mass
Set mass
PhysX Manual - “Mass Properties”
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
m | number | New mass |
.mass ⇒ number
Kind: instance property of PhysXComponent
Returns: number - mass
.massSpaceInteriaTensor
Set mass space interia tensor
PhysX Manual - “Mass Properties”
Has no effect, if the component is not active.
Kind: instance property of PhysXComponent
Param | Type | Description |
---|---|---|
v | Array.<number> | New mass space interatia tensor |
.addForce (f, m, localForce, p, local)
Apply a force
PhysX Manual - “Applying Forces and Torques”
Has no effect, if the component is not active.
Kind: instance method of PhysXComponent
Param | Type | Description |
---|---|---|
f | Array.<number> | Force vector |
m | Array.<number> | Force mode, see ForceMode, default Force . |
localForce | Array.<number> | Whether the force vector is in local space, default false . |
p | Array.<number> | Position to apply force at, default is center of mass. |
local | Array.<number> | Whether position is in local space, default false . |
.addTorque (f, m)
Apply torque
PhysX Manual - “Applying Forces and Torques”
Has no effect, if the component is not active.
Kind: instance method of PhysXComponent
Param | Type | Description |
---|---|---|
f | Array.<number> | Force vector |
m | Array.<number> | Force mode, see ForceMode, default Force . |
.onCollision (callback)
Add on collision callback
Kind: instance method of PhysXComponent
Param | Type | Description |
---|---|---|
callback | collisionCallback | Function to call when this rigid body (un)collides with any other. |
Example
|
|
.onCollisionWith (otherComp, callback) ⇒ number
Add filtered on collision callback
Kind: instance method of PhysXComponent
Returns: number - Id of the new callback for use with #removeCollisionCallback.
Param | Type | Description |
---|---|---|
otherComp | PhysXComponent | Component for which callbacks will be triggered. If you pass this component, the method is equivalent to onCollision. |
callback | collisionCallback | Function to call when this rigid body (un)collides with otherComp . |
.removeCollisionCallback (callbackId)
Remove a collision callback added with #onCollision or #onCollisionWith.
Kind: instance method of PhysXComponent
Throws:
- When the callback does not belong to the component
- When the callback does not exist
Param | Type | Description |
---|---|---|
callbackId | number | Callback id as returned by #onCollision or #onCollisionWith. |