local Workspace = game:GetService("Workspace")
-- Creates a ball of grass at (0,0,-10) with a radius of 10 studs
Workspace.Terrain:FillBall(Vector3.new(0, 0, -10), 10, Enum.Material.Grass)
I dont know how to save/load multiple terrain settings and I’ve never seen someone do it. I suggest you make terrain maps far away from each other and teleport the players according to vote results.(also enable streaming for performance)
Alright I’ll try this.
Which I got the great I’m not not wasting my time
Yeah. The way to do this is to run the CopyRegion function using the command bar, parenting the TerrainRegion instance it makes to the workspace and then to your script then while playing the game running PasteRegion to paste the terrain accordingly. I can’t be sure if it would work or not but that’s theonly thing I can think off…
Also this got me dead.
I’ve used this plugin before to save and load terrain on a project a couple years ago and it worked pretty well. I think there are others that do the same thing as well if this one doesn’t work anymore. Hope this helps!
I’m having issues trying to copy the specific Region3int16 in order for me to paste it. I dont want to copy the entire terrain
Is there any way I can copy a specific map’s region using Region3Int16?
I would greatly appreciate any help.
I have no experience with terrain.
This is my code attempting to copy Map 1 using 2 different parts (nothing happens)
local max_part = workspace.Region_Max
local min_part = workspace.Region_Min
local min = Vector3int16.new(
min_part.Position.X,
min_part.Position.Y,
min_part.Position.Z
)
local max = Vector3int16.new(
max_part.Position.X,
max_part.Position.Y,
max_part.Position.Z
)
local terrainRegion = workspace.Terrain:CopyRegion(Region3int16.new(min,max))
print(workspace.Terrain.MaxExtents)
print(terrainRegion)
workspace.Terrain:Clear()
task.wait(2)
workspace.Terrain:PasteRegion(terrainRegion, min, true)
That’s odd… are you sure min and max parts are set correctly? And could you wait a few hours till I come back, I’ll write a code and send it.
I’m gonna check again to make sure
min is min_part
and max is max_part
The script does clear the terrain right?
Try using the code snippet from the doc. I can’t help much as I don’t have access to my pc.
Okay!! It has come to my view that the terrain does get pasted but just really really far away!
It also came to my attention that using parts to specify limits is buggy as it printed wrong pieces at wrong points so you just have to be quite specific…
I also found this post: Script execution timeout while copying small terrain region - #3 by vicy98
Which yes is a bug report but has a working script.
--!strict
local copyPart = game.Workspace.CopyPart
local destinationPart = game.Workspace.DestinationPart
local offset = Vector3.one/2
local function getCorners(part: BasePart)
return {
trForward = part.Position + part.Size*offset ,
blBack = part.Position + part.Size*(-offset)
}
end
local function convertVector3ToVector3int16(vector: Vector3)
return Vector3int16.new(vector.X, vector.Y, vector.Z)
end
local function convertVintToV(vector: Vector3int16)
return Vector3.new(vector.X, vector.Y, vector.Z)
end
--Divide by 4 to align with voxel coordinate system
local function getRegion3Int16FromVector3(min: Vector3, max: Vector3)
return Region3int16.new(convertVector3ToVector3int16(min)/4, convertVector3ToVector3int16(max)/4)
end
local copyPartCorners = getCorners(copyPart)
local copyRegion = getRegion3Int16FromVector3(copyPartCorners.blBack, copyPartCorners.trForward)
print('Copied region:', copyRegion)
local copiedTerrainRegion = game.Workspace.Terrain:CopyRegion(copyRegion)
workspace.Terrain:Clear()
local destinationCorners = getCorners(destinationPart)
local destinationRegion = getRegion3Int16FromVector3(destinationCorners.blBack, destinationCorners.trForward)
print('Destination region:', destinationRegion)
game.Workspace.Terrain:PasteRegion(copiedTerrainRegion, destinationRegion.Min, true)
It works, however my map will be bigger than the maximum amount a part can extend to.
What should I do?
Nvm I have an idea, I will try copying different parts of the map using multiple parts and paste each individual part of the map alone and I’ll collect them together.
Maybe just use two parts? Break down the part? Or that.
Yeah that’s exactly what I thought, I’ll try doing that.
Update: It worked.
Woo hoo! Let’s go! Glad I could help you on this! Good luck developing!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.