PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Terrain

Show deprecated

Terrain

Show deprecated

Terrain is a feature that allows players to create dynamically morphable environments, with little to no lag. Terrain is currently based on a 4x4x4 grid of cells, where each cell has a number between 0 and 1 representing how much the geometry should occupy the cell, and the material of the cell. The occupancy determines how the cell will morph together with surrounding cells, and the result is the illusion of having no grid constraint. Terrain provides a practically unlimited amount of space to work with.

Properties

BinaryString

MaterialColors

[NotScriptable]

MaterialColors represents the editor for the Material Color feature, and cannot be edited by scripts.

To get the color of a material, use: Terrain/GetMaterialColor
To set the color of a material, use: Terrain/SetMaterialColor

Region3int16

MaxExtents

[ReadOnly] [NotReplicated]

Displays the boundaries of the largest possible editable region.

Color3

WaterColor

The tint of the Terrain water.

float

WaterReflectance

Controls how opaque the Terrain’s water reflections are.

float

WaterTransparency

The transparency of the Terrain water.

float

WaterWaveSize

Sets the maximum height of the Terrain water waves in studs.

float

WaterWaveSpeed

Sets how many times the Terrain water waves will move up and down per minute.

Functions

Vector3

CellCenterToWorld ( int x , int y , int z )

Returns the world position of the center of the terrain cell (x, y, z).

Vector3

CellCornerToWorld ( int x , int y , int z )

Returns the position of the lower-left-forward corner of the grid cell (x, y, z).

void

Clear ( )

Clears the terrain.

Instance

CopyRegion ( Region3int16 region )

Stores a chunk of terrain into a TerrainRegion object so it can be loaded back later. Note: TerrainRegion data does not replicate between server and client.

int

CountCells ( )

Returns the number of non-empty cells in the Terrain.

void

FillBall ( Vector3 center , float radius , Material material )

Fills a ball of smooth terrain in a given space.

void

FillBlock ( CFrame cframe , Vector3 size , Material material )

Fills a block of smooth terrain with a given location, rotation, size, and material.

void

FillCylinder ( CFrame cframe , float height , float radius , Material material )

void

FillRegion ( Region3 region , float resolution , Material material )

Fills a Region3 space with smooth terrain.

Color3

GetMaterialColor ( Material material )

Returns current terrain material color for specified terrain material.

void

PasteRegion ( Instance region , Vector3int16 corner , bool pasteEmptyCells )

Applies a chunk of terrain to the Terrain object. Note: TerrainRegion data does not replicate between server and client.

Tuple

ReadVoxels ( Region3 region , float resolution )

[CustomLuaState]

Returns a certain region of smooth terrain in table format. Both of the return arrays have an additional .Size property, a Vector3.

void

SetMaterialColor ( Material material , Color3 value )

Sets current terrain material color for specified terrain material.

Vector3

WorldToCell ( Vector3 position )

Returns the grid cell location that contains the point position.

Vector3

WorldToCellPreferEmpty ( Vector3 position )

Returns the grid cell location that contains the point position, preferring empty grid cells when position is on a grid edge.

Vector3

WorldToCellPreferSolid ( Vector3 position )

Returns the grid cell location that contains the point position, preferring non-empty grid cells when position is on a grid edge.

void

WriteVoxels ( Region3 region , float resolution , Array materials , Array occupancy )

[CustomLuaState]

Sets a certain region of smooth terrain using the table format

Events