Physics.WorldSettingsAsset
ClassStores reusable settings for a Physics WorldComponent such as gravity magnitude and direction.
- Available on all platforms
Since Lens Scripting v164
Index
Properties
Methods
Example
// Change gravity in a given World Settings Asset
// @input Physics.WorldSettingsAsset worldAsset
script.worldAsset.gravity = new vec3(0.0, -300.0, 0.0);
// Create world settings.
var settings = Physics.WorldSettingsAsset.create();
print(settings);
// Modify layer collision matrix.
settings.setLayersCollidable(0, 3, false);
settings.setLayersCollidable(200, 20, false);
print(settings);
print(settings.getLayersCollidable(3, 0));
settings.resetLayerCollisionMatrix();
print(settings);
print(settings.getLayersCollidable(3, 0));
// Assign world settings to a collider.
script.myCollider.worldSettings = settings;
Extends
Properties
absoluteSpeedLimit
absoluteSpeedLimit:
number
Speed limit, in world space cm/s. Set to 0 to disable this.
Since
Lens Scripting Version 169
Default Value
0
defaultFilter
defaultFilter:
Filter
Default Filter used for colliders in the world.
Since
Lens Scripting Version 183
Default Value
null
defaultMatter
defaultMatter:
Matter
Default Matter used for colliders in the world. This is used for a collider when its matter field is unset.
Since
Lens Scripting Version 169
Default Value
null
gravity
gravity:
vec3
Gravity acceleration vector (cm/s^2).
Since
Lens Scripting Version 164
Default Value
(0, -980, 0)
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
relativeSpeedLimit
relativeSpeedLimit:
number
Speed limit, relative to shape size. Set to 0 to disable this. The effective world space speed limit is scaled by simulation rate, so this is the maximum distance the object can move in a single step.
Since
Lens Scripting Version 169
Default Value
0.5
simulationRate
simulationRate:
number
Simulation rate, in steps per second. Larger values improve simulation accuracy at the cost of performance. This is limited to intervals of 30hz, in the range 30-240hz.
Since
Lens Scripting Version 169
Default Value
60
slowDownStep
slowDownStep:
number
Slow down simulation step frequency (higher values are slower). Limited to >=1.0. This achieves a slow-motion effect by reducing the number of simulation steps each frame. Useful for debugging as large values will cause noticeably discrete steps.
Since
Lens Scripting Version 169
Default Value
1
slowDownTime
slowDownTime:
number
Slow down simulation time (higher values are slower). This achieves a slow-motion effect by scaling simulation time. Unlike slowDownStep, it will maintain smooth motion, but has accuracy problems at large scales.
Since
Lens Scripting Version 169
Default Value
1
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
create()
staticcreate():WorldSettingsAsset
Create an instance with default settings.
Returns
WorldSettingsAsset
Since
Lens Scripting Version 183
getLayersCollidable()
getLayersCollidable(
layerNumberA,layerNumberB):boolean
Given 2 layer numbers A and B, returns true if colliders in A collide with colliders in B, and vice-versa. The layer numbers correspond to those used to form a LayerSet with LayerSet.fromNumber(). The relationship is symmetric, so if collision is disabled for (A, B), it is also disabled for (B, A). This accesses a flag in the "Layer Collision Matrix", as viewable in Studio. Note however that layer numbers are not the same as layer IDs. To get the number of a Studio-created layer, use LayerSet.numbers.
Parameters
| Parameter | Type |
|---|---|
layerNumberA | number |
layerNumberB | number |
Returns
boolean
Since
Lens Scripting Version 183
getTypeName()
staticgetTypeName():TypeName<WorldSettingsAsset>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<WorldSettingsAsset>
Since
Lens Scripting Version 164
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
resetLayerCollisionMatrix()
resetLayerCollisionMatrix():
void
Resets the layer collision matrix such that all layer pairs are enabled.
Returns
void
Since
Lens Scripting Version 183
setLayersCollidable()
setLayersCollidable(
layerNumberA,layerNumberB,enable):void
Given 2 layer numbers A and B, enables or disables collision between colliders in those layers. The layer numbers correspond to those used to form a LayerSet with LayerSet.fromNumber(). The relationship is symmetric, so if collision is disabled for (A, B), it is also disabled for (B, A). This accesses a flag in the "Layer Collision Matrix", as viewable in Studio. Note however that layer numbers are not the same as layer IDs. To get the number of a Studio-created layer, use LayerSet.numbers.
Parameters
| Parameter | Type |
|---|---|
layerNumberA | number |
layerNumberB | number |
enable | boolean |
Returns
void
Since
Lens Scripting Version 183