Search Unity

DunGen - Procedural Dungeon Generation

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

  1. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Well ... there's usually ways to work around the various limitations. You could have, maybe, scenes for each room that you load additively and asynchronously, and use the prefab rooms you feed to DunGen as proxies, where you have each scene set at 0,0,0 and you move it to the location of you proxy room.

    You'd have to use light probes in those scenes as well, to get your random objects looking right. Maybe this Unity tutorial asset would help you in that regard: https://assetstore.unity.com/packages/templates/tutorials/additive-loading-lighting-examples-129922

    I suspect your original approach is probably the correct one, though, and you may be overlooking some significant efficiencies somewhere. Or, you may simply be attempting more than you can really get done on a tablet.
     
  2. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    134
    I didn't realize before, but there were still some lights on in my scene. Once I turned them off and also disabled a custom image effect, the fps is now around 50 with no lights. But with realtime lights, it goes down to 13.

    I looked at that asset you linked before, but I don't know how to set rooms to load additively and work with DunGen. Maybe it's a feature that can be added to DunGen where you can put scenes as tiles instead of prefabs?
     
  3. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    No, you'd set up your rooms normally with DunGen, but have a trigger collider or something like that in each room, and a collider on your camera too, so that when the camera gets near and hits the room collider, the appropriate scene gets loaded and moved to that location.

    It would be something entirely in your hands, that you would do. But not necessarily super difficult. You'd have to have a unique scene for each type of room, though, and bake it.

    Lights and shadows can eat up a ton of fps, especially on mobile. You should seriously consider using primarily an ambient light, occasional added lights that only turn on when needed, and lighting with shadows only when absolutely needed. Also, whenever possible, use spotlights instead of point lights.

    Since you know your target platform, it seems reasonable to do some tests to see what you can get away with.
     
    Last edited: Mar 6, 2020
  4. CF-Games

    CF-Games

    Joined:
    Jun 2, 2013
    Posts:
    134
    I tried the additive scene approach and the light baking works, but the same scene can only be loaded once. So if I have a separate scene for each room, if the player is already in a room that is the same room as the next room, that scene can't be loaded again because it already exists.

    I also tried just replacing all the rooms with the appropriate additive scenes as a post process step to DunGen, but that also didn't work because each unique scene can only be loaded once.

    Am I suppose to create several copies of each room scene and load/unload each one as needed? I also couldn't figure out how to access the additive scene room to move it. There's a scene.GetRootGameObjects function, but is there a way to just get the room gameobject?
     
    Last edited: Mar 6, 2020
  5. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    You are right. This doesn't seem to work in modern versions of Unity. I've avoided using lightmaps for a long time, because they were always so limited and buggy ... but yeah, this basic sort of feature is no longer built-in to Unity.

    I'll have to refer you to this:
    https://unity3d.com/how-to/light-baked-prefabs-on-mobile

    Store assets like this might work for you:
    https://assetstore.unity.com/packages/tools/utilities/duplicate-with-lightmap-46812
     
    Last edited: Mar 6, 2020
    christougher likes this.
  6. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    65
    I'm looking at Dungeon crawler example scene and it says in the readme file that "Finally, the Dungeon Crawler Nav Mesh Adapter component generates a dungeon-wide navigation mesh when the generation is complete.Normally, we’d use DunGen’s built-in integration for the Unity NavMesh components, but in order to avoid requiring any dependencies for the sample, we build the nav mesh manually."

    I setup a simple tile with just one cube and two doorways.

    upload_2020-3-15_13-58-25.png

    I set the navigation options for the cube like this:

    upload_2020-3-15_13-59-17.png

    When the dungeon is generated it seems that navmesh is not generated.

    upload_2020-3-15_14-9-50.png

    I read the Dungen documentation but there's no mention how to setup DunGen’s built-in integration to use with the Unity NavMesh. I opened the Dungeon crawler example scene and when I play it I can see that navmesh is generated but that example does not use DunGen’s built-in integration with the Unity NavMesh.

    So I suppose I'm missing some steps to do it correctly with DunGen’s built-in integration? It would be nice if step by step instructions would be in the Dungen and Dungeon crawler example documentation.
     
  7. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The "Pathfinding" section of the readme PDF (pages 32 & 33) explains how to use the NavMesh integration.
     
  8. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    65
    My bad! Didn't notice that. Thanks!
     
  9. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Is this working right with Sectr now? A while back I inquired and it seemed to be broken. I already own this ... just deciding on if I want to use it, and if its as simple as it used to be (just enable sectr basically) to have room culling based on LOS then I might just go down that route ...

    [Edit -- HDRP 2019.3]
     
    Last edited: Mar 26, 2020
  10. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    49
    Well was looking at this, but going on a month with no reply, last update in 2019, I assume it is getting to end of life?

     
  11. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    I don't think so. This plugin has been out for a long time, and it doesn't always need updates with each Unity version.

    Unity changes things related to shaders a lot. Things related to what DunGen does ... very infrequently.
     
    Vincent454 likes this.
  12. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    I agree this asset is so good and I doubt that even if support ever ends it could stop working one day.
     
  13. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    49
    Thanks for the input.
    It really got my attention for a project I was planning, but having been burnt several times with assets was being careful.
     
  14. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sorry, I didn't get a notification for the new posts.

    I'm still developing DunGen, but it turned 6 years old in March so updates have slowed down a bit. There's currently a beta version that I'm planning on releasing in the next week or two (honestly, it should have been released sooner). I have some stuff planned for future updates as well - the next version will likely focus on usability and debugging.

    Regarding SECTR, I finally got around to buying the new version and can confirm that it does still work. Previously, I only had the old SECTR VIS (before the 2019 version). DunGen's integration works with both versions.
     
    hopeful likes this.
  15. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    65
    Feature suggestion: could the Tilesets be created and managed directly from Archetype inspector? This would improve workflow.
     
  16. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    TileSet and archetype management is definitely an area I want to improve. Your suggestion would certainly help towards that goal. For setups where you only need one tileset per archetype it doesn't feel like there's much point in having two separate assets, so being able to modify one from the other would definitely help to make that feel better.

    Another thing I'm looking to do is maybe provide an option to allow TileSets to manage themselves implicitly by looking for tiles in a specified folder. That way - after making a tile - you wouldn't need to add it to the tile set manually, just place it in the right folder.
     
    jensen_305 and GreaserMonkey like this.
  17. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    49
    Well I picked it up, now I have to play around and learn it :).
    It should help speedup my new project.
     
  18. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    49
    Can anyone point me to a video tutorial for getting started? I cannot seem to find one.
    Thank you.
     
  19. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    At this point is version 2.13.0 (Beta 4) considered stable?
     
  20. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    There's no official video tutorial I'm afraid.


    I haven't ran into any problems with it and there have been no bugs reported, so I think it's safe to consider it stable. I'll be pushing this version to the asset store soon - probably after the sale is over. Of course, if you run into any issues, let me know and I'll get them fixed as soon as possible.
     
    camta005 likes this.
  21. saltysquid

    saltysquid

    Joined:
    May 1, 2017
    Posts:
    41
    Quick question regarding the dungeon layout. Is there an easy way to A) force a room to have all doorways always attach (think about a hallway that you don't want to dead end) and B) Limit the # of a certain room? For instance I have a room that's fairly ornate and I'd like 2-3 at most, but at least 1.

    Can this be easily accomplished somehow?

    By the way, I purchased Dungen 3 years ago! I can't believe I keep finding uses :) Nice work.
     
  22. saltysquid

    saltysquid

    Joined:
    May 1, 2017
    Posts:
    41
    Did you check out the readme.pdf it comes with? Not exactly a video, but it's real clear and step-by-step.
     
    Vincent454 likes this.
  23. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    There isn't really a way to force all doorways to be used, but if you use a 2-doorway tile on the main path (but not on the start or goal node) it will have to use both doorways. Something similar can be done for branches by specifying some tiles that you'd like to use for dead-ends as 'Branch Cap Tiles' in the archetype asset (with the type set to 'Instead Of'); DunGen will try to always use those as the end tile of a branch. Though if it can't place the branch cap tile, it will abort and leave that branch without a cap - so it's not guaranteed.


    For limiting the number of times a certain room can show up, you have two options:

    If you want no more than one copy of a room: just add a Tile component to your room and change 'Repeat Mode' to 'Disallow'. This method can't be used to force a minimum number of rooms to spawn.

    The second option is more flexible but a lot more work to set up so you probably wouldn't want to use it for too many tiles. You can remove the special tile from your tilesets and instead use the tile injection system to place it in the dungeon. If you want between 1-3 of these tiles across the entire layout, you'd need to add three entries to the tile injection list and mark one of them as required. This can also be done through code to avoid cluttering the injected tile list. Both tile injection methods are described on pages 29 & 30 of the readme. Here's an example of what the code might look like.
     
  24. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    49
    Yes, looked over it several times before posting, if that is all I can go by, I will have to use it, or just count this as a loss and move on.

     
  25. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    It's not that difficult. Look at the demos, change the values in the inspector for the dungeon, and you'll see how it works.

    You can also use your own scripts for adding features. Like, to keep memory costs down you might want to have each room made up of game objects that spawn meshes from a pool only when the camera is around. (Otherwise, all that's present are colliders.)
     
    camta005 and Vincent454 like this.
  26. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    200
    I have a quick question as today is the last day of the sale i need to know if i want to get this.

    Is it possible to mix randomly generated rooms along with my own hand crafted rooms. Like 2 floors are randomly generated then the 3rd floor is hand crafted myself with no help from dungen?
     
  27. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Yes it is, just dont use dungen for the third floor. If you want to have all 3 floors in the game at once you can simply make the third floor its own room basically. But if you dont then just dont call the dungen generator for floor 3 and spawn in your custom one.
     
  28. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    200
    Ok. Thanks. Can I have a hand crafted room in middle of a dungen room too. Like when a key opens a door to a room, can the room be hand crafted?
     
  29. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Just to avoid confusion: there are no procedurally generated rooms in DunGen. It makes a procedural dungeon, but only from hand-crafted rooms (or other level chunks) stitched together following a set of rules you define.
     
  30. saltysquid

    saltysquid

    Joined:
    May 1, 2017
    Posts:
    41
    Sounds great, thanks for the reply! I'll check this out!
     
  31. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Hello Aegon games :) I have a question regarding the Nav Mesh adapter.

    In the documentation it says that using the Unity Nav Mesh adapter is fine, however with that component you can't select layers, meaning navmeshes are generated for all the meshes, even ceilings.

    I tried the dungeon crawler nav mesh adapter which has the layer mask options, and it works great, however it does not have all the options the unity nav mesh adapter has.

    Which one to use ?


    Thanks !
     
  32. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    In the new version (2.13) which just hit the asset store yesterday, it's possible to provide your own NavMeshSurface to bake by setting the bake mode to 'Full Dungeon Bake' and unchecking 'Auto-Generate Surfaces'. Make a surface and add it to the list and you can use any of the settings available on the surface.
     
    camta005 likes this.
  33. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    That's really cool to hear, I will try this out, thank you for the fast answer :)
     
  34. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    64
    Jumping into scenes (just regular scene load without additive) and coming back to a scene that has a generator the memory always grows. Going to my main menu and to a dungen scene 4 times and im already in 10GB ram.
    Any ideas?
     
  35. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Where are you reading the memory usage from? I tried with the dungeon crawler sample project and checked the memory in task manager and didn't notice any problems.

    From this article, it sounds like Unity keeps unused assets from the previous scene in memory:
    But that wouldn't account for the memory usage increasing after every scene load.
     
  36. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    64
    I can see it in task manager. Once CPU starts to boost (dungen is generating) then memory starts to ramp up.
    Ill try what you described.
     
  37. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Hello Aegon Games !

    So Yesterday I updated my project using the last version of dungen ( previous version was already installed )

    And then I have this message error : "
    Assets\downloadedAssets\DunGen\Integration\Unity NavMesh\UnityNavMeshAdapter.cs(167,79): error CS1061: 'Doorway' does not contain a definition for 'UsedDoorPrefab' and no accessible extension method 'UsedDoorPrefab' accepting a first argument of type 'Doorway' could be found (are you missing a using directive or an assembly reference?)"

    I assumed it's trying to fetch the prefab Doorway but can't find it anywhere ?

    Thanks
     
  38. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    When you upgrade DunGen, you'll need to extract the integration packages again. Most of the time it won't be necessary, but I renamed something in 2.13 and the old integration now can't find it. If you delete the old "DunGen/Integration/Unity NavMesh" folder and re-import "DunGen/Integration/Unity NavMesh.unitypackage" it should work.

    I'm looking into making that automatic in future.
     
  39. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Oh I see, I think part of the issues was I moved the dungen folder into 3rd parties dedicated softwares folders.
    I moved it back and made the update, and it worked perfectly, thanks.

    Also, I see the script 'Dungeon Crawler nav mesh adapter' is no longer available, do you think it will be possible to get it back ?

    Thank you again :)
     
  40. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I didn't touch the dungeon crawler NavMesh adapter in the new version, it should still be where it always was (Dungeon Crawler Sample/Scripts/World/DungeonCrawlerNavMeshAdapter.cs).
     
  41. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Thank you, I actually had to re open the sample scene to reimport all the necessary elements. Thanks
     
  42. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Version 2.13.1 - Released
    Be sure to backup your project before updating to a beta version of DunGen.
    Available on the Asset Store as of 01 July 2020



    Enhancements
    • The 'Adjacent Room Culling' component (non-multi-camera version) now also has a 'Target Override' property to match its multi-camera counterpart, allowing it to be used in games where you want to cull around the character instead of the camera (e.g. third-person or 2D)

    Bug Fixes
    • Removed deprecated components from sample scenes to avoid warnings in Unity 2020.1
    • The 'Adjacent Room Culling (Multi-Camera)' component should now work properly when using scriptable render pipelines, as long as the project is Unity 2019.1 or higher
    • Fixed an issue in the Dungeon Crawler Sample that caused the NavMesh to persist between scenes
    • [New in Beta 2] Fixed an issue with SECTR portal culling integration that caused rooms to not be culled initially when 'Multi Camera Culling' was turned off
    • [New in Beta 3] Fixed an issue causing 'Doorway Connection Chance' to do nothing
     
    Last edited: Jul 1, 2020
    hopeful and Vincent454 like this.
  43. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Hey, I am having an issue with the Sector Vis plugin that at the start nothing is culled until after the camera has been within it's bounds, then when leaving it culls normally, but initially nothing is culled. I tried the different settings, but didn't seem to change anything. Any idea what might be causing this? When normally operating sector at scene load I don't seem to be experiencing this problem, only runtime adding of it. I also submitted a ticket for their support but I wasn't sure if you had any idea what was going on or if it had anything to do with DunGen in your experience.
     
  44. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I'm not sure what's causing that. I've just tried testing it myself and I can't seem to reproduce the issue. What versions of Unity, DunGen, and SECTR are you using?
     
  45. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Unity: HDRP 2019.3.15f1
    DunGen: 2.13.0
    SECTR COMPLETE: 2019.0.3

    A few things I have tried to troubleshoot:
    Forcing update after DunGen generated the tiles as well as after a short delay after tiles are generated.
    Variety of different settings on culling such as always update children, group children, individual children updates, nothing seemed to effect.

    A few videos to show:
    Initial generation, no rooms culled (cull in editor is turned on in the Sectr settings) skip to about 16 seconds. I know this one didn't generate a ton of tiles, but it's the same with larger amounts as well.


    Interior of rooms, this shouldn't make a difference because only the portal line of sight matters but to show the rooms are enclosed:


    And then after the camera has moved around a little you can see that the first rooms act as they should, while the further rooms that haven't been visited yet not being culled:
     
  46. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622

    I'm think able to reproduce the issue now. I had 'Multi Camera Culling' turned on before; now that I've turned it off I'm getting no rooms being culled initially.

    I'm still looking into the cause (SECTR's culling camera is 2000 lines of code), but I think it's not registering the sectors because the camera exists before the rooms are spawned (in my case at least). Turning the culling camera component off and then on again fixes the issue. Hopefully I'll have a proper solution soon.
     
  47. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Awesome, that makes sense. Thanks for the quick turnaround. For now I will figure something out to refresh the camera after generation.
    Thanks!
     
  48. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Would that also effect room placements? getting overlapping rooms as well. Investigating now, i'll update what I find.
     
  49. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    It shouldn't cause overlapping rooms. Overlapping rooms are usually caused by one of three things:

    1. A doorway component isn't quite on the edge of a tile
    2. The automatic bounds generation isn't producing the correct results for whatever reason. You can check this by entering play mode and then selecting one of your rooms in the scene view - it should have a red box that represents the bounding volume of the room. If it's not correct, you can always manually override it by adding a Tile component to your room prefab and enabling 'Override Automatic Tile Bounds'.
    3. In cases with more extreme overlaps, a doorway might be facing the wrong way. You'd notice something was wrong right away if that was the issue though.


    Regarding the culling issue: refreshing all active culling cameras after generation does seem to fix it for me.

    Code (CSharp):
    1.  
    2. foreach(var cullingCam in FindObjectsOfType<SECTR_CullingCamera>())
    3. {
    4.    if(cullingCam.isActiveAndEnabled)
    5.    {
    6.        cullingCam.enabled = false;
    7.        cullingCam.enabled = true;
    8.    }
    9. }
    10.  
    This goes at the end of the PrepareForCulling() method in 'SECTRPortalCullingAdapter.cs'. It feels like a bit of a hack so I'm not 100% happy with it, but it works and I haven't been able to find a better way to do it. I've applied this fix to the current beta version.
     
    Last edited: Jun 6, 2020
    BigRookGames likes this.
  50. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Amazing support, thanks. Will definitely leave a review. Really enjoying the plug-in.
    Thanks.