Class · inherits BasePart
Terrain
Terrain lets you to create dynamically morphable environments.
About Terrain
The Terrain class lets you create dynamically morphable environments. It is
based on a 4×4×4 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.
For more information, see Terrain.
Properties 9
Decoration
: booleanNotScriptableEnables or disables terrain decoration.Currently enables or disables animated grass on the
Grassterrain material, although future modifications of this property may control additional decorative features.GrassLength
: floatNotScriptableSpecifies the length of animated grass.Specifies the length of animated grass on the
Grassterrain material, assumingDecorationis enabled. Valid values are between0.1and1.MaterialColors
: BinaryStringNotScriptableRepresents the editor for the Material Color feature and cannot be edited by scripts.MaterialColorsrepresents 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, useTerrain.SetMaterialColor.MaxExtents
: Region3int16ReadOnlyNotReplicatedDisplays the boundaries of the largest possible editable region.Displays the boundaries of the largest possible editable region as a
Region3int16. The returned value spans from(-32000, -32000, -32000)to(32000, 32000, 32000)in cell coordinates, where each cell is 4 studs wide. This corresponds to a world-space volume of -128,000 to 128,000 studs on each axis. The property is read-only.WaterColor
: Color3The tint ofTerrainwater.The tint color applied to
Terrainwater. ThisColor3value is blended with the water's base appearance to shift its overall hue. The default value is[0.05, 0.33, 0.36](a dark teal).WaterReflectance
: floatControls how opaqueTerrainwater reflections are.Controls how opaque the reflections on
Terrainwater are, on a scale of0(no reflections) to1(fully opaque reflections). The default value is1.WaterTransparency
: floatThe transparency ofTerrainwater.The transparency of
Terrainwater, on a scale of0(fully opaque) to1(fully transparent). The default value is0.3.WaterWaveSize
: floatSets the maximum height ofTerrainwater waves in studs.Sets the maximum height of
Terrainwater waves in studs. This is currently constrained to between0and1.WaterWaveSpeed
: floatSets how many timesTerrainwater waves will move up and down per minute.Sets how many times
Terrainwater waves will move up and down per minute. This is currently constrained to between0and100.
Methods 21
CellCenterToWorld
(x: int, y: int, z: int) → Vector3Returns the world position of the center of the terrain cell.Returns the world position of the center of the terrain cell at grid coordinates
(x, y, z). Each terrain cell is 4×4×4 studs, so this method returns the position of the lower-left-forward corner of the cell plus an offset of(2, 2, 2)studs.CellCornerToWorld
(x: int, y: int, z: int) → Vector3Returns the position of the lower-left-forward corner of the grid cell.Returns the world position of the lower-left-forward corner of the terrain cell at grid coordinates
(x, y, z). Each terrain cell is 4×4×4 studs, so the corner position is(x * 4, y * 4, z * 4).Clear
() → ()Clears all terrain.Clears the entire terrain, removing all material and occupancy data from every voxel. After calling this method, the
Terrainobject contains no geometry until new terrain is written via methods such asFillBlock()orWriteVoxels().CopyRegion
(region: Region3int16) → TerrainRegionStores a chunk of terrain into aTerrainRegionobject so it can be loaded back later.Stores a chunk of terrain into a
TerrainRegionobject so it can be loaded back later. Note thatTerrainRegiondata does not replicate between server and client.CountCells
() → intReturns the number of non-empty cells in the terrain.Returns the approximate number of non-empty cells in the terrain. A cell is considered non-empty when it has a material other than Air and an occupancy greater than zero. This count is an approximation and can be used to quickly gauge how much terrain geometry exists in the place.
FillBall
(center: Vector3, radius: float, material: Material) → ()Fills a ball of smooth terrain in a given space.Fills a spherical volume of smooth terrain centered at
centerwith the givenradius(in studs) andMaterial. Voxels within the sphere are set to full occupancy with the specified material. Existing terrain inside the sphere is overwritten.FillBlock
(cframe: CFrame, size: Vector3, material: Material) → ()Fills a block of smooth terrain with a given location, rotation, size, and material.Fills an oriented rectangular volume of smooth terrain at the position and rotation specified by
cframe, with the dimensions given bysize(in studs), using the specifiedMaterial. Because the block is oriented by aCFrame, it can be rotated to any angle. Existing terrain inside the volume is overwritten.FillCylinder
(cframe: CFrame, height: float, radius: float, material: Material) → ()Fills a cylinder of smooth terrain in a given space.Fills a cylinder of smooth terrain in a given space. The space is defined using a
CFrame, height, and radius.FillRegion
(region: Region3, resolution: float, material: Material) → ()Fills aRegion3space with smooth terrain.Fills an axis-aligned
Region3volume of smooth terrain with the specifiedMaterialat full occupancy. Theresolutionparameter must be exactly4. The region must be aligned to the voxel grid; useRegion3.ExpandToGridto align a region before calling.FillWedge
(cframe: CFrame, size: Vector3, material: Material) → ()Fills a wedge-shaped volume of terrain with the givenMaterial.GetMaterialColor
(material: Material) → Color3Returns current terrain material color for specified terrain material.PasteRegion
(region: TerrainRegion, corner: Vector3int16, pasteEmptyCells: boolean) → ()Applies a chunk of terrain to theTerrainobject.Applies a chunk of terrain to the
Terrainobject. Note thatTerrainRegiondata does not replicate between server and client.ReadVoxelChannels
(region: Region3, resolution: float, channelIds: Array) → DictionaryReturns a region of terrain voxel data in table format based on the channel names.Returns voxel data from a region of terrain, separated by channel. Unlike
ReadVoxels(), this method lets you specify exactly which channels to read (SolidMaterial,SolidOccupancy, and/orLiquidOccupancy), and returns a dictionary keyed by channel ID. Theregionmust be aligned to the voxel grid,resolutionmust be4, and the region cannot exceed 4,194,304 voxels.ReadVoxels
(region: Region3, resolution: float) → TupleReturns a certain region of smooth terrain in table format.Returns the voxel data for a region of smooth terrain as two 3D arrays:
materials(an array ofMaterialvalues) andoccupancies(an array of numbers between0and1). Theregionmust be aligned to the voxel grid,resolutionmust be4, and the region cannot exceed 4,194,304 voxels. For more granular channel control, seeReadVoxelChannels().ReplaceMaterial
(region: Region3, resolution: float, sourceMaterial: Material, targetMaterial: Material) → ()Replaces the terrain of a material within a region with another material.ReplaceMaterial replaces terrain of a certain
Materialwithin aRegion3with another material. Essentially, it is a find-and-replace operation onTerrainmaterials.When calling this method, the
resolutionparameter must be exactly4. Additionally,regionmust be aligned to the terrain materials grid, such that the components of the region's minimum and maximum points must be divisible by4. UseRegion3.ExpandToGridto make a region compatible with this function.SetMaterialColor
(material: Material, value: Color3) → ()Sets current terrain material color for specified terrain material.Sets current terrain material color for specified terrain material. Terrain material will shift its base color toward specified color.
WorldToCell
(position: Vector3) → Vector3Returns the grid cell location that contains the position point.Returns the grid cell location that contains the point
position.WorldToCellPreferEmpty
(position: Vector3) → Vector3Returns the grid cell location that contains the position point, preferring empty grid cells when position is on a grid edge.Returns the grid cell location that contains the point
position, preferring empty grid cells when position is on a grid edge.WorldToCellPreferSolid
(position: Vector3) → Vector3Returns the grid cell location that contains the point position, preferring non-empty grid cells when position is on a grid edge.WriteVoxelChannels
(region: Region3, resolution: float, channels: Dictionary) → ()Sets a region of terrain using a dictionary of voxel channel data.Sets a region of terrain using a dictionary of per-channel voxel data, the inverse of
ReadVoxelChannels(). Thechannelsdictionary maps channel ID strings (SolidMaterial,SolidOccupancy, and/orLiquidOccupancy) to their respective 3D data arrays. You may write one or more channels in a single call. Theregionmust be aligned to the voxel grid,resolutionmust be4, and the region cannot exceed 4,194,304 voxels.WriteVoxels
(region: Region3, resolution: float, materials: Array, occupancy: Array) → ()Sets a certain region of smooth terrain using table format.Sets a region of smooth terrain from two 3D arrays:
materials(an array ofMaterialvalues) andoccupancy(an array of numbers between0and1). Both arrays must have dimensions that exactly match the target region in voxels. Theregionmust be aligned to the voxel grid,resolutionmust be4, and the region cannot exceed 4,194,304 voxels. For more granular channel control, seeWriteVoxelChannels().
Terrain also has every member of BasePart. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.