Search Unity

DunGen - Procedural Dungeon Generation

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

  1. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    40
    Hi, you made the great tool for generating random dongeon!

    But, I found a error on RuntimeAnalyzer like this :

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[DunGen.Tile,DunGen.DungeonGraphNode].get_Item (DunGen.Tile key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    DunGen.DungeonGraph..ctor (DunGen.Dungeon dungeon) (at Assets/DunGen/Code/Graph/DungeonGraph.cs:28)
    DunGen.Dungeon.PostGenerateDungeon (DunGen.DungeonGenerator dungeonGenerator) (at Assets/DunGen/Code/Dungeon.cs:47)
    DunGen.DungeonGenerator.PostProcess () (at Assets/DunGen/Code/DungeonGenerator.cs:920)
    DunGen.DungeonGenerator.InnerGenerate (Boolean isRetry) (at Assets/DunGen/Code/DungeonGenerator.cs:288)
    DunGen.DungeonGenerator.OuterGenerate () (at Assets/DunGen/Code/DungeonGenerator.cs:163)
    DunGen.DungeonGenerator.Generate () (at Assets/DunGen/Code/DungeonGenerator.cs:128)
    DunGen.Editor.RuntimeAnalyzer.Update () (at Assets/DunGen/Code/Analysis/RuntimeAnalyzer.cs:81)

    then, this analyzing didnt gain the %...
    I use Unity5.3.2f1 personal and DunGen 2.8.0
     
  2. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    DunGen is currently in the madness sale. For anyone who's been waiting for a discount, you can get it for 47% off until 4th March.


    I think I've fixed this in an internal build, I'll see if I can get the 2.8.1 beta out in the next day or two.
     
  3. Chrisad

    Chrisad

    Joined:
    Mar 12, 2013
    Posts:
    55
    Hello AegonGames.
    I want to make game with a cave make with multiples floors like this :



    Each floor need to look like this and must be connect with some holes (a room with a hole on it center toward another floor). I have read the limitations of doorways found in the readme file. So if I have understood correctly, this is impossible with DunGen?
     
  4. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The doorway placement shouldn't be an issue (you can place doorways on ceilings and floors) but the multiple connected paths shown in your image would pose a problem. DunGen only handles a linear path from start to goal; it can connect doorways that align by chance but there's no way to guarantee loops in a dungeon layout.
     
  5. Chrisad

    Chrisad

    Joined:
    Mar 12, 2013
    Posts:
    55
    Thanks for the fast answer. I have several others questions (sorry for my poor english)
    1. Not perpendicular corridors woudn't be a problem?
    2. Multiple connected path is very important for my game. Can I modify DunGen (with the source code) to acheive my goal?
     
  6. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    This may not fit with your plans, but the only way I can think of to get circular layouts is to make a circular hallway, or circular set of rooms, as a single DunGen room.
     
    Aegon-Games likes this.
  7. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    There's no restrictions on the size or shape of tiles so long as all of the doorways lie on the axis-aligned bounding box of the tile itself, so it's possible to have organically shaped rooms and corridors.

    OddShapedRooms.png

    As hopeful suggested, it's possible to have looping paths in a dungeon if you build them within the same tile. There's no requirement to stick to a "rooms and corridors" layout; you can make tiles from larger chunks as shown above. Other than that though, it's not possible to guarantee multiple connected paths between tiles. That's just due to the way DunGen works unfortunately - I can't see any way around it.
     
  8. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hi sorry if this has been asked before but searching the forum is tricky. Does the dungeon have a seed, so if more than one person uses the same seed they will get the same result? Thinking of using this for multiplayer :)
     
  9. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    afaik yes :) there is a seed :)
     
    Aegon-Games likes this.
  10. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Yes, you can seed the dungeon if you like. Passing the seed around should result in an identical dungeon layout on all clients.

    I know what you mean about searching the forums; looking back through 700+ posts to find answers can be a pain. I'm looking to maybe set up a dedicated forum or answerhub-style Q&A area for DunGen somewhere so questions can be separated and easily searchable.
     
  11. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Thanks for the info, I took advantage of the sale and bought it :) Also I spotted on the Roadmap better facilities for forums so you might want to look into that to save some potential work
     
  12. KindalD

    KindalD

    Joined:
    Aug 24, 2012
    Posts:
    6
    I have a quick question. When generating a dungeon all is well except for one thing. It does not seem to cap off everything. I have a few rooms that have 4 doors and not all are used. They may just be left with nothing attached to said door. I would expect the behavior to cap the ones it is not branching off of, or the main path doesn't go through. How would I go about making sure this happens?

    Thanks in advance,

    KindalD
     
  13. kerafrymm

    kerafrymm

    Joined:
    Jan 20, 2013
    Posts:
    21
    Sorry if this has been asked before, but searching through unity forums are kind of irritating.

    I was wondering if you could use "rooms" made by sprites tiled in Tiled for use in a 2d game, and if there can be different sized doors, i.e have two open-connected rooms connecting to each other, rather then forcing a doorway to be used

    Thanks,

    Kerafrymm
     
  14. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    DunGen won't make use of all of your doorways. You'll want to place a mesh that blocks the doorway into your tile and use the Doorway component's "Add when NOT in use" list to tell DunGen that you'd like your blocker GameObject to be used in cases where the doorway is not used.

    The section named "Adding/removing doorway-related objects" (page 5) in the readme goes into a little more detail.


    Sprites can be used with DunGen, you just need to change the UpVector in the dungeon settings to (0, 0, -1). You can use doorways of different sizes and create multiple doorway socket groups to ensure they only connect to matching doorways.
     
  15. hubecube_

    hubecube_

    Joined:
    Aug 26, 2012
    Posts:
    18
    Hey, I am trying to figure out how I can move my generated dungeon or have it generate at position / rotation that I specify instead of at origin. I am trying to integrate it with other pieces of an existing level.
     
  16. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    If you're using the DungeonGenerator class directly, you can pass a root GameObject into the constructor.

    If you're using the RuntimeDungeon component you'll need to move the root GameObject after the dungeon has been generated. Something like this:

    Code (CSharp):
    1.  
    2. public class MoveDungeon : MonoBehaviour
    3. {
    4.     public Vector3 NewDungeonPosition;
    5.     public RuntimeDungeon RuntimeDungeon;
    6.  
    7.  
    8.     private void Awake()
    9.     {
    10.         RuntimeDungeon.Generator.OnGenerationStatusChanged += OnDungeonGenerationStatusChanged;
    11.     }
    12.  
    13.     private void OnDungeonGenerationStatusChanged(DungeonGenerator generator, GenerationStatus status)
    14.     {
    15.         if(status == GenerationStatus.Complete)
    16.             generator.Root.transform.position = NewDungeonPosition;
    17.     }
    18. }
    19.  

    In the next version, I'll be sure to add an option to specify the root GameObject in the inspector instead.
     
  17. hubecube_

    hubecube_

    Joined:
    Aug 26, 2012
    Posts:
    18
    This worked beautifully. Thank you for the quick response. ;)
     
  18. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Here's the new beta version. Not much going on right now, it's mostly quality-of-life changes but there's no reason for it not to be made public.

    [NEW] Version 2.8.1 (Beta)
    - Download

    - Change Reverted the ProBuilder support changes made in 2.8.0 - these are no longer necessary
    - Change The Dungeon class now has a Bounds variable which reports the axis-aligned bounding box of the entire dungeon layout
    - Bugfix Fixed an error in the runtime analyser
    - Change A root GameObject can now be chosen when using the RuntimeDungeon component. If none is specified, it will default to the old behaviour of creating a new root named "Dungeon"
     
    hopeful likes this.
  19. closetgeekshow

    closetgeekshow

    Joined:
    Jun 6, 2014
    Posts:
    125
    i was wondering if it's possible to the random prop placement features without the rest of the system. Could I use dungen to fill rooms with without generating the rooms first?
     
  20. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    335
    Hello,

    what is plan for next release ?

    +++
     
  21. S4G4N

    S4G4N

    Joined:
    Mar 13, 2013
    Posts:
    3,215
    Hi,

    Just to let all DUNGEN package owners know that the Village Interiors Kit that has been used to showcase DUNGEN on some of the it's Web DEMOS as well as the excellent Video is currently also on a -33% SALE as well as it's companion package the Village Exteriors Kit.

    Feedback from the developer at the time of testing was that it works very well with DUNGEN

    Cheers
    Cobus
     
    Aegon-Games and hopeful like this.
  22. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Maybe but it would take some reworking. Also, to avoid any confusion, the random prop features don't place objects in the rooms; props are manually placed, the prop scripts just determine which of the props are active at random (based on some weighting).


    The beta that I posted yesterday will likely go for another week or so while I collect any bugfixes and changes, then I'll submit it to the asset store. It's not going to be a very big release.
     
    hopeful likes this.
  23. peanutgallery

    peanutgallery

    Joined:
    Oct 5, 2013
    Posts:
    35
    Hi there!

    I've been looking closely at this asset, I had no idea it existed before the Madness sale but it looks really great. The game I'm making has sections where it's meant to be a somewhat linear "roguelike" kind of experience, and this tool looks like it fits the bill nicely.

    Question time!
    - When it comes to local props, can I prevent props from being populated in the same space? For instance, let's say I design a room with curtains. Sometimes they're red curtains, sometimes they're blue, and sometimes they're green. However, the curtains are always in the same place -- but in each room, I only want one of them to spawn. Can I place them all in the same place in the same room and not have to worry about them appearing all together, i.e. if a red curtain appears then a blue or green curtain won't appear, and so on? Is that what the "Prop Sets" are used for? Following that, I imagine a tile can have multiple local prop sets in order to increase the number of total combinations?

    If I'm understanding right, my guess is I would:
    1. Create a "Curtain" empty game object and place in the room.
    2. Attach the Local Prop Set script to it.
    3. Set the count to 1-1 so only one spawns.
    4. Click the "Add New Prop" button to make three slots.
    5. Drag and drop the red curtain, the blue curtain, and the green curtain into the three slots.
    6. (optional) set the weights so that red curtains show up most of the time but blue and green show up rarely.

    Is that accurate?


    - Can you explain more specifically what you mean by nested Prefabs not working? Does this mean that our Tile GameObject can have a bunch of prefabs nested under the GameObject itself, but if we wanted to parent a "Lightbulb" prefab to a "Lamp" prefab that wouldn't work. We'd need to create a "Lamp With Lightbulb" and "Lamp Without Lightbulb" prefab and treat them separately? (Or use some third-party workaround as mentioned in the PDF?) I just wanted to be clear on this. I know it's not DunGen specific but a Unity issue.
     
  24. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Your understanding of the local prop set is spot on. Possibly a better option for this use case though would be the Random Prefab prop which you can attach to an empty GameObject, the prefab prop would then pick one of the specified prefabs at random and place it at the GameObject's position. This would just save you from having to put down three sets of curtains every time.


    Regarding the nested prefab problem: There's no issue with placing prefabs inside other prefabs. The problem is that any prefab nested inside another doesn't receive changes made to the prefab itself. Using your example: say later in development you want to change the colour of all instances of the lighbulb, the bulb inside your lamp prefab won't receive that update since it's nested inside another prefab.

    In DunGen this is especially important since each tile is a prefab, meaning any prefab instances you use inside your tiles will suffer from this problem. Hopefully Unity will fix it soon but it's on their roadmap under "In-progress, timelines long or uncertain".
     
    peanutgallery likes this.
  25. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277

    in the meantime you could use
    https://www.assetstore.unity3d.com/en/#!/content/17557

    but be forewarned with larger projects the dependency checks of this asset can become quite timeconsuming

    nested prefab support from unity is feature that is listed since ages under upcoming ^^ i would not get my hopes up for a fast solution
     
    peanutgallery likes this.
  26. abDev

    abDev

    Joined:
    Feb 10, 2014
    Posts:
    5
    Greetings,
    I have a couple of questions:
    - do a given dungen's seed always generate the same props/global props?
    - if no, is there a seed like var to generate the same props/global props?

    tyvm
     
  27. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The same seed will always generate the same props.
     
  28. bigd

    bigd

    Joined:
    Feb 14, 2014
    Posts:
    40
    Hi there,

    Looking into this asset now that it's on sale. I've seen a couple early posts on this but haven't seen anything recently addressing this problem. What's the latest on AI navigation? Has anyone figured out how to integrate this with astar?
     
  29. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    havent played toooooo much with it
    but integrating should be really no problem

    you can just get the dungen coordinates and then use recast graph box
    and its done ^^
     
  30. peanutgallery

    peanutgallery

    Joined:
    Oct 5, 2013
    Posts:
    35
    Thanks for the timely and informative response, AegonGames!

    Yeah, I know they've kicked that can down the road for quite a while now :) Thanks for the link to that asset, it could help in the short term.
     
  31. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I've already generated a NavMesh for RAIN without issue; it's unlikely other assets will cause much trouble. I picked up A* Pathfinding Project Pro during the sale with the intention of putting together either a sample or out-of-the-box integration for both assets (similar to how DunGen works with SECTR VIS). Now I just need some time to work on it ;)
     
    Tinjaw, bigd and hopeful like this.
  32. bigd

    bigd

    Joined:
    Feb 14, 2014
    Posts:
    40
    Thanks guys, makes sense!

    @AegonGames One more question for you, I have a requirement to have the same starting and end location within the scene, can I do that with this tool? For example, the player needs to start at 0,0,0 and end at 0,100,0, would this system be able to generate a dungeon between these two points?
     
  33. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Hi @AegonGames I'm thinking of buying DunGen, what I'd like to know would it build with THIS and THIS?

    Including levels?

    Thanks.
     
  34. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Unfortunately it's not possible to have DunGen generate a path between two points due to the way the algorithm works. If it were as simple as your example (only changing along one axis) and you were willing to sacrifice using more interesting layout shapes, you can use rooms of the same size, have all of the doorways centred along the same axis and set the dungeon length to a specific value needed to reach your goal.

    Since I did an awful job explaining that, here's a picture (top-down view):

    LinearPathTarget.png

    In the example above:
    • All rooms are 10 units long (width and height are irrelevant)
    • The start tile is not allowed to rotate - resulting in the only doorway facing down +X
    • Doorways are always on the same axis and are centred
    • The dungeon length is set to 11

    This lets you hit your target but for most people it probably won't be worth the loss of a more interestingly shaped layout. There's no other way of doing it in DunGen I'm afraid.


    Almost any art assets should work, especially packs that are modular and snap to a grid. Looking at the description of the asset you linked, I can't see any reason why it wouldn't work.

    The only restriction on placing objects with DunGen is that the doorway needs to be on the edge of the room's axis-aligned bounding box. If the doorways aren't facing down one of the axes, it won't work; if any mesh overhangs beyond the doorway, there may be some intersection between tiles.
     
  35. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Thanks for the info ..
     
  36. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    any way too make loop ? end close range to start
     
  37. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    No, sorry. It's just not possible with the way DunGen works.
     
  38. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    12
    Some question about Global prop.
    I added random prop component in dungeon tiles prefab.
    and each prop prefab has global prop component and global Id. (some prefabs has same global id)

    then I set dungeon flow's global prob entity.

    first above all, did i do right?

    Does global prop. set same position? (in my case, I guessed always center)
    and, Can I change global prop's rotation and size? (I set prefab(rotation 270, 0, 0) but ,in game, rotation 0, 0, 0)
     
  39. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sounds right to me.

    The global prop component doesn't change position/rotation but it sounds like you're using it alongside the random prefab prop component, which does. You can change this by removing this line of code in "DunGen/Code/RandomPrefab.cs" on line 26:

    Code (CSharp):
    1. newProp.transform.localRotation = Quaternion.identity;

    I'll be making a change in the next beta build so that you can pick whether or not you want DunGen to zero-out prefabs' positions and rotations.
     
  40. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    12
    Thanks.

    Can I do set trap-switch prop like key-door prob relation?

    I want to set trap in random dungeon, the trap has switch(it's option).
    If trap has switch then switch prop must set in dungeon.
     
  41. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The lock & key system isn't really a general-purpose solution. I suppose you could make it work with trap placement as long as you only want traps to appear in doorways. The doors & keys placed are only prefabs so they can be anything you want really, but the placement of doors is always restricted to doorways.
     
  42. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    The madness sale ends in less than 2 hours so now is the last chance to get DunGen and other assets at half-price for anyone who's still wanting to get it on sale. The sale ends at 9:00 EST (14:00 GMT)

    EDIT: Sale is over now
     
    Last edited: Mar 4, 2016
  43. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I did it again. I added new functionality to what was supposed to be a bugfix-only release; so 2.8.1 beta is now 2.9.0 beta.

    Version 2.9.0 (Beta) - Download
    - Change Reverted the ProBuilder support changes made in 2.8.0 - these are no longer necessary
    - Change The Dungeon class now has a Bounds variable which reports the axis-aligned bounding box of the entire dungeon layout
    - Bugfix Fixed an error in the runtime analyser
    - Change A root GameObject can now be chosen when using the RuntimeDungeon component. If none is specified, it will default to the old behaviour of creating a new root named "Dungeon"

    * NEW *
    - Change RandomPrefab props now have options for keeping the spawned prefab's position or rotation as an offset. Previously, spawned prefabs always snapped into position and ignored the prefab's transform (this is still the default behaviour)
    - Feature Added integration for generating navigation meshes with both RAIN and A* Pathfinding Project Pro
    - Change The utility function UnityUtil.CalculateObjectBounds() now ignores trigger colliders by default. Room bounds should no longer encompass any trigger colliders
    - Bugfix Fixed errors when using custom doorway socket connection logic


    The most notable new addition is the integration with RAIN and A* Pathfinding Project Pro for NavMesh generation. The documentation included in the package has some instructions on how to get the integration set up (the online documentation won't be updated until 2.9 is released).

    Right now, both integrations handle automatically generating a NavMesh when the dungeon is generated through a RuntimeDungeon component. The A* Pathfinding Project Pro integration additionally supports changing tags on the NavMesh under doors when they open & close to allow AI to path through open doorways. I'm still looking into a way to do this with RAIN.
     
    Last edited: Mar 7, 2016
    Tinjaw, hopeful and Arganth like this.
  44. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    just amazing :D exactly what i needed (a* part :))
     
    Tinjaw likes this.
  45. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    12
    Is it possible that some tile has a locked door (always) and I want to place the door's key in dungeon(or monster, chest) by random.
    I tried to add this room as node in Dungeon flow, this room has one doorway, but dungen failed to make dungeon.

    I don't know that room's node make to fail to make dungeon but It was fine without adding that node.
     
  46. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    12
    In case of Special tile Injection, Can I use multi tileSet with Is Required option?

    I set 2 special tile injection and the option of one is "Is Required(check)" & "Can appear on Branch Path?(check)" and other is "Is Required(check)" & "Can appear on Main Path?"

    and click the play button then unity do not response.
     
  47. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    Is it normal that i get very strange Z (and X) values when generating ?



    Also, rotation of doorways 90° ends up to -89.98019

    Any idea ?
     
  48. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    12
    I'm using SECTR VIS for Dynamic Occlusion Culling.

    When the camera pass through the doorway, game screen flicker.

    is any solution to avoid this?
     
  49. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Sorry for the late reply; it's been a busy month and I forgot to check the forum thread :oops:

    The boss room in the demo scene does just that. You'll want to make sure your room node has a lock assigned to it and that the lock placement mode is set to "Entrance". Then assign the corresponding key to one of the line-segments in you dungeon flow graph.

    DunGen will fail if you use a room with only one doorway since it can't continue to the end of the dungeon (the only exceptions are the start and goal tiles).


    You should be able to use as many required TileSets as you like with the special tile injection system. I tried to reproduce the issue you're having by copying the setup you described but it works fine for me.


    That's normal (and actually unavoidable). If you put a cube down in Unity and try to rotate it 90° (while holding Ctrl for snapping), you'll end up with something like 89.999 instead of 90.0

    The difference between the number you get and the one you expected should be so small as to not be noticeable so you can safely ignore it as something that "just happens".


    If you're interested in the reason, it's because certain numbers can't be accurately represented in binary (like 0.1) just like how there are certain numbers we can't represent in decimal (such as 1/3). All of these small rounding errors add up every time we perform some maths on the numbers resulting in a bigger (albeit still really small) error in the end.


    I'm not sure about this, I'll look into it. I haven't done extensive testing, but I did make use of SECTR VIS for the keep demo and didn't notice any flickering.
     
  50. gammaker

    gammaker

    Joined:
    Feb 8, 2014
    Posts:
    12
    First above all, Thanks for your supporting.
    I have additional questions

    According to your answer, Can't I use one way tile except goal/start tiles? also cap tiles?
    I want to use this locked tile as cap tiles. cap tiles have one way door too.

    Okay. I will try again. As I say more information, I used tiles (one has 2 door ways, others has one door ways.)
    But when I used one door way tile as injection tile, That didn't occur any problem.

    I asked SECTVR Forum too. And I received below answer:

    "That usually happens if there is a gap between the sectors. You can try adding a Member to your camera and setting portal determined to true, but probably you need to ask the dun gen team to look into the bug.
    "
    I already checked true "portal determined" but same thing happened.

    your asset is so helpful to me. :)