This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Generating a facility using room segments (SCP Containment Breach)

MirceaKitsuneMirceaKitsune Posts: 43Member

I was thinking of playing with some project ideas for Godot again. As most of what I wanna do is procedurally generated stuff, I was wondering how to best approach random corridors made out of segments. Are there any examples of such a thing, with a simple script that can be easily copied or expanded upon?

SCP Containment Breach is the best example for the functionality I'm thinking of: You have a seed which can be copied and reused. This seed determines how a group of predefined models (hallways, rooms, corridors) are spawned, in such a way that you get unique areas each time, the zones connected seamlessly with doors in between.

So I'd want to build a set of room segments of various shapes and sizes, keeping the following design points in mind:

  • Each segment must be defined as a scene. It won't be just a model but an object group, since I'll want to include lights and items with their own scripts and functionalities as well as baked bounce lighting.
  • Every segment will be designed to contain one or more holes. In front of each hole, another segment with a hole the same shape and size must be chosen and spawned, so that the two holes face against each other perfectly with a predefined spacing. Every segment must indicate the origin point and direction of each such hole, with a list of compatible segments that may against that hole. If a segment has multiple holes of the same shape and size in a valid spot, it may be positioned and rotated so that any of those holes may meet that of the parent segment. The list should allow counts or probabilities, so certain rooms can be more rare or frequent, while you can enforce a minimum or maximum amount for a segment.
  • When deciding which segment to pick and how to position it above, the code must be careful not to allow segments to poke into one another. For example: You may have an "I" shaped segment, to the side of which you could attach a "C" shaped segment via a compatible hole to form a "D"... however the other end of the "C" might be left in mid air or intersecting the "I", as there's no hole in the "I" designed for it nor enough room to continue the "C" segment without poking through the "I".
  • In the middle of all inter-segment holes, a door scene must next be placed to seamlessly cover the gap without leaving spaces through which the player could see into nothingness. Each segment hole type must define a compatible list of doors that can bridge it, as the door must precisely fit the exact shape and size of the two holes it's bridging.
  • Lastly the generated world must be compatible with pathfinding. If a room segment is configured to spawn a character while another room is configured to spawn an item, the character needs to be able to walk to that room however far it is. In practice I'll likely want to have characters randomly wandering around the maze, chasing the player only if they see or hear them nearby, losing track and ending the chase once the player can distance themselves enough.

Are there any examples or demos of something like this? As I'm still a near complete newbie to Godot this is probably a little ambitious, but with some examples and explaining of what they do I could ultimately figure it out. I can't make any promises... but if I can get this working efficiently, I may offer a demo myself with some nice areas using CC licensed assets, on top of which anyone could build games with an SCP type generated world.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.