Search Unity

DunGen - Procedural Dungeon Generation

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

  1. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
  2. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The only thing I could think of is that maybe Agent.updateRotation is not being set back to true after having finished traversing an off-mesh link. But looking at your script, it's still there on line 69 so I don't think that's it.

    As far as I'm aware, NavMesh support is properly implemented into DunGen - the NavMesh is generated and the links are placed - but getting the agent to traverse the navigation mesh properly is outside of the scope of DunGen. Unfortunately, I just don't know enough about Unity's NavMesh system to give any better answers. You might have better luck in the navigation section of the forums if you haven't already checked.

    Sorry I couldn't be more helpful.
     
  3. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    I'm trying to get the Unity NavMesh working but after installed the asset from the integration folder I'm getting this error.

    Code (CSharp):
    1.  
    2. Assets/NavMeshComponents/Scripts/NavMeshSurface.cs(376,52): error CS0117: `UnityEditor.PrefabUtility' does not contain a definition for `GetCorrespondingObjectFromSource'
    3.  
    4.  
     
    Last edited: Sep 27, 2018
  4. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    It looks like PrefabUtility.GetCorrespondingObjectFromSource was added in 2018.2; if you're using an earlier version of Unity, make sure you select the correct branch when downloading Unity's high level API components.
     
    hopeful likes this.
  5. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    Whoops, that's what the problem was. 2018 for 2017. Thank you!
     
  6. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
  7. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    You'll have to use Off Mesh Links. If you check my posts on previous pages, you can see the threads on what to do.
     
    Aegon-Games likes this.
  8. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    I have turned on Off Mesh Links but still nothing creating the link in between.

    EDIT: I figured out what the problem was. "Disable when door is closed clicked in the Unity Nav Mesh Adapter. Once I unchecked it then the Off Mesh link was there.

    But I have noticed that it creates the Off Mesh Link regardless if there is a door/wall there.
     
    Last edited: Oct 3, 2018
  9. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Is there a way to randomize wall textures?
    I want to change the texture on the walls of a room, but I can't just randomize the wall prefab because the doorframe wall needs to have the same texture. So there is a bit of a dependency there. I need both the wall and the wall-doorframe to have the same random texture. Is that possible?

    Perhaps a way to say:
    If generating with Wall_5, use DoorFrameWall_5 for entry ways


    Also, can you bake Height Meshs at runtime, in addition to the regular navmesh?
     
    Last edited: Oct 8, 2018
  10. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    Hi and thanks for this asset, it is great. I've been making some great looking maps, but I have a question. I'm sorry if this has been covered before, either here or in the readme. I was wondering if there's an easy way to force corridors between rooms, currently I can't see how to do this. Thanks in advance for your help.
     
    peanutgallery, IsntCo and hopeful like this.
  11. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    I think I found the solution to the above, it's somewhere in this thread. Basically you check the type of the tile in Generator.cs and you can force a return if the two connection types aren't what you want (in this case both rooms).

    I'd be interested to know how to extend this and have a minimum of two corridors between each room. I assume you'd need to keep a flag or count of some sort.

    On another note, I was wondering how to avoid double thickness doors (see attached).



    https://imgur.com/a/Tr6infB

    I think you'd be able to make a corridor with no doorway but this wouldn't help for adjacent rooms. Does anyone have any ideas?
     
    Last edited: Oct 17, 2018
  12. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Do you happen to have a script/instructions for how to do this?
     
  13. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    It's on page 19 of this thread:


    "This is a little tricky. DunGen doesn't know about corridors as a separate concept, it only deals with rooms.

    While I haven't tried it, one possible solution is to make two separate DoorwaySocketTypes, one for doorways in your rooms and another for those in your corridors, then override the default IsMatchingSocket method so that only room and corridor doorways can be connected."

    For Example:

    In DoorwaySocket.cs, add entries to the enum for Room and Corridor doorways

    Code (CSharp):
    1.  
    2. public enum DoorwaySocketType
    3. {
    4.     Default,
    5.     Large,
    6.     Vertical,
    7.     Room,
    8.     Corridor,
    9. }
    10.  
    "Then, in the same file, replace the existing IsMatchingSocket method with your own implementation:"

    Code (CSharp):
    1.  
    2. public static bool IsMatchingSocket(DoorwaySocketType a, DoorwaySocketType b)
    3. {
    4.     // DON'T allow Corridor sockets to connect to one-another
    5.     if (a == DoorwaySocketType.Corridor && b == DoorwaySocketType.Corridor)
    6.         return false;
    7.     // DON'T allow Room sockets to connect to one-another
    8.     if (a == DoorwaySocketType.Room && b == DoorwaySocketType.Room)
    9.         return false;
    10.     // DO allow Room and Corridor sockets to connect
    11.     if ((a == DoorwaySocketType.Corridor && b == DoorwaySocketType.Room) ||
    12.         (a == DoorwaySocketType.Room && b == DoorwaySocketType.Corridor))
    13.         return true;
    14.     // Every other socket type can connect if the two sockets match
    15.     return a == b;
    16. }
    17.  
    "If you only have the two doorway socket types, the above implementation can be simplified to this:"

    Code (CSharp):
    1.  
    2. public static bool IsMatchingSocket(DoorwaySocketType a, DoorwaySocketType b)
    3. {
    4.     // Only allow connections between sockets which don't match
    5.     return a != b;
    6. }
    7.  
    "As I mentioned, I haven't tried this but it should work in theory; however it doesn't solve the issue of "hanging" corridors that don't have a room connected to both ends."
     
    Keaneo, peanutgallery and hopeful like this.
  14. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,687
    Another option for corridors ... which you may find helpful or not ... is to include the corridors in each of your room sections.

    So you'd design a room, and then you'd add an entry corridor to it and and exit corridor to it, and the combination of the 3 things together would make your "dungen room."

    Then dungen will snap the doors for the corridors together.

    You could probably also arrange it so that if the corridor doesn't attach to something, a blocker appears at the beginning of that hallway, sealing it off. So technically you would still have a corridor to nowhere hanging there, but a character in the room won't see it, because the room is sealed off from the hallway.

    Does that make sense? I haven't tried it, so there may be a snag in there somewhere.
     
  15. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    I like that idea, the tricky part is how to tell if a corridor doesn't attach to anything. It also seems tricky to block it at the room connection if it doesn't. I guess this could be done by checking each corridor for open doorways, and if it is equal to one instead of two, then also block the opposite end. I'll see if I can do something like this when I next update my dungeon.
     
  16. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,687
    Door blockers are a built-in function. They get triggered when there is no room attached to a door. It should activate the linked door blocker mesh regardless of where it is located in the room.

    Also, when dungen matches doorways, you don't necessarily have to have physical doors. So the corridors can be open as they attach to one another.
     
  17. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    I get that they are generated, my concern is how to tell if a corridor is hanging. I'm assuming that the generator fills in the dead-end with a wall if it doesn't connect to another room? That's what I meant when I said checking for one open doorway rather than two, I meant a dead-end wall. It's difficult to describe this without trying a few things in the generator as the vocabulary needs to be specific.
     
  18. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,687
    You'll have to play with it. The doorway script gives you the options for connectors and blockers, and you set them according to socket groups.

    I suspect you'll have to have a different blocker object for each corridor in a room, as even if you use the same blocker mesh / material, there will be a different offset for each corridor.
     
    Last edited: Oct 22, 2018
  19. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    Different offset? I don't follow. I can see that they could be different sizes? But without digressing I think it should be easy enough as I said to check if a corridor only has one blocker object, and if so add another.
     
  20. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,687
    If I'm right, you'll see quickly enough. But it should still be very practical and doable.
     
  21. devgamer1

    devgamer1

    Joined:
    Oct 6, 2018
    Posts:
    7
    To be fair I've not fully taken in everything you've said as I don't have enough knowledge of how the generator works. I can tell the points you have made are very relevant though and I applaud your advice. I'll refer to them when I start the hackery.
     
  22. zh4r0naX

    zh4r0naX

    Joined:
    Oct 30, 2016
    Posts:
    71
    Does this asset work with the 2018.3 unitybeta ?
     
  23. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,687
    I don't keep up with the betas, but that's got the new prefab system, right? I would think that would prevent DunGen from working properly, and necessitate an update specifically for the new prefabs.
     
  24. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sorry I've been really slow about answering questions on the forums and in e-mails recently. Thanks to everyone who's been answering questions in my absence. I'm still going to be a little slow for the moment, but intend to be back to full speed by the new year.

    I've only tested the demo scene for the moment, but everything seems to be working fine.

    Unity has always been very good about not breaking things with new versions, but I did expected the new prefab system to cause some problems - thankfully that doesn't seem to be the case. There are a few warnings about API changes that I'll need to push a new version to fix, but they don't affect the functionality of DunGen.
     
    peanutgallery and hopeful like this.
  25. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    IMPORTANT

    It has just been brought to my attention that someone claiming to be Aegon Games had been selling DunGen as a special Halloween discount on itch.io for a few hours. We have never sold DunGen anywhere other than the Unity Asset Store - if that changes, I'll post about it here.

    We've already contacted itch.io about it, but if anyone bought the asset from there, I'd recommend contacting itch.io yourself. I have no idea what was actually in the package being sold, but obviously don't run any executables.
     
  26. Tarball

    Tarball

    Joined:
    Oct 16, 2016
    Posts:
    166
    Hi, great asset so far. With most prefabs, I don't have any problem, but when the mesh extends outside of the bounding axis, I have some issues. I have attached the tile script to override bounds, but this does not seem to help. For example, for "blockers," I use the following prefab:
    dungen.png
    As you can see, the new bounds indicated by the red box overlaps with the portal which is facing outwards. However, the mesh and its collider extend beyond it. This is giving me inverted blockers where they are facing the wrong way and overlapping with the tile they are supposed to block. I am having a few other issues too that I believe to be related. I sent an email a couple hours ago, but this image may help clarify my issue. Any help is appreciated. Thanks.
     
  27. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Prefabs that are spawned out of the boundaries of a room are a problem since the bounding box is used to detect collisions between two rooms. Blocker prefabs can only be spawned after the dungeon is finished being generated, so there's no way to include them in the collision checks either - resulting in blocker prefabs that sometimes overlap neighbouring rooms.

    I think the only way to handle a dead-end like that would be to include it in the room itself, and only spawn the rubble itself as a blocker - that way it can be instantiated inside the bounds of the room with no risk of overlapping its neighbours.

    As a side note, I'm not sure if I'm misunderstanding but it sounds like your blocker prefab has a Tile component and a doorway in it. Those shouldn't be in a blocker; it's unlikely to cause any problems either, but it's best to avoid it anyway.
     
  28. binbash3r

    binbash3r

    Joined:
    Nov 5, 2016
    Posts:
    13
    With the new A* Pathfinding update, the AStarNavMeshAdapter.cs script is throwing an error on line 56 because ScanLoop is now deprecated. Scan or ScanAsync (the new methods) do not work as "ProgressCallback" is not of type NavGraph. I've sent an email via the support website about this and how the issue pertains to my project.
     
    Last edited: Nov 6, 2018
  29. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I think I've already fixed this in an internal build. Unfortunately, I only have the (now deprecated) 3.x version of A* Pathfinding Project so I can't test the fix myself right now.

    Basically, in AStarNavMeshAdapter.cs, I replaced this:

    Code (CSharp):
    1. PathFinder.ScanLoop(ProgressCallback);
    with this:

    Code (CSharp):
    1. foreach (var graph in PathFinder.graphs)
    2.     foreach (var progress in PathFinder.ScanAsync(graph))
    3.         ProgressCallback(progress);
     
  30. binbash3r

    binbash3r

    Joined:
    Nov 5, 2016
    Posts:
    13
    Looks like there are only two more errors in the latest version:

    Code (CSharp):
    1. Assets\DunGen\Code\Utility\UnityUtil.cs(293,20): error CS0103: The name 'PrefabUtility' does not exist in the current context
    2.  
    Code (CSharp):
    1. Assets\DunGen\Code\Utility\UnityUtil.cs(294,24): error CS0103: The name 'PrefabAssetType' does not exist in the current context
    2.  
    This works in-editor, but not if you try to build the project. I should note that I'm using mostly-compatible packages with the game, like Multistory Dungeons, A*, and of course, DunGen. I'm generating dungeons on runtime currently.
     
  31. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sorry about that. This issue has already been fixed in an internal build, but the beta download page isn't working at the moment and I don't have time to fix it right now.


    I'm hoping to submit the new beta build to the asset store in the next few days, so it should be available next week. If anyone needs it now, please send me an email at support@aegongames.com with your invoice number and I'll send you the package that way.
     
    hopeful likes this.
  32. binbash3r

    binbash3r

    Joined:
    Nov 5, 2016
    Posts:
    13
    Will do. As always, thanks for your continued support of a great asset!
     
  33. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The new version (2.11.5) is now available on the asset store and DunGen is 50% off during Unity's Cyber Week Mega Sale (until 7th December)

    Bugfixes
    - Fixed an issue preventing the basic culling camera from culling rooms behind a closed door
    - The Basic Culling Camera will now no longer incorrectly refresh the visible set of tiles every frame - this could increase performance greatly
    - Fixed an issue causing the integrated basic culling to not work if the camera was spawned through code

    Changes
    - Updated to work with the new prefab system in Unity 2018.3
    - [BREAKING CHANGE] A* Pathfinding Project Pro integration updated to version 4.0+. If you're using an older version, you'll need to add ASTAR_PATHFINDING_VERSION_3 to your "Scripting Define Symbols" in the Unity project settings
    - Moved demo scripts to their own namespace to avoid naming conflicts
    - Small update to the 2D demo scene to include a controllable "player character"
     
    hopeful likes this.
  34. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Just wondering, does DunGen provide a class where I can access its map data?

    Sure, I can save the seed and regenerate the same map, but what if I want to allow user to modify to the map during runtime? Without knowing which cell contains what, it’s pretty hard to do that.

    Thx in advance.
     
  35. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    There's some information about the dungeon layout provided in the Dungeon class which can be accessed via RuntimeDungeon.Generator.CurrentDungeon after the generation process is complete.

    This class contains a list of all tiles and the connections between them. If you'd prefer the information in graph form, the Dungeon class has a ConnectionGraph variable that might be more useful.
     
    bitinn likes this.
  36. GBCFraser

    GBCFraser

    Joined:
    Apr 11, 2013
    Posts:
    94
    Question: Will your dungeon generator work in 2D with the tilemap system?
     
  37. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    I have gone through the Integration with Sectr Vis and DunGen in your manual.

    The culling *mostly* works but there is a sliver of space between each generated room (as I walk through the Doorway) that culls incorrectly:
    https://gyazo.com/b6a4b529df846eaff92f5b2f6ea11d1e

    The door is in the "isOpen" state and should work. But when I move to the middle of the Doorway, everything is suddenly culled away.

    A couple screenshots of the level:
    https://gyazo.com/a6bca81857749c21aeb5da4c6c6a637d
    https://gyazo.com/7f3b379ae9882fa91329d92576b7db55

    Perhaps there is an issue with how DunGen does portals?
     
  38. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    191
    I think this is the best dungeon generator by far. But is there a function to fill the empty areas around the dungeon? for a topdown game I would like to fill these areas.
     
  39. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sorry for the late replies.

    After some testing it looks like DunGen does work with Unity's tilemap system.


    I don't know if this is the problem you're having, but I did notice there's a discrepancy between DunGen's tile bounds and those calculated by SECTR VIS. This could result in a small gap between sectors. If this is what's causing the problem, you can work around the issue by increasing the "Extra Bounds" field in DunGen's SECTR VIS culling adapter.


    There's no function to fill empty space right now. It's requested a lot but I think the only method I could use to fill in the empty space would be to scatter random small meshes in the space between rooms; I don't think that's what people have in mind though.
     
    hopeful likes this.
  40. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Thanks, that seemed to solve the Sectr Vis issue.
     
    hopeful likes this.
  41. StonedLover

    StonedLover

    Joined:
    Apr 16, 2014
    Posts:
    47
    Hey,
    I run into the Issue that my Tiles are overlapping even if I assign to the rooms the Tile and override the bounds, and no wall is outside the red box. But they still overlap. Anything I might miss to setup ?

    EDIT:
    Found the Issue. The Door Facing wasnt correct. Just a suggestion but might be a good idea to show with some kind of arrow or other simple mesh to show the direction OnGizmo. Since it wasnt that clear how this act in first place :D
     
    Last edited: Dec 11, 2018
    hopeful likes this.
  42. Creiz

    Creiz

    Joined:
    Jun 6, 2017
    Posts:
    130
    I've been eyeing this for a while, looks like it could help me make something like an infinite tower puzzle for my game. A question, though, do any of you know about a minimap system that works well with this?
     
  43. tonywalsh

    tonywalsh

    Joined:
    Jun 4, 2014
    Posts:
    16
    Can anyone confirm -- injected tiles do not 'know' which way the dungeon is flowing with regards to Entrance and Exit doorways, is that correct?

    This seems to be the case based on testing.

    Secondly, injected tiles do not seem to spawn branch tiles (probably because they don't 'know' about flow). Correct?
     
  44. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Any system that allows you to generate the map at runtime should work. I've only ever looked at one minimap system (DMMap), and it does include a procedural level demo.


    Injected tiles should work the same as any other regarding entrance and exit doorways. I had to check the code for this, but the only difference between placing a normal tile and an injected one is that the generator overrides the pool of potential tiles to pick from; the doorway selection process that comes after that doesn't care where the tile came from.

    Injected tiles should also be capable of spawning branches as long as they are spawned on the main path.


    I tested this by added an injected tile with specific entrance & exit doorways to the demo scene to confirm.
     
  45. Lukas_Schwarz

    Lukas_Schwarz

    Joined:
    Aug 3, 2013
    Posts:
    7
    Hey, I'm currently evaluating whether DunGen is for me or not and got a question regarding the flow editor.

    You posted an image way back on page 2 of this thread that shows a tree instead of a linear path that the user can describe in the flow editor. This feature is not implemented right?
    I'm really interested in this functionality and I also don't require loops in the flow tree.
    Since you grant full access to the source code: Do you think that this feature could be implemented by me in a reasonable time frame?

    Don't rush your answer, I got time and so far DunGen seems to be the only product with this kind of functionality.
    Thanks in advance!
     
  46. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    I use DMMap and it works pretty well for this
     
    Aegon-Games likes this.
  47. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Yeah, that flow graph was never implemented in the end. Unfortunately, I ran into a number of issues trying to implement branching paths.

    It's been a while since I looked into it, but adding support for a tree graph would require some non-trivial changes to the dungeon generator itself (as well as completely rewriting the graph editor of course).
     
  48. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    335
    Hello Aegon-Games,

    do u know why baking is quite long ?

    how i can disable this ?

    upload_2019-1-12_23-57-42.png

    upload_2019-1-13_0-6-29.png

    it is new scene:
    upload_2019-1-13_0-7-55.png

    what is computer minimum specs for using dungen ?


    ++
     
    Last edited: Jan 12, 2019
  49. Mana-Station

    Mana-Station

    Joined:
    Apr 27, 2015
    Posts:
    168
    Oh, that's easy!

    Open Window -> Rendering -> Lighting Settings. Just disable "Auto Generate" at the bottom of this window and it's gonna stop baking all the time.

    If you don't want to use baked lighting at all, you can disable "Realtime Global Illumination" and "Baked Global Illumination" all together. If you do want to use it (for a mobile project for example), at least set Lightmap Resolution at a number between 5 and 15 (it's 40 by default).

    Lighting_Settings_01.jpg

    Hope that helped! :)
     
    Aegon-Games, hopeful and tequyla like this.
  50. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    335
    Hi,

    thanks

    ++