Search Unity

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

DunGen - Procedural Dungeon Generation

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

  1. JuZtchillin

    JuZtchillin

    Joined:
    Nov 6, 2014
    Posts:
    9
    Hey Aegon,

    I tried the beta 2.10. It is still happening when generating a dungeon in the editor. However I couldn't get it to happen at run time. It used to happen in both before. I also kept the same settings for run time and editor generation.
     
  2. TBruce

    TBruce

    Joined:
    Jan 18, 2015
    Posts:
    86
    Hi,

    Can DunGen do a Metroid style map? This would be utilizing both Vertical and horizontal rooms.

    Thanks
     
  3. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Sorry for the late reply. In the "New Dungeon" window, make sure "Ignore Sprite Bounds" is unchecked, otherwise 2D rooms bounds won't be calculated properly. It looks like it's still checked by default; I'll make sure it's unchecked by default in future builds.


    Yes, doorways can be placed both horizontally and vertically. It'll be up to you to ensure ceiling doorways are always reachable in-game though.
     
  4. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    BTW, Unity's own runtime generated navmesh is coming. You can see the WIP version of it being used in a procedural dungeon setting here.

    Not sure when it is coming out, it could be a few months away, but DunGen users will eventually have an official Unity navmesh solution. :)
     
  5. TBruce

    TBruce

    Joined:
    Jan 18, 2015
    Posts:
    86
    My question was not regarding doorways but in a Metroid style game when in a 2D vertical area with gravity.
     
  6. MisterMatt

    MisterMatt

    Joined:
    Oct 24, 2012
    Posts:
    13
    I have purchased this asset and it is very well put together. The only thing I would like to have added would be code samples of creating a dungeon flow via code instead of using the visual editors. Given certain conditions in my game I would like to modify the available tiles, length, number of gated bosses, etc.

    I have been poking around at the library starting with creating a DungeonGenerator, DungeonFlow, adding GraphLines with KeyLockPlacemens and DungeonArchetype with custom TileSets with TileWeigths and GameObjectChances, etc.

    I am making progress on this and can eventually get it working, but it would be great to have some "Happy Path" starting point examples, is this something you would be able to provide? Maybe have something similar hidden away in a testing project you would be willing to share?

    Thanks in advance! :)
     
  7. JuZtchillin

    JuZtchillin

    Joined:
    Nov 6, 2014
    Posts:
    9

    Hey Aegon,

    No problem :). Ya once I unchecked the "Ignore Sprite Bounds" it worked fine. Thanks.
     
  8. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    I have noticed a couple of problems lately, and not sure how to fix them.

    1) Every now and then I get and error related to placing the keys that prevents the Dungeon from being generated


    2) It seems the bounding box collider generated for each tile, acts funny sometimes:




    Any idea how to fix those?

    Thanks!

    EDIT: Quick update just to mention that this bounding problem can happen to the same tile (one instance is correct and another one is not) and in all cases it seems to be the X axis (it gets about 10 times bigger)
     
    Last edited: Nov 8, 2016
  9. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    Me again :p

    I have some problems understanding how the Local Prop Spawn works.
    I use a local prop set to spawn some enemies (see screenshot)


    As you can see in that room I have 5 props (enemies) listed, I set the count between 0-3 and 3 were spawned.
    So far so good, the problem is that this is the first room and as you can see in the graph the chances of spawning that early should not be that high, this happens very often on the first and second room.
    The main path has a 8-12 room's length.

    I set up the graphs like that because I would like to avoid having enemies on the first couple of rooms, should that be done any other way?

    Thanks.
     
  10. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Once again, sorry for the late reply. I'm not getting email notifications from the forums anymore for some reason so I'll have to try and get in the habit of checking back regularly.

    This will probably be the last round of changes for this beta build before I finally push it to the Asset Store. I was hoping for a big feature in 2.10 but that's not going to happen; this beta cycle has been far too long already.

    Version 2.10.0 (Beta) - Download
    - Bugfix Fixed an issue with the 2D demo scene which caused tiles to overlap
    - Change "Ignore Sprite Bounds" in the dungeon generation settings is now unchecked by default
    - Feature Doorways now have a priority for deciding which doorway's "Door Prefab" should be chosen
    - Feature Added an option to specify which layer the tile trigger volume is placed on (Defaults to "Ignore Raycasts", only effective if "Place Tile Triggers" is checked)
    - Bugfix "Avoid Door Prefab Rotation?" for doorways should now be set properly
    - Bugfix Door prefabs should now always be cleaned up correctly
    - Bugfix Auto-placed trigger volumes for tiles no longer sometimes have negative sizes

    * NEW *
    - Bugfix Fixed an issue with the SECTR VIS integration that was causing door states to not correctly update
    - Bugfix Fixed an error that ocured when trying to place a lock on a doorway that was already locked
    - Feature Added a DungeonFlowBuilder helper class to assist with creating a dungeon flow graph through code
    - Feature Added a new "count mode" to the local prop set script which allows the number of props to change based on the tile's position in the dungeon layout
    - Bugfix Fixed an issue that was incorrectly allowing assets to be selected in the LocalPropSet component


    Good to know. I knew it was on their roadmap, but I didn't think it was potentially that close to being implemented. I'll be keeping an eye on this so I can add integration when it's ready.


    The shape of the dungeon is pretty much determined by where the doorways are placed, which is why I brought it up. The dungeon can progress both horizontally and vertically if you also place doorways on what would otherwise be the room's ceiling - that will allow DunGen to place another room above.


    Hmm, that's an interesting one. I never thought about creating dungeon settings through code so I'm not sure how feasible it will be. I spent a few hours tampering and came up with a nicer way of building the dungeon flow graph (the newly implemented DungeonFlowBuilder class). The issue comes with creating TileSets, Archetypes, and the like at runtime since they're derived from ScriptableObject and I don't think you're supposed to instantiate those at runtime.

    That said, I was able to get something working - albeit without the lock & key stuff - you can see the code here (requires the new beta build from above).


    Were you using the 2.10 beta? The bounding box issue should have been fixed in that build. Regarding the lock & key error message, I've just added a fix to the beta build that I think should solve the issue.

    As for the local prop set script, it didn't work the way you want - it picks a random number of props first (before considering the depth scale of each individual prop). I've added a new "Count Mode" to the local props script in the beta build above though. You should now be able to set this to "Depth Based" and DunGen will pick the number of props based on how deep into the dungeon the room is. It does this by sampling the "Count Depth Curve" (where the value is 0, the minimum count will be used, where it's 1, the maximum count will be used). Hopefully, this behaves closer to what you wanted.
     
    Last edited: Nov 18, 2016
  11. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    Thanks for quickly uploading a new build! I will give it a try and let you know if I still have the bounding box and key issues.

    Regarding the props spawning, the new addition looks interesting but I guess I did not explain myself correctly.
    I don't want more enemies as the player goes deeper, I just didn't want enemies in the first couple of rooms.

    You are mentioning that first it picks a random number of props, in the example I gave you it picked 3, that's fine.
    Then if I'm understanding this correctly, from those 3 picked, it checks their probabilities of spawning against their individuals depth scale graphs, in the example I gave you for the 3 ones should be close to 0 since they are in the first room, but they still spawned, and that happens most of the time. So it seems I'm not understanding the individual depth scale field properly or that it barely has any effect.

    Are there any methods available to check how far in a dungeon is an specific GameObject?

    Cheers!
     
  12. tomraegan

    tomraegan

    Joined:
    Mar 28, 2016
    Posts:
    137
    Hi there. I'm currently learning DunGen and it's all going well, except for Local Prop Set. Random Prefabs works great, but Local Prop Set gives me an error:

    Destroying assets is not permitted to avoid data loss.
    If you really want to remove an asset use DestroyImmediate (theObject, true);

    I've got Unity and the asset up to date, so I was thinking it was my method causing the problem.

    - Create GameObject inside tile
    - Add Local Prop Set component
    - Select multiple props and add to component
    - Generate Dungeon

    Anyway, if anyone can help I'd appreciate it.

    Edit: Having played with DunGen for several hours now, I must say it is quite brilliant. To me, that is. It's the tool that best manifests inside Unity the idea in my head.
     
    Last edited: Nov 18, 2016
  13. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    The individual depth scales in the LocalPropSet component adjusts the chance for each object to spawn relative to one-another, so if they all have a low weight, they have an equal chance to spawn. The weights just tell DunGen what to pick, not how many to pick, that is already decided.

    I've updated the beta build with another "Count Mode" option named "Depth Multiply" which will calculate a random number (based on the min & max count), then multiply it by the value in the depth curve. You can probably get the results you want by setting the "Count Depth Curve" to something like this:

    CurveExample.png

    That'll prevent anything from spawning at the beginning of then dungeon (about the first 20% using the graph above), while still giving you the random variation beyond that point.

    Alternatively, if you want more control you can access the tile depth by getting a reference to the Tile that contains your enemy spawns. The easiest way to do this would be to implement your own prop type by deriving from DunGen.RandomProp:

    Code (CSharp):
    1. using DunGen;
    2.  
    3. public class DepthBasedSpawn : RandomProp
    4. {
    5.     // How many tiles into the dungeon path before this object can spawn?
    6.     public int MinimumDepth = 3;
    7.  
    8.     public override void Process(System.Random randomStream, Tile tile)
    9.     {
    10.         // Get our current depth along the main path (in tiles, staring at 0); we could also get the depth percentage using tile.Placement.NormalizedPathDepth
    11.         int depth = tile.Placement.PathDepth;
    12.  
    13.         // If we're not deep enough in the dungeon to spawn this enemy, destroy it
    14.         if (depth < MinimumDepth)
    15.             Destroy(gameObject);
    16.     }
    17. }
    18.  


    Sounds like you're giving the Local Prop Set an asset instead of an object from the scene. That prop type should only accept game objects that have been placed in the room itself, so that you can furnish the room by hand and let DunGen randomise which objects should be kept at runtime.

    The fact that the LocalPropSet component was accepting GameObjects that aren't in the scene is a bug and I've fixed it in the new beta build.
     
    Arganth and hopeful like this.
  14. tomraegan

    tomraegan

    Joined:
    Mar 28, 2016
    Posts:
    137
    Great. That's it!
     
  15. ANTARES_XXI

    ANTARES_XXI

    Joined:
    Dec 23, 2014
    Posts:
    141
    Hey! Does this asset use multithreading / coroutines? Can we show some animated UI (progressbar os smthing else) while generating a dungeon?
     
  16. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Unfortunately, DunGen doesn't run asynchronously yet so you can't use animated UI while it's generating. It's high on my to-do list, but finding the time to work on it is proving difficult at the moment.
     
    Gekigengar likes this.
  17. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    HI AegonGames im a big noob, i got A* Project Pro and i followed the tutorial but nothing seems to happen, im missing something? please help

     
  18. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    The "A Star Nav Mesh Adapter" component (DunGen/NavMesh/A* Pathfinding NavMesh Generator) needs to be on the same GameObject as the Runtime Dungeon Generator component.
     
    Arganth likes this.
  19. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    It turns out the ProBuilder change I reverted earlier actually is needed. If anyone is having overlapping issues when using tiles created with ProBuilder, this new beta build should fix that.

    Version 2.10.1 (Beta)
    - Download

    - Bugfix Tiles created with ProBuilder should now have their bounds calculated properly and should no longer overlap
     
    Arganth and hopeful like this.
  20. soglab

    soglab

    Joined:
    Dec 21, 2012
    Posts:
    2
    dun.PNG

    Hello, Thank you for your great asset . but I have same issue with "Misscelan" about bounding box ..
    and I use 2.10 too..

    how can i fix it?
     
  21. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    77
    Hi AegonGames

    I'm interested in dungen I watch your clip from asset store it look great and easy to use but I have 3 question may I ask you
    1.I’m trying to create 2d game that mean prob wall floor monster player everything are sprites. I read from readme you can generate in 2d too but I ask for sure everything ok.

    2.I have a pathfinding solution for 2d that is Poly|nav2d(this use by create one big collider for walk zone and small collider for obstacles How I define walk zone (all floor is walk zone)and obstacles) but I don’t know how to use with dungen are you have any suggestion or you have a better one please suggest me.

    3.Could I save dungeon when player create and save variable or I need use something like playerprefs (example in the dungeon have 3 boss(Boss A , Boss B , Boss C ) if kill 1 boss get 1 reward kill 3 boss get 3 rewards ,If first time kill only Boss A get a reward second time kill Boss B get another reward third time kill Boss C get another reward forth time kill Boss A,B,C have no reward)

    4.How I instantiate Enemy and Player in scene(instantiate all of this as prefabs?) ?

    5.I would like to know dungen can use 2 or more themes in 1 dungeon?

    6.Can I create room when player enter the room door lock and instantiate enemy when kill all enemy door open ?(before I think to use dungen I place trigger zone as room when player enter room player will enter trigger zone too but if I use dungen I can't place trigger zone at run time are you have any suggestion ?)

    7.I use Pro Camera 2D for move camera now I use when player enter or peek room camera move to the room that use with trigger zone too.How I place trigger zone as room at run-time?
    If you have any question please let me know

    Thankyou
     
  22. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Version 2.10.1 (Beta) - Download
    - Bugfix Tiles created with ProBuilder should now have their bounds calculated properly and should no longer overlap

    * NEW *
    - Change All Renderer component bounds will be taken into account when calculating tile bounds now, not just MeshRenderers and (optionally) SpriteRenderers
    - Feature It's now possible to override DunGen's automatically generated tile bounds by attaching a Tile component to the room prefab and checking the "Override Automatic Tile Bounds" box
    - Bugfix The scale of tile prefabs is now correctly handled


    Are you scaling your tile prefabs? The new beta build (above) should fix the issue if you are. Scaling tile prefabs was the only way I was able to encounter any issues with tile bounds, so if that's not the problem you're seeing I'm not sure what could be causing it.

    The new build also adds the option to override DunGen's automatic tile bounds calculation; you could use that method to manual specify tile bounds if necessary.


    1. 2D is supported and I've tested it with Unity's built-in sprites, but if you're using a 3rd party asset like 2D Toolkit, I can't say whether it will work properly or not. I haven't got around to testing that.

    2. I've never used Poly|Nav (or any other 2D navigation asset). From the looks of it, you'll need to write your own solution for generating the "walkable" colliders after the dungeon generation is complete. You might be able to create a walkable collider for each room and place them inside the room prefabs, but I don't know if Poly|Nav supports that.

    3. DunGen doesn't handle any sort of saving/loading. You'll need to save the seed used to generate the dungeon the first time and use it whenever you need to generate the same dungeon again. At that point, it's up to you to save and restore anything that has changed state since the dungeon was created.

    4. It's up to you how you want to instantiate enemies and players in the scene. You can place them directly in the tiles, add them as props using DunGen's prop system, or write your own spawner script.

    5. Yes, the dungeon flow graph lets you split the dungeon into any number of "archetypes" so you can use a different set of themed rooms for different sections of the dungeon.

    6 & 7. By default, DunGen will create a trigger volume for each room for you. You can attach the included DungeonCharacter component to your player object and subscribe to its "OnTileChanged" event, which will fire when the player moves between two rooms.

    I hope that helps.
     
  23. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    77
    Can I access corner position of each room?
    because poly nav 2D is polygon 2d base for create walk-able area if I can access the position I think I can change polygon at run time and that mean I can use poly Nav2D
    Thank you for reply
     
  24. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    You can access the bounding box of each room, but it's not an accurate way to determine the shape of the room unless all of your rooms are rectangular.
     
  25. flipwon

    flipwon

    Joined:
    Dec 29, 2016
    Posts:
    179
    Is there a way to disable flipping, as there is with rotation? Using a 2d perspective view my sprites don't allow for rotation or flipping. The disabling of rotation works, just need to figure out how to not allow them to flip. (which unfortunately means I have to make soooo many more tiles :( this is a problem with my sprites though not your generator lol)

    edit2: My tiles don't seem to be flipping any more, which is strange because I haven't changed anything since, though I am now having some strange happenings.

    Sometimes larger rooms seem to be spawned when they have no room:


    Sometimes my blocker objects are spawning in the middle of other rooms:


    and finally sometimes the walls are just not being removed:


    As far as I can tell, these problems seem to all be stemming from overlap. The generator just doesn't notice that a room is already there or something. I guess that change I read above from November hasn't launched yet?

    edit #32819481294: Have updated to the beta version and still getting overlaps on the rare occasion. Triple checked door rotations,
    North: -90, 0, 0
    South: 90, 0, 180
    East: 0, 90, -90
    West: 0, -90, 90

    which seems to be your default values


    edit #4218941289491284921: The only way I've found to get rid of the overlap is by overriding the automatic tile bounds and setting them up manually, making sure the extents z has a positive value. Any idea why this is?
     
    Last edited: Jan 16, 2017
  26. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Tiles should never flip, only rotate; so I'm not sure what's up with that.

    I've been getting occasional reports of overlapping tiles for a while, but for the last few months I haven't been able to reproduce the problem myself - even with multiple demos as well as our own games & prototypes. Clearly I've overlooked something; maybe a difference in workflow or a commonly used asset.

    Is there any chance you could send me a small demo project with the overlapping issues? You can email it to dan@aegongames.com
     
  27. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    So we can do complex maps now?
    (multiple linked hallways/rooms, different biomes, areas that are only passable once certain abilities have been unlocked)
    This is great news!

    How do we set this up with Dungen?

    This is the Super Metroid map for those that don't know what this entails:
     
  28. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    @AegonGames

    Hi, i need and answer ASAP please, im triying to make my dungeon spawn with a 45 degrees of rotation in the Y axis, this i want to achieve a isometric perspective, but i try to set my tiles with a 45 rotation, but the dungeon generator undoes the angle back to 0, i tried setting the dungeon root with 45 degrees, but it did not worked, it still generated the dungeon straight, is there any way of acheiving this with DunGen?
     
  29. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    I manage to set it up



    I did my own recast graph generation code, without door support, but i dont care because my game does not allows enemies go pass doors, what i did was twist the generated level root transform by 45 degrees in the Y axis, and after that i got a reference to the recast graph and called the SnapForceToScene method, so the navmesh would generate, and it works, but i can see by the dungeon bounds gizmo that the dungeon generator still thinks the level is straight, can you please helep me with this?

    This is the code is used to generate nav mesh over the rotated level.

    Code (CSharp):
    1.     //Method that subscribes to the dungeon generator to check the dungeon generation status.
    2.     private void CheckGenerationStatus(DungeonGenerator generator, GenerationStatus status)
    3.     {
    4.         switch (status)
    5.         {
    6.             case GenerationStatus.Complete:
    7.                 RecombineStaticLevelGeometry();
    8.                 LevelRoot.rotation *= Quaternion.AngleAxis(45, Vector3.up);
    9.                 RecastGraph graph = AstarPathFinder.graphs[0] as RecastGraph;
    10.                 graph.SnapForceBoundsToScene();
    11.                 AstarPathFinder.Scan();
    12.                 break;
    13.             default:
    14.                 break;
    15.         }
    16.     }
     
  30. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Sorry for the confusion, I was only referring to vertical & horizontal rooms.

    Different biomes are possible by using multiple archetypes; areas that are only passable once you've obtained a certain ability could technically be done with some effort using the Lock & Key system.

    Multiple linked rooms/hallways however are still not possible. It can't feasibly be achieved with the way DunGen works - specifically, allowing arbitrarily shaped & sized rooms.


    Once the generation is complete, it shouldn't really matter where DunGen thinks the rooms are (besides, the bounds are axis-aligned and wouldn't work properly when rotated 45°).

    Leaving it as-is shouldn't cause any ill effects. For our own project though, we're actually just rotating the camera 45° instead of rotating the world - which works perfectly for our needs.
     
  31. LunaTrap

    LunaTrap

    Joined:
    Apr 10, 2015
    Posts:
    120
    Glad to hear that its no problem, i did tried rotating the camera and it worked perfectly, but it ended up being more convenient to rotate the level itself so i keep the default world axis on all my code.
     
  32. MBoffin

    MBoffin

    Joined:
    Mar 29, 2013
    Posts:
    15
    I also posted this on the 2D Toolkit forums, but it's quite relevant here as well. I tried using DunGen (the beta) and 2D Toolkit during Global Game Jam 2017 last weekend and totally failed. I was setting up the TileMap prefabs correctly per instructions on the 2D Toolkit forums, but whenever I generated the map, it came out a total mess with nothing rendered correctly at all, tiles overlapping, render data all out of whack, etc. Being a game jam, I didn't have time to sort it out, but tonight I finally dug in and got it working. It seems to be a problem using TileMap prefabs and placing them at new locations during runtime. To get it working, I had to tell each TileMap to .ForceBuild() after the whole map was done being generated. Here's the script I wrote that I attached to the runtime generator:

    Code (CSharp):
    1. using UnityEngine;
    2. using DunGen;
    3.  
    4. public class TileMapPrefabFix : MonoBehaviour {
    5.  
    6.     void OnEnable() {
    7.         GetComponent<RuntimeDungeon>().Generator.OnGenerationStatusChanged += Generator_OnGenerationStatusChanged;
    8.     }
    9.     void OnDisable() {
    10.         GetComponent<RuntimeDungeon>().Generator.OnGenerationStatusChanged -= Generator_OnGenerationStatusChanged;
    11.     }
    12.  
    13.     private void Generator_OnGenerationStatusChanged(DungeonGenerator generator, GenerationStatus status) {
    14.         if (status == GenerationStatus.Complete) {
    15.             tk2dTileMap[] tileMaps = generator.Root.GetComponentsInChildren<tk2dTileMap>();
    16.             foreach (tk2dTileMap tileMap in tileMaps) {
    17.                 tileMap.ForceBuild();
    18.             }
    19.         }
    20.     }
    21. }
     
  33. grogshotgames

    grogshotgames

    Joined:
    Aug 6, 2015
    Posts:
    77
    Hi! It's my first time using DunGen.

    I'm trying to make a dungeon where there are corridors connecting every room. I made some corridors and some rooms. and I set all Allow Immediate Repeats to true on corridors and to false on rooms, but this is what I got:



    Obviously this is not the desired result. Corridors should always be created to link rooms, and rooms should never be linked between each other without a corridor in between them.

    Is there a way to do this?

    Also it would be great to set a limit on immediate repeats so dungeons like this are not created:

     
  34. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    This may have been asked before(I looked but couldn't find an answer).
    How do you handle doorways that are in-between rooms.
    What I mean is almost all dungeon/models I have (example 3d forge kits) all have the doorway in-between rooms.
    Where all your examples both rooms have a doorway.

    3D Forge Doorway:
    https://www.dropbox.com/s/8qb2ikd4dqfshwi/3dForgeDoorway.JPG?dl=0

    DunGen Doorway:
    https://www.dropbox.com/s/uaa8xculwc2j60u/DungenDoorway.JPG?dl=0

    The only way (unless I missed something) is to setup doorways on both rooms.
    So if I did that in my scenario I would end up with the doorway being created twice(which we don't want).

    So I guess the question is, is there a way(currently) to only create that doorway once?
     
  35. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    I don't have the correct answer for you, but for an "outside the box" answer, there's this: design your rooms so the doorways are placed by you more toward the middle of the room (as opposed to at the edge), and the passages ("doorways") created by DunGen are paths that have no doors.

    If there's no other answer that will work for you, then I guess you would have to do something procedural where one door object suppresses the other one.
     
    Last edited: Feb 11, 2017
  36. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    Yeah I can think of a lot of ways I may be able to do it.
    I'm just wondering if there is an "out of the box" way to use a single doorframe.
     
    Last edited: Feb 12, 2017
  37. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    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. public enum DoorwaySocketType
    2. {
    3.     Default,
    4.     Large,
    5.     Vertical,
    6.     Room,
    7.     Corridor,
    8. }
    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.  
    8.     // DON'T allow Room sockets to connect to one-another
    9.     if (a == DoorwaySocketType.Room && b == DoorwaySocketType.Room)
    10.         return false;
    11.  
    12.     // DO allow Room and Corridor sockets to connect
    13.     if ((a == DoorwaySocketType.Corridor && b == DoorwaySocketType.Room) ||
    14.         (a == DoorwaySocketType.Room && b == DoorwaySocketType.Corridor))
    15.         return true;
    16.  
    17.     // Every other socket type can connect if the two sockets match
    18.     return a == b;
    19. }
    20.  
    If you only have the two doorway socket types, the above implementation can be simplified to this:

    Code (CSharp):
    1. public static bool IsMatchingSocket(DoorwaySocketType a, DoorwaySocketType b)
    2. {
    3.     // Only allow connections between sockets which don't match
    4.     return a != b;
    5. }
    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.


    You should be able to handle this case using the doorway component's "Door Prefab" field. That'll ensure that only a single instance of the given prefab will be created for each doorway pair.
     
    Arganth likes this.
  38. flipwon

    flipwon

    Joined:
    Dec 29, 2016
    Posts:
    179
    Hey there, everything is working great with the asset, I just have a little request. :D

    I am using a tileset that does not allow vertical flipping, but would in fact allow horizontal flipping. Is there any chance allow rotation on the tile script could be separated into two fields of allow vertical flip and allow horizontal flip?

    This would be super useful for me and I'm sure others in the future as well.

    Thanks again for the asset <3


    edit: As far as the problem I had with overlapping tiles a while back, sorry I didn't get back to you. It turns out it was being caused by the automatic tile bounds not behaving well with another unity asset "Super Tilemap Editor." I've just had to set the bounds manually, but it's nothing with your script, just how tile bounds are detected with that asset.
     
    Last edited: Feb 15, 2017
  39. IronStomachVR

    IronStomachVR

    Joined:
    Oct 25, 2013
    Posts:
    22
    It seems the newest version of SECTR VIS is no longer working with DunGen. By not working I mean it is culling very strangely, mostly not at all. I know SECTR isn't your asset but maybe it is an easy fix on DunGen's end will work. I am going to keep using the older version of SECTR VIS but they did make a lot of cpu improvements.
     
  40. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    It wouldn't hurt to mention this to the VIS dev. He's very responsive, and he would know if the behavior change is intentional or not.
     
  41. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    I was able to get it working.
    Although I did it a little different than you suggested.
    Here is what I did if anyone is interested:

    Under class Doorway I added these data members:
    Code (CSharp):
    1. public bool isDoorwayB = false;
    2. public List<GameObject> RemoveWhenIsDoorwayB = new List<GameObject>();
    Under DoorwayInspector method OnInspectorGUI I added:
    Code (CSharp):
    1.             EditorGUILayout.HelpBox("When this doorway is in use (another tile is connected using this doorway) and this is a \"B\" doorway, the selected objects below will be deleted in the scene.", MessageType.Info);
    2.             EditorUtil.DrawObjectList<GameObject>("Remove when in use and this is a \"B\" doorway", door.RemoveWhenIsDoorwayB, GameObjectSelectionTypes.InScene);
    Under class TilePlacementData method ProcessDoorways I changed this
    Code (CSharp):
    1.             foreach (var d in UsedDoorways)
    2.             {
    3.                 foreach (var obj in d.AddWhenNotInUse)
    4.                     if (obj != null)
    5.                         UnityUtil.Destroy(obj);
    6.             }

    to this:

    Code (CSharp):
    1.             foreach (var d in UsedDoorways)
    2.             {
    3.                 foreach (var obj in d.AddWhenNotInUse)
    4.                     if (obj != null)
    5.                         UnityUtil.Destroy(obj);
    6.  
    7.                 if (!d.isDoorwayB && d.ConnectedDoorway != null)
    8.                     d.ConnectedDoorway.isDoorwayB = true;
    9.                 else if (d.isDoorwayB)
    10.                 {
    11.                     foreach (GameObject obj in d.RemoveWhenIsDoorwayB)
    12.                         if (obj != null)
    13.                         {
    14.                             UnityUtil.Destroy(obj);
    15.                         }
    16.                 }
    17.             }
    Then I just added the doors to the RemoveWhenIsDoorwayB array.
     
    Last edited: Feb 19, 2017
    montyfi and hopeful like this.
  42. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    267
    hi thinking of purchasing the plugin.... things i needed to know, can do multilevels? can do high ceilings with walkable walkways?
    im thinking its more of a building level than a traditional dungeon level...
    curved levels?
     
  43. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    I'll try to take a look in the next few days and see if I can figure out what's going on.


    Multiple-floor dungeons are supported; high ceilings should also work. You're not going to be able to get a tightly packed set of rooms like you would in a building however. Rooms can be whatever shape you want, as long as the doorways lie on the very edge of the rooms axis-aligned bounding box.
     
  44. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    @AegonGames - Be sure to check with the VIS dev, as I think he's already found the problem, and (IIRC) it's on his end.
     
    Aegon-Games likes this.
  45. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    Hey @AegonGames hope you dont mind (let me know otherwise), but here is a short review of Dungen :)

     
  46. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    Hi, i try this and it doesn't work : all the theory look good but when i generate a dungeon, i got this :
    "This could indicate a problem with the way the tiles are set up. Try to make sure most rooms have more than one doorway and that all doorways are easily accessible.
    Here are a list of all reasons a tile placement had to be retried:
    NoMatchingDoorwayInTile (x21)"


    I've made some tests and its like if he just check if there is other doorway with the same DoorwaySocketType and not the code in IsMatchingSocket. Can you give me some help plz? Or did i just misunderstood something?
     
  47. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Sorry for the late reply.

    You're right, there was a point in the code that I wasn't checking the IsMatchingSocket function and was manually matching the socket groups. I've fixed the issue in a new beta build that I should be publishing later today, but if you'd like to fix the issue in the current version, find this line in DungeonGenerator.cs (line 670):

    Code (CSharp):
    1.  
    2. if (cTemplate == null || !cTemplate.DoorwaySockets.Contains(fromDoorway.SocketGroup))
    3.     tileWeights.Weights.RemoveAt(i);
    4.  
    and replace it with this:

    Code (CSharp):
    1.  
    2. if (cTemplate == null || !cTemplate.DoorwaySockets.Any(x => DoorwaySocket.IsMatchingSocket(x, fromDoorway.SocketGroup)))
    3.     tileWeights.Weights.RemoveAt(i);
    4.  

    If that doesn't help, the new beta that I'm publishing soon should practically guarantee that a dungeon doesn't fail to generate.
     
  48. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    Version 2.11 (Beta 4) - Download
    Updated: 14th April 2017


    Important Upgrade Notes:
    This is probably the biggest new release since 2.0; there have been some drastic changes in this new version of DunGen; expect bugs. Be sure to back up your project before trying the new beta build. It's best to delete the existing DunGen folder before importing the new one.

    Also note that DunGen is now only packaged with Unity 5.0, instead of both 4.3.3 and 5.0. The code should still work with Unity 4.5+, but from now on I'll only be targeting 5.0+


    Features
    • Added API to DungeonGenerator for registering post-process callbacks: RegisterPostProcessStep() & UnregisterPostProcessStep()
      • Callbacks are invoked during DunGen's Post-Process step in order of phase (before or after built-in post-processing), then priority (highest to lowest)
      • The base NavMeshAdapter class has been changed to use this method to ensure that the NavMesh is build before DunGen reports that the generation is complete when using the OnGenerationStatusChanged event
    • Added an adapter for Unity's new NavMesh system (5.6 beta)
    • Added an adapter for built-in simple culling suitable for use in interior first-person games; works best with auto-closing doors on each doorway
    • Dungeon generation can now be performed asynchronously so as to avoid blocking Unity's main thread, allowing for things like animated loading screens to play while the dungeon is being generated
      • There are some new settings for runtime dungeons to control this behaviour
      • The new "Pause Between Rooms" settings allows you to pause the generation for a number of seconds after a room is placed to visualise the generation process
      • [New in Beta 4] Prop placement and doorway processing is not also done asynchronously
    • [New in Beta 4] Dungeon layouts can now be optionally restricted to a specified AABB (axis-aligned bounding box). Note that enabling this option may increase generation times

    Changes
    • Drastically changed the way DunGen appends tiles internally - it should now generate faster most of the time and practically never fail to generate a dungeon layout, even with the most restrictive constraints
    • Culling adapters now use the same method as NavMesh adapters, they are added as components to the GameObject containing the RuntimeDungeon; moved culling code out of DungeonGenerator class
    • Documentation has been completely re-written to be more modular, easier to follow, and to include features that may have been skipped over in previous versions. The documentation is now front-loaded with information to get started quickly, more advanced topics appear later
    • Improved the inspector for the Doorway component & changed some of the terminology; it should be much easier to understand now
    • The option to use the legacy weighting system has been removed, there was no reason to use it and it's no longer possible with the new generation method anyway
    • Added tooltips to all dungeon generator settings
    • [New in Beta 4] Added tooltips to Archetype settings
    • The dungeon flow editor no longer looks so bad when using Unity's dark skin
    • Code Cleanup
      • Removed experimental GenerateAppended() method. It was never fully supported and never would have been
      • Removed orphaned code for dungeon analysis window. RuntimeAnalyzer has always been the way to analyse dungeon generation
      • Removed code used to generate a main path without allowing backtracking - it wasn't even exposed as an option and allowing backtracking is objectively better
      • Removed visibility code from the base Tile class; visibility should be handled by culling adapters
      • Removed TypeUtil & AnalysisWindow
      • Simplified and refactored a lot of the code in the AddTile method & offloaded some of the code to a separate class

    Bugfixes
    • Fixed an issue with the generation failing due to not finding matching doorways in a tile when using a custom IsMatchingSocket method
    • [New in Beta 2] Disallowing repeated tiles should now work as intended and will now also consider branches
    • [New in Beta 2] Fixed a collision issue when using manually overridden tile bounds
    • [New in Beta 3] Fixed an issue with injected tiles on the main path marked as "required" not appearing occasionally
    • [New in Beta 3] Unused tiles deleted during the generation process should no longer contribute to the NavMesh when generating synchronously


    All the new features should be properly explained in the new documentation.
     
    Last edited: Apr 14, 2017
    antoripa, hopeful and tapawafo like this.
  49. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    621
    The beta build has been updated with some bug fixes (see above).
     
  50. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    Hi !

    Thanks for the solution ! I’ve download the Beta and made some tests :
    -Its work perfectly when I add a new rule in the « special Tile injection »
    -Its doesnt work when I inject tile through code (does the same problem as in my previous post but only when i tried to inject more than one tile)

    I’ve an other probleme : I want to have a precise number of a specific room in my dungeon, but when I add two (or more) rules in « special Tile injection » with « required » check, i dont always have two time the room.

    Thanks for your time.