Stores reusable settings uniform for a world (such as gravity magnitude and direction). See also: WorldComponent.worldSettings.

// 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;
interface WorldSettingsAsset {
    absoluteSpeedLimit: number;
    defaultFilter: Physics.Filter;
    defaultMatter: Matter;
    gravity: vec3;
    name: string;
    relativeSpeedLimit: number;
    simulationRate: number;
    slowDownStep: number;
    slowDownTime: number;
    uniqueIdentifier: string;
    getLayersCollidable(layerNumberA: number, layerNumberB: number): boolean;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    resetLayerCollisionMatrix(): void;
    setLayersCollidable(layerNumberA: number, layerNumberB: number, enable: boolean): void;
}

Hierarchy (view full)

Properties

absoluteSpeedLimit: number

Speed limit, in world space cm/s. Set to 0 to disable this.

defaultFilter: Physics.Filter

Default Filter used for colliders in the world.

defaultMatter: Matter

Default Matter used for colliders in the world. This is used for a collider when its matter field is unset.

gravity: vec3

Gravity acceleration vector (cm/s^2). Defaults to real-world gravity of 980 cm/s^2, downward.

name: string

The name of the Asset in Lens Studio.

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. The default of 0.5 only allows the object to move by half its size in a single step, which should prevent tunneling.

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, with 60hz as the default.

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.

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.

uniqueIdentifier: string

Methods

  • 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

    • layerNumberA: number
    • layerNumberB: number

    Returns boolean

  • Returns the name of this object's type.

    Returns string

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Resets the layer collision matrix such that all layer pairs are enabled.

    Returns 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

    • layerNumberA: number
    • layerNumberB: number
    • enable: boolean

    Returns void