Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

DunGen - Procedural Dungeon Generation

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

  1. modality2

    modality2

    Joined:
    Dec 7, 2017
    Posts:
    1
    I'm running 2.13 and having some trouble with the "Connection Chance" variable. I've created a symmetrical tile, but can't seem to generate looping paths. I've attached some screenshots, as you can see there are many opportunities for connection here.

    Here are some things I tried in order to get those sweet looping paths:

    - I have the connection chance turned up to 1. I tried with connection chance turned up to 1 globally and also overriding it with a setting of 1 in the prefab
    - The "Restrict to same section" setting is unchecked
    - I tried duplicating the tile and adding it to the tileset (thinking maybe you can't connect a tile to itself)
    - I've tried using both the Random Prefab setting and the Scene Object setting for the blocker
    - I also tried turning all the branches off and seeing if I could loop the main path to itself

    Anyway let me know if I'm missing something obvious. I think DunGen is an awesome tool, thanks for making it.

    EDIT: It appears that DungeonProxy->ConnectOverlappingDoorways is never called. I added some debug logging to that method to see where it was bailing out, but then discovered there's only one reference to ConnectOverlappingDoorways, and that's when it's declared. :eek:

    EDIT 2: I think I have a fix.

    Thanks for writing clean + well-organized code. This may not be exactly how you'd do it but it works for me.

    I added this IEnumerator to DungeonGenerator:

    Code (CSharp):
    1.     protected virtual IEnumerator ConnectOverlappingDoorways()
    2.     {
    3.       proxyDungeon.ConnectOverlappingDoorways(DungeonFlow.DoorwayConnectionChance, DungeonFlow, RandomStream);
    4.       yield break;
    5.     }

    Then call it as a coroutine before the post-processing step:

    Code (CSharp):
    1.             // Branch Paths Generation
    2.             GenerationStats.BeginTime(GenerationStatus.Branching);
    3.             yield return Wait(GenerateBranchPaths());
    4.  
    5.             // If there are any required tiles missing from the tile injection stage, the generation process should fail
    6.             foreach (var tileInjection in tilesPendingInjection)
    7.                 if (tileInjection.IsRequired)
    8.                 {
    9.                     yield return Wait(InnerGenerate(true));
    10.                     yield break;
    11.                 }
    12.  
    13.             // We may have missed some required injected tiles and have had to retry, if so, the status will be either Complete or Failed and we should exit here
    14.             if (Status == GenerationStatus.Complete || Status == GenerationStatus.Failed)
    15.                 yield break;
    16.  
    17.             yield return Wait(ConnectOverlappingDoorways());
    18.  
    19.             CurrentDungeon.FromProxy(proxyDungeon, this);
    20.  
    21.             // Post-Processing
    22.             yield return Wait(PostProcess());

    Dungeon with branches:
    Screen Shot 2020-06-10 at 9.01.30 AM.png

    Long dungeon with no branches. but still some chance for connection:
    Screen Shot 2020-06-10 at 9.07.03 AM.png
     
    Last edited: Jun 10, 2020
    Aegon-Games and camta005 like this.
  2. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499

    Wow, sorry about that - I'm not sure how I missed it.

    Looks like I broke it in 2.13.0 when I overhauled the dungeon generation to only spawn prefabs at the end. Previously, I was calling ConnectOverlappingDoorways in the post-processing step, but the prefabs have already been placed by then so I think where you put the fix is actually the best place for it now.

    Thanks for finding a solution to the problem; I've applied the fix to the latest beta version.
     
  3. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    298
    Do you remember what the solution to the " ArgumentException: An item with the same key has already been added." was? I am running into the same thing.
     
  4. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    134
  5. Razheem

    Razheem

    Joined:
    Sep 15, 2017
    Posts:
    4
    Hello everyone, i have a problem with Navmesh.

    Right now i'm fullbaking with dungen because of my AI (jumping through navlinks was awful xD).
    Everything is working fine, until i go in a previously locked room.
    The problem is that locked doors block the navmesh generation.

    I read that i have to add a navmesh obstacle component to locked doors in fullbake mod, wich i did, but it doesn't change anything.

    Thanks for reading, hoping you could help me with that because i hate navmesh problems and want to focus on everything else !
    PS : I'm quite noobie so please be clear and kind ;-)
     
  6. Vincent13122

    Vincent13122

    Joined:
    Oct 26, 2014
    Posts:
    83
    I am not sure but if the doors are included in the navmesh theyre probably set to navmesh static, turning that off should work I think.
    Alternatively when viewing the navmesh it might look like they obstacles blocking the generation but they aren't, if you turn off the navmesh obstacle you can see the navmesh part they blocked again.
     
  7. Razheem

    Razheem

    Joined:
    Sep 15, 2017
    Posts:
    4
    Hi again,

    Thanks Vincent for reply.
    I've checked and they are not navmesh static. Moreover, when i disable the object nothing happen to the navmesh.

    I think it's a baking problem because everything is fine with navlinks, and everything is fine when i don't add lokcked doors to my dungeon flow.

    Something is probably wrong when baking : it should bake before placing doors then block navmesh with navmesh obstacles, but it seems that baking is done after placing the locked doors.

    I want this feature for my game, i hope somebody will find out, i'm digging more with my few understandings of this !
     
  8. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    It shouldn't matter when the bake happens since nav mesh obstacles are excluded from the build. I did some testing with the built-in basic sample scene and found that just adding a nav mesh obstacle component worked for the auto-door, but not the locked door prefab.

    It looks like the nav mesh obstacle component only excludes the object it's attached to, not any of its child objects. Since the locked door prefab for that sample is made of multiple objects, I had to add a 'Nav Mesh Modifier' component to each of them and check the 'Ignore From Build' checkbox.
     
    Razheem likes this.
  9. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    263
    How can I make it so certain tiles will always be used?
     
    Last edited: Jun 26, 2020
  10. Razheem

    Razheem

    Joined:
    Sep 15, 2017
    Posts:
    4
    Adding navmeshmodifier with ignore from build worked like a charm ! I never heared about navmeshmodifiers before.

    Thank you for this 5* support =)
    Grégory
     
  11. Razheem

    Razheem

    Joined:
    Sep 15, 2017
    Posts:
    4
    Hi Katasteel, you have to select your dungeon flow then use "special tile injection" and tick "is required".
    This way the generation will try again if it fails to spawn the tile in your dungeon: so don't make it too restricted because this could make too much fails attempts.

    "Special tile" is the tile used this way but not required in the exemple dungen dungeon.

    I hope i answered your question, sorry for my english.
     
    Aegon-Games likes this.
  12. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    263
    Thanks!
     
    Razheem likes this.
  13. bmmshayan

    bmmshayan

    Joined:
    May 20, 2014
    Posts:
    21
    Hello,
    When changing .NET version 3.5 to 4 (in Unity 2018), the old seed does not work, the dungeons are changed to others.
    How to make dungeons the same in .NET 3.5 and .NET 4?
     
  14. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    It looks like System.Random in Unity produces different results across .NET versions when using the same seed for some reason. I tried the same test with a standard .NET console application and the results between versions were identical as you'd expect.

    I should just be able to write my own random number generator to give consistent results across .NET versions. I'll try that later today.
     
    hopeful likes this.
  15. YellowcakeLance

    YellowcakeLance

    Joined:
    Feb 9, 2015
    Posts:
    2
    Hi, really enjoying this asset a lot, compliments to the chef!

    So, I'm tinkering with it, is there a way to force the generate to place an amount of dead-end tiles?
    For example: a dungeon with exactly 6 special rooms with one door to go in/out.

    I checked out the global props and tile injections, but while the global prop isn't what I want (it's on an object, instead of a whole tile), the tile injection isn't allowing me to have tiles with one door that it may place.

    Ideally, I'd want to add them as a Node on the dungeon flow, but here again it needs to have at least 2 connecting doors. What's the ideal way to go about this, here?
     
  16. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    I was able to replace the random number generator with my own and it looks like it now produces identical results when switching between .NET 3.5 and 4.x in Unity.

    It's a breaking change so I can't include it in the current beta version, but if you send me an email with your invoice/order number I can send you the new version if you like.


    As long as you ensure DunGen doesn't try to place them in the middle of a path, one-doorway rooms should work with tile injection. I just tried it now and didn't have any trouble when using these settings:

    OneDoorwayCapSettings.png
     
  17. YellowcakeLance

    YellowcakeLance

    Joined:
    Feb 9, 2015
    Posts:
    2
    Thanks for the reply!

    Looking at the image, it would place those tiles at the end of a non-mainline branch, right? But what if I would like them to appear on any branch (including main line) but only at the end of dead-end hallways as a cap, regardless of when on this segment (even in the middle)? And while we can set caps to tilesets as a Instead Of/Addition To rules, I'd like them to only appear a number of times as a requirement (ex. 4 times, no more no less).

    If not through the front-end tools, can this be done through coding? Any pointers to this to get me started?
     
  18. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    The settings I showed would place the tile at the end of any branch, just not on the main path itself (rooms with only one doorway aren't valid on the main path except the start or goal node).

    You could actually change the 'Branch Depth' to 0-1 (instead of 1-1 as in the screenshot) if you wanted to and it would try to place the tile at any point along the branch. DunGen will still complete the generation process if a branch path is terminated early.
     
  19. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    263
    I upgraded from and older version on DunGen and now when the dungeon is created it no longer sets the tile game objects to active.
    Is there a setting to make it do that after it creates them?
     
  20. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    Since 2.13.0 DunGen doesn't deactivate tile GameObjects during the generation process any more so there shouldn't be any need to activate them. Are your prefabs themselves set as inactive?
     
  21. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    42
    Global props are listed in flow inspector. How do I find what prefabs are using a specific ID? Is there an easy way? If not could you improve the inspector so that the prefabs would be listed together with each ID?
     
  22. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    Unfortunately, there's no easy way to do that. I was thinking of changing the ID into a name field so at least there would be some indication of what type of object will be placed.

    I don't think I'll be able to easily show which prefabs use a specific ID since that would require checking every prefab in the project, but I'll look into it and see if I can find a decent solution.
     
  23. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    42
    Okay. Could the globalprop script add the prefab name to a list when it is added to a prefab and the inspector retrieve the names from that list later on? A list per ID which contains the prefab names. But I don't know is it possible to remove the name from the list if globalprop script is removed from a prefab. If not it would cause problems obviously. Just an idea.

    Name field would help a little I think.
     
  24. bmmshayan

    bmmshayan

    Joined:
    May 20, 2014
    Posts:
    21
    I am glad that you quickly react to problems. I have already written my own tool, which guarantees me the stability of dungeons on different platforms. I hope a fix with a random will be released in new versions. Thanks!
     
  25. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    263
    Request:

    I would love if DunGen's Tile had a repeat mode called "Count". And allowed us to enter in an integer.
    Then it would only use that Tile Type until it had reached the entered integer.

    It would be useful for when you want a tile to be able to repeat, but only so many times.
     
    camta005 likes this.
  26. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    I've added this to my to do list for the next version. I don't have a lot of time to work on DunGen right now so I'm not sure when that's going to be unfortunately.
     
    camta005 likes this.
  27. MarioRuiz

    MarioRuiz

    Joined:
    Nov 7, 2009
    Posts:
    161
    camta005, hopeful and katasteel like this.
  28. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    549
    Hello,

    I am interested in this asset. I was wondering if you could explain how the async generation functions though. Is it truly async, including the loading of the room assets, or is it more of a coroutine that runs X amount per frame?
     
  29. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    It's the latter. So far I haven't even needed to use the asynchronous generation though. The included basic demo generates in <50ms for me and the more complex dungeon crawler sample takes 200-300ms (including building a full navmesh; without that it's more like 150ms).

    I'll definitely look into improving the process if needed though.
     
  30. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    549
    I'm planning on using it in a VR game where any frame skips can be an issue. I'll just have to try it out and see how it goes I guess.
     
  31. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    DunGen doesn't do any work while the player is moving around the world, the generation all happens at the start so any frame skips shouldn't be noticeable. The asynchronous mode just prevents DunGen from blocking the game thread so the game doesn't freeze and you can show an animated loading screen while the player waits.
     
  32. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    42
    I tried that but then I got Bakery from Asset store and use that for lighting. It works really well.
     
  33. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    Version 2.13.2 (Beta 1) - Download
    Be sure to backup your project before updating to a beta version of DunGen.
    Updated 13 August 2020


    Bug Fixes
    • Fixed an error when trying to process child props that have been removed by a prop script
    • When doing a full dungeon bake using Unity's NavMesh system, the old navmesh is now correctly cleared first
     
  34. pedrogon

    pedrogon

    Joined:
    Jul 31, 2012
    Posts:
    1
    Hi Dungen'ers!

    I would like to know if someone had Dungeon Archetypes/Flows/TileSets for Unity Asset Store Environment sets like Manufactura K4 Top-Down Interiors, Top-Down Caves, Top-Down City, or Mana Station Eternal Temple, Multistory Dungeons, and so on...

    It would be great to have such a repository for that in order to test those packages with this awesome tool. Any suggestion would be appreciated.

    Thanks in advance!
     
    Feartheway likes this.
  35. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    87
    is there a list of assets that have dungen integration built in, like mulitstory dungeons has very good integration with dungen, are there many other assets that have this?
     
  36. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,315
    Hello, I'm interested in buying this for my next Unity store asset pack. I want to integrate this third party tool as Dungen ready scenes so I'm wondering if this works with HDRP and URP? I'm not a big fan of the SRPs but they the future of Unity moving forward I guess and I'll be implementing them in my packs from now on.
     
    Feartheway and camta005 like this.
  37. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Great I'm already using DunGen and am interested in buying anything that is compatible.
     
  38. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    87
    based on my limited experience with dungen and multistory dungeons. dungen takes the tiles and procedurally generates them. I think the tiles can be HDRP / URP. I will check and confirm this in a bit. HDRP instantly broke in my linux unity environment. URP aka LWRP seems to work ok. I imagine hdrp will work ok in a windows unity. That does break cross platform compatibility though.

    fyi this might be of use to you.
    https://forum.unity.com/threads/what-renderer-to-use-urp-vs-built-in-some-dots-discussion.743021/

     
    Last edited: Aug 20, 2020
  39. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    DunGen should work fine with any render pipeline. The only part of DunGen which directly interfaces with graphics is the built-in culling (which was recently changed to also work with the SRPs).
     
  40. PremonitionTV

    PremonitionTV

    Joined:
    Mar 28, 2020
    Posts:
    2
    Hi there! Firstly, this is an amazing asset, however using this asset alongside my ProBuilder workflow has not been smooth, the bounds of the rooms are not being set correctly. Here's an example of the rooms set bounds vs the bounds that are shown by the debugger in-game. From reading this thread, it seems ProBuilder was causing issues in the past for some users yet it was fixed, I'm assuming a change in ProBuilder in recent updates negated any fixes made in DunGen itself. Any help towards fixing this issue would be amazing, thanks again for creating such a useful asset!

    The room's set bounds: https://prnt.sc/u76qyn

    The rooms bounds at runtime shown via the debugger: https://prnt.sc/u76qny
     
  41. TabArtwork

    TabArtwork

    Joined:
    Jun 9, 2020
    Posts:
    5
    Hello. First off I just want to say that I'm loving this asset. It's amazing and worth every penny!

    I just had a quick question regarding culling.
    Is it possible to exclude certain items from culling?

    The reason why I ask is in my game, if you grab a gun in one room, it suddenly becomes invisible when I enter the next room. I'm not sure if I should be spawning items in to rooms in a different manner, but if there was some way to attach a script to items you didn't want culling to affect, that would be great because it seems like a really good way to optimize the game but I want items to be able to be carried by the player and also it's possible enemies may chase the player in to the next room and I'm assuming the same thing will happen.
     
  42. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    Looks like this isn't a ProBuilder issue. Doorways need to lie on the bounding box of the room, so DunGen is trying to shrink the bounds to match your doorways. From your image, it's moving the top boundary down to the middle of the room to meet the upwards-pointing doorway there.

    There are only 3 valid doorways in that room: top-right, bottom, and left - the others won't be used (or in this situation, they'll break the bounds of the room trying to make it work).

    I hope that makes sense


    I think the best thing to do would be to un-parent objects from the room they spawned in if they're able to move around the dungeon. As an example, once the dungeon generation is complete, this script finds all objects marked as global (using an empty component) and re-parents them to the dungeon root instead.

    NOTE: Script execution order will probably need to be changed to guarantee the script runs before the culling caches the renderers contained in each tile.
     
    TabArtwork likes this.
  43. PremonitionTV

    PremonitionTV

    Joined:
    Mar 28, 2020
    Posts:
    2
    This has not worked either, I changed the rooms geometry to line up with this guidance and it somehow made the issue worse? I do not know what is causing this because the doors are lined up with the boundary?

    Changed Geometry to line up with the boundary box: https://prnt.sc/u8kyys
    Edit: One of the doors was placed incorrectly in the image, it has since been fixed but the issue still persists.

    What happens when the room is placed in at runtime: https://prnt.sc/u8l0mz
     
    Last edited: Aug 30, 2020
  44. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    87
    how do i use stairs? to go up and down in a level? is it documented somewhere?
     
  45. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499

    Sorry for the extremely late reply, I didn't get an email about your new post. If you're not still having the issue, please just ignore this post.

    I've still only been able to reproduce the issue on my end with a door that's facing the wrong way. But assuming you flipped the top-left doorway in your first image, that shouldn't be happening.

    If you haven't already, could you try selecting your dungeon flow asset and click the 'Validate Dungeon' button at the top of the inspector. That will perform a series of checks for common issues in any of your rooms.

    If that doesn't work, is it possible for you to email me a simple example project demonstrating the issue?


    You can just add stairs directly to your rooms (or make a new room just containing stairs). Doorways placed at different heights will still connect properly and give you some height variation without any additional steps.
     
  46. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    263
    Dungen has been putting the Exit right next to the Start.
    This has happened a few times already.
    upload_2020-9-11_7-53-47.png

    upload_2020-9-11_8-1-27.png

    upload_2020-9-11_8-2-22.png

    It is even connecting them via a doorway.
    What can I do to stop this from happening?
     
    Last edited: Sep 11, 2020
  47. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    499
    The connection is probably due to having a 'Connection Chance' greater than zero. With this setting enabled, DunGen will connect doorways that overlap. I'll change this in a future version so start & end rooms can't be connected this way -it really doesn't seem like desired behaviour. Setting 'Connection Chance' to 0 should stop these connections from happening though.
     
  48. TabArtwork

    TabArtwork

    Joined:
    Jun 9, 2020
    Posts:
    5
    This was an excellent recommendation. Thank you so much! I already have an empty object that dropped items parent themselves to, so I was able to just have them parent themselves when they first wake up.
    Thanks again! I'm loving this asset and I left a 5 star review.
     
  49. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,579
    Always make it an option, there is case where I would want that, since leveling is the true progression, skipping ahead is a risk the player has to make, as exit lead to tougher dungeon.
     
  50. Felinsky

    Felinsky

    Joined:
    Jan 22, 2018
    Posts:
    22
    Hey is there any tutorial for dungeon generation on runtime ? I looked everywhere but didnt find any tutorial (even in documentation)
     
unityunity