Okay so basically i did a room generation system that succesfully(not rlly) creates 10 room i just created 4 sets of rooms, first one is a hall, second is a turn, third is a stairs up, and the fourth is a pentagon shaped large room, and when i run it, every room get mixed with each other and i showed it on 2nd photo, and i dont know how to prevent it.
If you need the script, i could send it.
#Bug and i really need help
1 messages · Page 1 of 1 (latest)
I recommend using BlockCasts, so you can choose a turn or a stairs up room instead of a hall, for example. I think this can work since you can check exactly what type of room fits in front of the current room, without collapsing with other one.
While I was writing this, I thought about creating a variable to let you know how much turns you've made by tracking the number of right and left turns relative to the start position, preventing the creation of a loop. I'll try to explain it better down below
Let's say our variable is, at the start, set to 0
When you add a right turn room, this increases in 1 and when you turn left, decreases in 1
By doing that, you can take control of what to choose, just like that:
local directionTracker = 0
function ChooseRandomRoom()
-- Some other code you have here, idk
local avaiableRooms = {
'Hall',
'Stairs Up',
'Turn Right',
'Turn Left'
}
-- Can't turn right
if directionTracker > 0 then
-- Removes 'Right'
turnRooms[3] = nil
-- Cant' turn left
elseif directionTracker < 0 then
-- Removes 'Left'
turnRooms[4] = nil
end
-- Select the room randomly here
Make sure your room models have a well set primary part you can position properly