Search Unity

Create a hallway between randomly generated rooms

Discussion in 'Scripting' started by wauchope, May 17, 2018.

  1. wauchope

    wauchope

    Joined:
    May 17, 2018
    Posts:
    1
    EDIT: This is probably in the wrong place. If a mod sees this would you be able to move the thread for me please or redirect me to the correct sub-forum.

    A little bit of context: I'm currently toying around with level generation for a game i want to make. I've managed to make it such that the rooms are randomly positioned and sized and none of them overlap as seen below.

    Example of a generated level

    What would be a good way of creating a path inbetween rooms. Perhaps with a variable average number of paths entering/leaving each room?

    Source Code:
    https://github.com/Wauchope/dungeon-crawler
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    The general scripting area is fine to discuss this, but there is also a brand-new "World Building" forum right next to us in the main directory.

    The problem you are working with touches on a lot of disciplines: graph theory, game design, spatial distribution, etc. You want to make connected rooms that are believable, not in any way disconnected and unreachable, and yet with enough hallways the entire level becomes open space, and you don't want that either.

    Fortunately there are a LOT of games that do this already, and their source is freely available for you to get ideas from, or sometimes just use outright. Rogue and Angband are two of the most popular grid-based roguelikes, but there are hundreds if not thousands of others out there, all employing varying ways of creating rooms. You might want to google up sourcecode for other roguelikes to get some ideas about how you can connect your rooms in a reliably complete way.
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983

    Some resources I find useful for this:

    https://gamedevelopment.tutsplus.co...ngeons-with-procedural-recipes--gamedev-14360

    https://github.com/DMeville/Unity3d-Dungeon-Generator

    https://catlikecoding.com/unity/tutorials/maze/

    https://naplandgames.com/blog/2016/11/18/unity-3d-tutorial-procedural-map-generation-beginner-level/

    http://www.nathanmwilliams.com/?p=472

    https://www.alanzucconi.com/2015/02/24/to-voronoi-and-beyond/

    and the most useful resource as it has all the info you need to generate hallways etc:

    http://www.nathanmwilliams.com/files/AnInvestigationIntoDungeonGeneration.pdf

    http://www.habrador.com/tutorials/math/13-voronoi/
     
    Kurt-Dekker likes this.
  4. jhocking

    jhocking

    Joined:
    Nov 21, 2009
    Posts:
    814
    MadeFromPolygons and Kurt-Dekker like this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    GREAT list of resources there both from @Daemonhahn and @jhocking ... thanks! If either of you spontaneously posted this list over in the World Building forum, I am sure there would be a warm reception there. If you like, I can post it there too, up to you.
     
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    You are more than welcome to :) I am glad it helped!
     
    Kurt-Dekker likes this.
  7. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    I posted in the thread that jhocking also did :)
     
    Kurt-Dekker likes this.