Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Region cannot be empty error when reading terrain voxels?

Asked by 8 years ago

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' :

01region=Region3.new(game.Workspace.A.Position,game.Workspace.B.Position)
02region = region:ExpandToGrid(4)
03local material, occupancy = game.Workspace.Terrain:ReadVoxels(region, 4)
04local size = material.Size
05for 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
12end

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?

1 answer

Log in to vote
3
Answered by 8 years ago
Edited 8 years ago

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:

1region = Region3.new(Vector3.new(1,1,1), Vector3.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 :)

Ad

Answer this question