I’m new to terrain and region3, and I want to script something much like roblox studio’s built-in terrain generation. I want the generation to be constrained to a cube, like inside of it but unable to go outside certain borders. Someone told me that using Terrain:WriteVoxels() would be useful for achieving this. However, I don’t really understand the wiki on it and there were no tutorials either.
Try this wiki article, which goes into a ton of detail and clearly explains the steps:
Can you explain what the occupancy and material arrays are for? And how would you set them to the correct size to be aligned with the voxel grid?
The occupancy table defines how “full” each voxel is.
The material table defines the material (suprise!) for each voxel.
You can use Region3:ExpandToGrid to help with alignment.
So if i wanted to set a cube area with 50 studs long 50 studs wide and 50 studs tall, how exactly would I do that with Terrain:WriteVoxels()?
And how would I know what to put in the materials 3D array and occupancy 3D array?
The tutorial explains that you could use FillBlock() to do that without needing to worry about arrays. Read that part of the tutorial.
Then is WriteVoxels() the best solution to generate terrain like roblox studio’s terrain generator, or is there a better option? I recieved some help from people explaining how 3D arrays work. I get the parameters now, I’m just somewhat confused how you use it to generate terrain.
I do not think you need to deal with WriteVoxels
. That is for more complicated terrain manipulation.
For what you want, I would say that the methods such as FillBlock
and FillBall
are what you want. They let you input things like a position and size of a chunk, rather than dealing with individual voxels.
You can view the complete list on the Terrain API page (scroll down to FillBall).
Yes but if I wanted to generate terrain how would I do that?
I’m pretty sure functions like FillBlock and FillBall only fill cubes to the max. I’m talking about terrain generation restrained to a cube, so they cannot go outside of the cube but they can go inside.