Search Unity

  1. 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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

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,110
    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:
    128
    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,110
    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:
    128
    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,110
    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:
    16
    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:
    452
    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:
    16
    My bad! Didn't notice that. Thanks!
     
  9. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    440
    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,110
    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.
     
    Vincent13122 likes this.
  12. Vincent13122

    Vincent13122

    Joined:
    Oct 26, 2014
    Posts:
    66
    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:
    452
    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:
    16
    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:
    452
    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:
    269
    At this point is version 2.13.0 (Beta 4) considered stable?
     
  20. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    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:
    33
    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:
    33
    Did you check out the readme.pdf it comes with? Not exactly a video, but it's real clear and step-by-step.
     
    Vincent13122 likes this.
  23. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    452
    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,110
    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 Vincent13122 like this.
  26. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    185
    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. Vincent13122

    Vincent13122

    Joined:
    Oct 26, 2014
    Posts:
    66
    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:
    185
    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:
    452
    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:
    33
    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:
    452
    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:
    46
    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:
    452
    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:
    46
    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:
    452
    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:
    452
    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:
    452
    Version 2.13.1 - Download
    Be sure to backup your project before updating to a beta version of DunGen.
    Last Updated 25 May 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
     
    Last edited: May 25, 2020 at 1:53 PM
    hopeful and Vincent13122 like this.
unityunity