XBLAX
|
  |
| Joined: 06 Apr 2012 |
| Total Posts: 82 |
|
|
| 19 Oct 2016 02:16 PM |
Greetings. I have been working on some terrain tools lately and it seems to be coming on well, yet there was an issue that occurred when wanting to incorporate an inventory with said tools.
The inventory, in this case, would be used to store certain values of a terrain material so it may be used in a future point in time. But the only way I've found to read the terrain material is by using Region3. The issue I'm having is that the region does not always pick up the physical terrain, instead just 'air'. I was wondering if anybody could help me with this? |
|
|
| Report Abuse |
|
XBLAX
|
  |
| Joined: 06 Apr 2012 |
| Total Posts: 82 |
|
| |
XBLAX
|
  |
| Joined: 06 Apr 2012 |
| Total Posts: 82 |
|
|
| 19 Oct 2016 03:13 PM |
Maybe I should just present what I have so far.
local tool = script.Parent.Parent local plr = game:GetService("Players").LocalPlayer local lastmat tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local region = Region3.new(mouse.Hit.p, Vector3.new(mouse.Hit.X-1,mouse.Hit.Y-1,mouse.Hit.Z-1)) region = region:ExpandToGrid(4) local material, occupancy = game.Workspace.Terrain:ReadVoxels(region, 4) local size = material.Size for x = 1, size.X do for y = 1, size.Y do for z = 1, size.Z do if material[x][y][z] ~= Enum.Material.Air and material[x][y][z] ~= Enum.Material.Water then -- attempt to ignore water... print("Material at (", x, y, z, "): ", material[x][y][z]) wait(0.5) game.Workspace.Terrain:FillBall(mouse.Hit.p, 4, Enum.Material.Air)
end end end end end) end) |
|
|
| Report Abuse |
|