I’ve recently been working on randomly generating hallways. I do this by generating the floors, and then adding 4 walls along the edges of the floor parts. The problem is that when the hallway turns, the walls block off the hallway, as seen here:
I have tried doing this by using unions that will negate out the parts of the wall that are in the way,
but this is a pretty hacky solution and also leads to weird collisions. Is there some way that I can do this with math instead? I imagine this means somehow determining where these unwanted wall sections are, and then resizing and moving the walls accordingly.
I'm not sure if putting the code here is neccesary, but here's the relevant bit
I understand that this code is pretty hard to read, but basically I’m just creating four walls around each of the edges of the floor part to create the hallways.
-- generate walls
local x, z = true,true
for index, floor in pairs(Floors:GetChildren()) do
for i = 1, 4 do
local pt = floor:Clone()
local mult = z and 1 or -1
pt.Size = x and Vector3.new(1,height,floor.Size.Z) or Vector3.new(floor.Size.X,height,1)
pt.Position = floor.Position+(x and Vector3.new(mult*floor.Size.X/2,height/2,0) or Vector3.new(0,height/2,mult*floor.Size.Z/2))
pt.Parent = Walls
local h = x; x = not z; z = h
end
end
-- remove excess walls that block path?