I’m working on a project where there’s a map of ‘tiles’ and rooms are procedurally generated by selecting a random tile in the folder (starting wall), then raycasting in either in +x, -x, +z, or -z directions. If the wall the ray hits is too far from a given ‘MaxDistance’ variable we reset back to the randomly selected ‘StartingWall’ and when we find a wall we put it inside the table of ‘RoomWalls’ after first making sure the wall isn’t already in the table to not have repeats walls. I also delete one room at a time and make sure they aren’t overlapping by restarting the process completely if the raycast hits ‘nothing’ because that would have to mean it hit an already carved out room or the edge of the map. So here’s an image showing what I’ve got going on so far:
So as you can see we have 7 procedurally made rooms that do not overlap and have somewhat random ‘sizes’ the size variable is the given number of walls I want the room to carve out.
Now I want to make little 1 thick paths that connect the rooms. One idea I had was to store the walls in the rooms positions with the highest and lowest x and z positions so I would know where the ‘edges’ of the rooms are and the connecting the closest edges to each other or something along those lines. I’m kind of all ears here and looking for possibly all around better solutions. I don’t want the paths cutting through rooms that are between and it would be nice to add some element of randomness, but maybe I should just start in the middle and create a web? Any ideas/solutions here much appreciated.