I'm currently messing around with different Terrain methods.
However,when I try this script (taken from the wiki), I get an error saying 'Region cannot be empty' :
01 | region = Region 3. new(game.Workspace.A.Position,game.Workspace.B.Position) |
02 | region = region:ExpandToGrid( 4 ) |
03 | local material, occupancy = game.Workspace.Terrain:ReadVoxels(region, 4 ) |
04 | local size = material.Size |
05 | for x = 1 , size.X do |
06 | for y = 1 , size.Y do |
07 | for z = 1 , size.Z do |
08 | print ( "Material at (" , x, y, z, "): " , material [ x ] [ y ] [ z ] ) |
09 | print ( "Occupancy at (" , x, y, z, "): " , occupancy [ x ] [ y ] [ z ] ) |
10 | end |
11 | end |
12 | end |
I have two parts in the workspace : "A" and "B" ; Both are at opposite corners of my terrain chunk.
yes,I have swapped the Vector3s when defining 'region', yet it still says "Region cannot be empty".
Any way to fix this?
I had the same problem while using FillRegion. But there is a solution! I tested it on my own script and yours, and it works on both.
All you have to do is make sure that the x, y, and z coordinates in the first Vector3 are lower than the x, y, and z coordinates in the second Vector3. ALL three of them must be lower in value.
For example:
1 | region = Region 3. new(Vector 3. new( 1 , 1 , 1 ), Vector 3. new( 9 , 9 , 9 )) |
As you can see, the first Vector3 coordinates are lower than the other ones on all three axes.
Just adjust your A and B positions so that A is lower than B on x, y, and z. You'll get an error if even one coordinate in the first Vector3 is greater than it's corresponding coordinate in the second Vector3. Hope this helps :)