So if anyone follows the updates on the Site: 012 incident, I’m currently trying to pan out an idea of having a randomly generated map.
The idea I currently have is that there is a block labeled “Generator” that will move in a snake-like direction, spawning room segments in a grid. Since my artstyle makes for taller rooms, each grid segment is actually 6x10. When a segment is spawned, it places a Located object in the center of the segment so when the Generator moves around, it’s supposed to detect the Locator’s with raycasting and move the path away from it.
Currently it works well starting out, but It’s currently having trouble detecting other rooms and will sometimes start looping into itself. Another issue I found is that it’s spawning two segments every second instead of just 1, which might be a minor error on my end, somethings looping twice that shouldn’t.
So I guess I’m posting this asking if anyway has a similar example or can provide help on allowing the hallways to generate.
Each segment contains 60 spawns and produces a 6x10 room, which all link together nicely, its actually getting the raycasts to detect and move the Generator away from already placed Locaters.
I would post a link, but the game is supposed to be in secret and I think I made the game private back when I had indie so I’m not for sure if people other than me can access it, but I can try sending the link via Private Message and see if it works.
Basically I’m just asking if anyone has attempting a random generated map with this type of design before. Once I can get the hallway segments spawning correctly, I should be able to add T roads, 4 ways, and small rooms as well without much issue, but I want to see if it’s possible first before I make everything else.
I was looking into different discussions to hopefully find some sort of answer, but then I found a GIF of Pixel Pizza’s work in progress game.
This is basically what I’m looking for, but I’m doing it with full 60 object rooms instead of just one object so I’m not sure if this would work well for me, but this is a great example of what I’m looking for. I tried attempting this and it didn’t work too well.
If you’re spawning in 60 objects per room then it would be best to imagine you’re spawning in only one. What that means is that calculate the proper distance the room needs to be, then spawn in that single object, and that single object will spawn in the other 60.
Each room is 6x10 grid, or 192x320 pixels. So I just have the Generator block move either 192 left or right or 320 up or down depending on the direction it’s facing based on the last segment placed.
It starts by going right when it places a horizontal hallway segment. Then theres a 1/3 chance it will spawn either another horizontal piece, a top right piece, or bottom right piece. A top right piece will change the direction down so it will have a 1/3 chances of spawning a segment with a hallway connecting on the top of the segment to connect with the piece and it continues like this. I added raycasts to turn switches off on different pieces if the generator block find’s itself in different situations such as getting close to a located which is spawned inside each segment. When a switch is turned off, the generator keeps trying the random until it places a segment that is able to play then it continues placing more, but for some reason it won’t pick up the raycasts.
One issue I realized is that it doesn’t account for corners. It only detects when a locater is either left, right, up, or down from the generator. If I raycasts to detect different locaters from the corner, then I can prevent walls from being spawned alongside themselves and hopefully move the generator away from them.
This should work now that I think about it, but that means I’ll have to redo a ton of and gates and switches.
Now that I reread this, I realized what you meant. I could have it spawn a special block (Such as a locator that uses raycasts to detect nearby locators and spawn in the room to connect to those. The only issue is when I have hallways alongside of each other, which I still have to fix with a ton of raycasting on the generator’s part.
I don’t want it to be infinite, but a decent size that allows for T and possible 4 ways that can branch off into different sections.
There are going to be prebuilt rooms that have important items (an office with a keycard for example).
The only downside of having a room is that it needs to be two grid spaces so it can have a hallway segment with a door, and the room connected to it. The hallways don’t normally have doors on their own, unless connected to a room and it needs to know that, but I can think up of something for that later.