Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

DunGen - Procedural Dungeon Generation

Discussion in 'Assets and Asset Store' started by Aegon-Games, Mar 7, 2014.

  1. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Thanks for bringing this to my attention, the issue should be fixed in the new beta build below. As for your question: unfortunately, it's not possible to specify a number of branches per-dungeon.


    Version 2.11.2 (Beta 2) - Now Available on the Asset Store
    Available on the Asset Store as of 24th July 2017
    Updated: 19th July 2017


    Changes
    • The "Basic Room Culling Camera" component can now optionally be provided with a TargetOverride transform for games in which the camera is positioned separately from the player object (e.g top-down games)
    • [New in Beta 2] The ArchetypeValidator will now report a warning when a TileSet contains an entry with an unassigned tile and will no longer throw an unhandled exception

    Bugfixes
    • Tiles will now correctly never appear in the dungeon layout when they have a tile weight of zero
     
    Last edited: Jul 26, 2017
    OG_Jacob likes this.
  2. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    Thanks for the quick answer !

    For the branches per-dungeon, do you think it's something you’ve planned to add someday ?
     
  3. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Unfortunately, that's not something I have planned right now; making it work properly would require re-writing a lot of the branching code.
     
  4. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    77
    Hi Aegon

    I test dungen by create a map from 2 tile sets but it overlap how i fix this and it can automatic change size of each room ?
     

    Attached Files:

  5. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    77
    and I got failed 20 times what am I setting wrong
     

    Attached Files:

  6. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    The doorways on your first screenshot are facing the wrong way. If that's how they're set up, that would definitely be a cause for overlapping rooms or a dungeon that fails to generate.

    Other than that, overlapping is usually caused by the bounds being calculated incorrectly. You can override the automatic bounds calculation by adding a Tile component to your tile and checking the "Override Automatic Tile Bounds" checkbox and manually setting the bounds.
     
  7. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    77
    I cant find "Override Automatic Tile Bounds" in Tile.cs as a below picture.
    when I correct the direction on each door it will fail when generate.
     

    Attached Files:

  8. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    That option was added in 2.10.1 back in January, that you don't have it means you're using 2.10 or lower. I'd recommend updating to the newest version since there are a lot of changes that eliminate the issue of dungeons failing to generate.
     
  9. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    77
    Hi
    Can I fix a tileset for last branch depth in each archetype or weight in each depth?
     
  10. Katori

    Katori

    Joined:
    Nov 30, 2009
    Posts:
    60
    I want to generate a hotel--in other words, a lot of hallway tiles that then branch off into single rooms with one door. What's the best way to set this up? I've been running into some trouble trying to do this with DunGen.
     
  11. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Do you want a realistic procedural hotel? Or an unrealistic hotel that proceeds from a starting room (like the lobby) to end room, with random variations in the middle?

    Because, to the best of my understanding, DunGen is not the right tool for the first job. There are other tools in the store for that. But the second version? That's what DunGen is for.
     
  12. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    Hi,

    I’ve a little problem with the dungeon’s generation when I inject more than 1 tile in the branch path.

    The generator creates the main path without problem, then he adds each tile from the « Injection List », and after instead of finishing each branch, he only finishes the last tile injected.

    In this example, I inject 3 yellow tiles (always as the 1rst Tile of a Branch) and the generator adds the rest of the branches (2 brown tiles) only on the last one.
     
  13. mzr

    mzr

    Joined:
    Jul 25, 2014
    Posts:
    35
    Hi.
    Could you please reupload the keepdemo.unitypackage, because the link doesn't work and I'd love to take a look at it.
    Awesome tool btw.
     
  14. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Sorry for being away from the forums for so long. I'm going to try to check back more regularly since I don't seem to be getting the e-mail notifications reliably.


    I'm not sure I understand the question. If you're asking if you can tell DunGen to use a specific tile at the end of a branch, this can be done in the Archetype settings:

    BranchCapTiles.png


    You could maybe have one TileSet and Archetype for only your hallway tiles for use along the main path, then use the "Branch Cap Tiles" settings in the archetype, using a separate TileSet for your hotel rooms so that they only appear on the ends of branches. That's probably the closest you could get to the desired layout with DunGen.

    Does this happen every time for you? From my testing, I've seen it correctly process the rest of the branch for all injected tiles (screenshot below with 2 injected tiles). I'll need to look into it some more to figure out where the problem is.

    White Rooms = Injected Tiles
    Red Line = Main Path
    Blue Lines = Branch Paths
    Result.png


    Sorry about that, I guess I cleared out my dropbox folder at some point. I've re-uploaded it here and updated the original post with the new link.
     
    mzr likes this.
  15. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    I’ve found that if I leave the « Path Depth » of tiles injected only on the branches from 0 to 1 (even if the tile doesn’t appear on the main path) the generation completes more branches but still not all.






    Sometimes (very rarely) every branch is « completed » but not correctly. In this example one yellow tile (start of a branch) has only one brown tile (« Branching Depth » set to 3) and even if the branch is « finished », its doesn’t replace the tile by a Cap (« Branch Cap Type » = Instead Of).

     
    Last edited: Jun 28, 2017
  16. mzr

    mzr

    Joined:
    Jul 25, 2014
    Posts:
    35
    Great!
    Thanks.
     
  17. Drunken-Monkey

    Drunken-Monkey

    Joined:
    Dec 15, 2011
    Posts:
    95
    I'm running into an issue with the blockers facing the wrong direction. These are simple deadends prefabs added to the Blockers -> Random Prefabs in the Doorway Component.



    Edit - Ok, I have this figured out. I just needed to construct my prefabs differently.
     
    Last edited: Jul 3, 2017
  18. mzr

    mzr

    Joined:
    Jul 25, 2014
    Posts:
    35
    Two quick questions:
    1.Is there any easy way to add background? I'm making a top down game and I'd like to add something between the corridors.
    2. I'm using the runtime navmesh navigation and your keep demo and I can't get the room link to work, there are holes in navmesh in the doorways.
     
  19. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    Is it possible to build dungeons upwards? tile prefabs on top one another, i want to create multi level in a tower

    EDIT: how to view placement bounds?

    i gotten this error:

     
    Last edited: Jul 14, 2017
  20. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Sorry, I still haven't been able to find any issues with the tile injection logic yet. Also bear in mind that branch paths aren't considered "critical" by DunGen, so there's no way to guarantee that you'll get exactly the branch length that you want or that the correct branch cap tiles will be used. If for whatever reason DunGen can't place a branch tile properly, it'll give up after a set number of attempts; in contrast, for main path tiles, DunGen will scrap the entire dungeon and start over if necessary.


    1. For background objects, you could either place them in the tiles themselves (although you'd need to manually set up tile bounds to avoid background objects being considered) or just have the dungeon load in to an existing scene with a background environment already set up.

    2. The room link option should place NavMeshLink objects in the world so that even if there's a break in the NavMesh between rooms, they can still be traversed. I think there's a setting to enable auto-traversing links inside the nav mesh agent.


    You can build dungeons upwards by rotating doorways to face up/down and setting their socket group to "Vertical" (this stops dungeon from flipping tiles when connected to this doorway). For an example of this, see the "Upstairs" and "Downstairs" tile prefabs in "DunGen/Demo/Tiles/Crypt".

    You can see the placement bounds in the scene view (or game view if the Gizmos toggle is on) by selecting the dungeon root object in the hierarchy. They should appear as red bounding boxes; however if DunGen is generating tile triggers (on by default), they'll directly overlap the bounding box so they'll appear light-green.

    I'm not sure what could be causing that error, does it happen all the time?
     
  21. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    when i 1st build my level design map, there wasnt any errors. However when i start building my 2nd map, this error for archtype kept popping up, & now my 1st level wont work as well.
    Version: Unity5.6.2p2 + dungen 2.11.2b1

    Im still unable to view the bounds. When i try to generate the level in editor i now got this error too
    i went back to 2.11.1, all the errors encountered has gone.

    i got another question.. is it possible to have a prefab only appear in the center?
    so the prefab is a spiral stairs, & then have dungen build around the spiral stairs prefab?
    The spiral stairs is a special tile?
     
    Last edited: Jul 19, 2017
  22. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Check all of your TileSets; it sounds like you might have an entry in the list that doesn't have a tile prefab assigned to it. The new beta build will log a warning to the console about this to make it an easier issue to spot.

    Regarding building the dungeon around a central prefab: unfortunately, I can't think of a way to do something like that with DunGen.
     
  23. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    thats a pity, cuz i really hope theres some ways to do that..
     
  24. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    @AegonGames
    Can i make a request for the special tile to act like a central prefab?
     
  25. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    Just wondering, did you try to place that prefab as a node in the center of your flow. Making sure you also add a good amount of branches possible ?

    You can consider the start as an end point, and branches have an option to have a tileset for their last tile too.
     
  26. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    upload_2017-7-26_15-39-3.png

    I specified a special entrance and exit door.

    The exit door is used to move from this room to the next room.

    But the entrance door is not used to enter this room. I thought this would override the door used from the previous room?

    I'm currently on 2.11.1 and will upgrade to 2.11.2 soon but is this fixed?
     
  27. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    In your demo, One Way Room does not really work. If you actually assign different door prefabs you
    will see want I mean.
     
  28. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    I use exit / entrance door and they work for me. Can you show a screen of your room and show what is your exit/entrance?
     
  29. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    I don't know if it matters but my special doors are on the mini-boss rooms. I want these rooms to be enter only on one side and exit only on the other side. I created two special doors with triggers on only one side of the door. The rooms on the path up to and on the other side of the mini-boss rooms normal two-way doors.

    upload_2017-7-27_7-27-39.png

    upload_2017-7-27_7-30-23.png
    upload_2017-7-27_7-29-16.png upload_2017-7-27_7-33-25.png

    upload_2017-7-27_7-36-8.png


    The exit door has the same configuration but uses the GrandwayAutoDoorExitOnly prefab.

    When generated the entry door is not the GrandwayAutoDoorEntryOnly but a standard GrandwayAutoDoor (which has trigger to allow enter and exit of the door).
     
  30. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    BTW: Is there a way to generate a dungeon and then continue from the last room and generate another dungeon to extend the first part. Basically, think of it as the above flow but generating each part only when needed.
     
  31. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    On an Archetype segments I need to be able to have special rooms that only appear once. Right now special rooms are only added globally to the whole flow. Anyway to accomplish this through code or configuration settings?
     
  32. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    In GetPotentialDoorwayPairsForNonFirstTile, the test for compatible doors is:

    bool requiresSpecificEntrance = nextTile.Tile != null && nextTile.Tile.Entrance != null;

    // If the next tile must use a specific entrance and this door isn't it, skip it
    if (requiresSpecificEntrance && nextTile.Tile.Entrance != nextDoor)
    continue;

    But of course the previous title does not have door type of entrance but the entrance door of the next tile is compatible by socket type to the nextDoor. I think this test is wrong. Should it not be using socket type here?
     
  33. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    Sorry, wrong about the above. This issue is with priority:

    // If both doorways have door prefabs..
    if (a.DoorPrefabs.Count > 0 && b.DoorPrefabs.Count > 0)
    {
    // ..A is selected if its priority is greater than or equal to B..
    if (a.DoorPrefabPriority >= b.DoorPrefabPriority)
    chosenDoor = a;
    // .. otherwise, B is chosen..
    else
    chosenDoor = b;
    }
    // ..if only one doorway has a prefab, use that one
    else
    chosenDoor = (a.DoorPrefabs.Count > 0) ? a : b;

    It does not take into account B is a required entrance doorway. It always uses A. I need to have DoorPrefabPriorty higher for B.

    So, I get it, I changed the priority of the entrance and exit doorways and it works as expected now.
     
    hopeful likes this.
  34. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    So now I just need to figure out the special rooms on each archetype segment that need to be there on each segment only on a branch and required once.
     
  35. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    Question about branching paths. Can they cross over the mini-boss rooms allow a player to skip a mini-boss?
     
  36. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    Anyway to have multiple connected Dungeon Flows? Basically, need a way to generate a starting dungeon, get to the boss room and extend the dungeon by another Dungeon specifying an unused door of the boss room?

    I know how to generate multiple dungeons, but I need to connect them with the correct orientation to the other dungeon at the goal rooms so the exit dungeon door of level 1 connects to entrance dungeon door of level 2.
     
  37. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    The only way possible is to include a "fake" branching in your mini boss room, there is no way for Dungen to generate an automatic alternative path

    Dungen doesn't have that by default, you could potentially generate the new dungeon yourself and try to position it but you will have no guaranty that the new dungeon doesn't cross the old one (there is no check during the generation for an eventual existing dungeon)
    Your safest bet is to compromise and simply make a door when the player click you load the new dungeon.
     
    Aegon-Games likes this.
  38. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    The way DunGen is designed is so players can't skip past bosses and keys for doors. As @Elzean said, if you want the player to be able to skip a boss, you have to make a boss room that has within it a way to bypass the boss (like, IDK, an overhead ventilation duct).
     
    Aegon-Games likes this.
  39. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    No not looking for them to be able to pass boss rooms. Just make sure this can not happen. It would be a bad thing.

    But that still leaves me with the issue that each segment of the dungeon does not have the capability to have special room requirements. Only the entire dungeon flow has special rooms. Without this, I then need to generate each segment as a separate dungeon flow to get the special room requirements satisfied and then find a way to join them up as one dungeon layout.
     
  40. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    this is page 27 of the doc:
    upload_2017-7-29_0-55-23.png


    There is more info there i think you should check that out if i understand correctly what you want to do.
     
    hopeful likes this.
  41. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Adding to what's already been said: the only way branches can possible re-merge with the main path is if "Connection Chance" is greater than 0 in the Dungeon Flow settings. As long as that is zero, there's no way your mini-boss rooms can be bypassed.


    I tried adding that as an experimental feature but I've since removed it. The new dungeon segment could collide with previously created dungeons and overall it was slow and messy; DunGen just wasn't designed to work like that.

    You could use the "Special Tile Injection" system as mentioned and use the min/max path depth options to manually ensure that the tile will be spawned on the right section of dungeon. Alternatively, the tile injection system can be used through code (also briefly described in the readme) if that's easier.
     
    Dwight_Everhart likes this.
  42. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    I dont know anyone have this problem.
    on my room prefab i checked override automatic tile Bounds & the error "Failed to generate the dungeon 20 times." popped up. However upon unchecking it, no fails
     
  43. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    What did you override it with, do you have a screens of the value you used and your room ?
     
  44. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    error.PNG
     
  45. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    Thanks for the "Connection Chance" information.

    What I'll do is enhance the generator to allow multiple Dungeon Flows. What I'll do is generate each flow in turn connecting the previous flow to the next flow along the main path. So each segment of the dungeon is one flow. Really, it's just another loop generating mini-dungeons connected together without resetting the past runtime dungeon state information. Think of each flow having an Exit Door (on the goal tile) and the next one having an Entrance Door (on the start tile) which allows the main path to continue.
     
  46. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    The problem is not generating the new dungeon at some position, it's to avoid the new dungeon to overlap previous one.

    Unless you have a very simple setup where most room have only 1 entrance/exit and the dungeon is mostly straight then fine, you probably don;t have to care. Otherwise you will have to add a test for previous existing room during the generation.

    If you make this part work though, then nothing would stop you from generating a new dungeon from anywhere, like the end of a branch or any room that has a door available.

    There is good chance that many generation will fail in case of complex room setup. I had previous dungeons where the End room would sometimes be very near the starting one, like the entire dungeon would kind of loop back toward the starting position.
     
  47. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    possible to get dungen to build an elevator shaft? thats the same for building vertical doorways right?
     
  48. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    You can link room vertically yes, it's up to you to make the elevator itself though or could be a ladder etc :)
     
    Aegon-Games likes this.
  49. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    @RobertMassart Been thinking a bit more, and i really think it's not worth spending your time on this. You cant avoid some sort of loading time when the next dungeon generate, load the assets, instantiate them, and awake whatever needs to.

    So you may just as well simply have a loading screen when switching dungeon and spend your time to make a cool loading screen if you wish. Could be that the player open a door and you hide the loading in a open/close door animation like in Zelda, or simply pass a portal and you have some "stargate" kind of effect during loading. No player will complain about that and you will not work on a feature that is mostly useless/unimportant and likely to not work perfectly.

    It will also let you be completely free in your dungeon designs.
     
  50. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    Hi, my start tile has 6 doorways, how do I make dungen to use all 6 doorways?