Skip to content
EnvironmentSettings

Settings / EnvironmentSettings

EnvironmentSettings Class

Environment settings

Effect

Effective when called on client-side

Example usage: Create a script named "ClassExample", place it in the object bar, open the script, enter the following code to save, run the game, and you will see the corresponding method call information in the server log. The code is as follows:

ts
@Component
export default class ClassExample extends Script {

    protected onStart(): void {
        this.RoomSettings();
    }

    public RoomSettings(){
        let gra = EnvironmentSettings.getGravity();
        Console.log ("current gravity size:"+gra);

        //Set Gravity mode
        let mode = EnvironmentSettings.getGravityMode();
    }
}
@Component
export default class ClassExample extends Script {

    protected onStart(): void {
        this.RoomSettings();
    }

    public RoomSettings(){
        let gra = EnvironmentSettings.getGravity();
        Console.log ("current gravity size:"+gra);

        //Set Gravity mode
        let mode = EnvironmentSettings.getGravityMode();
    }
}

Table of contents

Accessors

deathBoundaryEnabled(): boolean other
Whether to activate the death boundary. The height limit of the death boundary will only take effect after it is enabled
deathBoundaryHeight(): number other
Get the height of the death boundary, range: [-50000, 50000]. After the height function of the death boundary is enabled, the character will enter the death state and reborn when falling below the death boundary, and other objects will be destroyed

Methods

getGravity(): number other
Get the current gravity magnitude
getGravityMode(): GravityMode other
Get the current gravity mode
setGlobalTimeDilation(timeDilation: number): void other
Set the overall expansion time speed of world

Accessors

deathBoundaryEnabled

Static get deathBoundaryEnabled(): boolean other

Whether to activate the death boundary. The height limit of the death boundary will only take effect after it is enabled

Returns

boolean

deathBoundaryHeight

Static get deathBoundaryHeight(): number other

Get the height of the death boundary, range: [-50000, 50000]. After the height function of the death boundary is enabled, the character will enter the death state and reborn when falling below the death boundary, and other objects will be destroyed

Returns

number

Methods

getGravity

Static getGravity(): number other

Get the current gravity magnitude

Returns

numberGravity magnitude. If the return value is undefined, please check whether the client call or whether the gravity size is set

getGravityMode

Static getGravityMode(): GravityMode other

Get the current gravity mode

Returns

GravityModeGravity mode. If the return value is undefined, check whether to call on the client or whether to set gravity mode

setGlobalTimeDilation

Static setGlobalTimeDilation(timeDilation): void other

Set the overall expansion time speed of world

Parameters

timeDilation numberUsage: Inflation time rate
Type: Floating point number< Range: The default global inflation time rate is 1. When the inflation time speed is set to less than 1, the overall running time of all objects in the world starts to slow down. The minimum expansion time velocity is 0.2. In stand-alone mode, the expansion can be set to 0 to achieve the effect of time pause.