Search Unity

Procedural Room Generation

Discussion in 'Scripting' started by samloeschen, Oct 18, 2012.

  1. samloeschen

    samloeschen

    Joined:
    Mar 22, 2010
    Posts:
    268
    Hey everybody. So for a little side project I've decided to start working on a sidescroller similar to castle crashers (you can move closer to/farther from the camera in addition to left and right), but I would like to add randomly generated levels and shooting. Currently, I'm trying to figure out how to populate each room with different objects/structures that will act as cover for the player to hide behind. Different objects will be different sizes, and not all of them will be rectangles (some will be "L" shapes, and so on) Each room's floor space is a grid of tiles which is split into chunks, to make populating the room an easier task...I'm not sure if I could write something that would generate nice cover across the room consistently. Here's a screenshot of the room with the chunks:



    So, what I'm trying to do is go through the list of chunks, decide whether or not that chunk should be empty (no cover, just floor), and if not, populate them with the different sized objects until a number of tiles in the room have been covered. Afterwards, I'll probably just try to find a path to the exit and delete objects that prevent the room from being beatable.

    What I'm struggling with is how to actually go about figuring which objects will fit and how to place them correctly...
    Thanks in advance!
     
    Last edited: Oct 18, 2012