Search Unity

DunGen - Procedural Dungeon Generation

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

  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Unity version is 4.6.9f1

    Using Dungen in runtime.

    The latest 2.7.0 beta

    With extensive testing, I have observed following.

    ArgumentOutOfRangeException
    This sometimes gets fixed, if I open the flow asset again using the flow editor... maybe it is filling in the missing info ... perhaps the flow asset gets messed up somehow when duplicating in the project view.. As to what has caused this, I have no idea.. All I did was duplicate the flow asset and then re-linked the necessary stuffs back with other archetype etc.. maybe it has got to do with flow asset created with older version of Dungen and then after updating to 2.7.0 the flow asset needed to be refreshed using the newer flow editor?

    KeyNotFoundException.
    This one I could get away with by commenting out the postprocessdungeon ...

    Door prefabs not getting removed for second time run.
    This one I was able to solve by adding
    foreach (var tile in doors)
    UnityUtil.Destroy(tile);
    to the Clear function.

    And as for the weighting of the tiles in the tile set and then using combination of different tilesets..

    Well.. I don't know if others are fine with this, but it is a bit of puzzler.. because the reason why I would want to use different tilesets is to organize them so I can mix and match the final tiles that I want to use.. But if I don't have any control over which tileset the Dungen is going to use next, and weight only plays within the tileset, then it is pretty much very limited and forces me to put everything in one tileset and do my weighting there... I think it makes much more sense to give us some control over the choice of tilesets or make the weight work across the different tilesets. (Load all the tilesets first and then choose)
     
  2. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Here's a screen shot of something I'm working on. It's a runtime generated Dungen using A* Pathfinding Project with characters driven by Behavior Designer. I'm using SECTR VIS for visibility. I'm hoping to turn it into an infinite stealth mobile game.

    Can't really tell from the picture but the sliding doors open and close for the player and AI.

    Dungen is really nice to work with. It's simple to learn and seems to be rock solid.

    Screen Shot 2015-11-26 at 9.12.43 AM.png
     
    montyfi, BackwoodsGaming and hopeful like this.
  3. mserry

    mserry

    Joined:
    Nov 22, 2015
    Posts:
    5
    Hello,

    I am currently getting this error on every single generation after using tiles that all have 2 door ways and 2 tiles with 4. and i am using DunGen Version 2.6.0

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[DunGen.Doorway].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    DunGen.DungeonGenerator.AddTile (DunGen.Tile attachTo, IList`1 useableTileSets, Single normalizedDepth, DunGen.DungeonArchetype archetype, Boolean isRetry) (at Assets/DunGen/Code/DungeonGenerator.cs:694)
    DunGen.DungeonGenerator.GenerateMainPath () (at Assets/DunGen/Code/DungeonGenerator.cs:447)
    DunGen.DungeonGenerator.InnerGenerate (Boolean isRetry) (at Assets/DunGen/Code/DungeonGenerator.cs:265)
    DunGen.DungeonGenerator.OuterGenerate () (at Assets/DunGen/Code/DungeonGenerator.cs:165)
    DunGen.DungeonGenerator.Generate () (at Assets/DunGen/Code/DungeonGenerator.cs:122)
    DunGen.RuntimeDungeon.Awake () (at Assets/DunGen/Code/RuntimeDungeon.cs:19)

    I've encountered this error occasionally but now it's completely stoping me from generating any dungeons. any pointers would be helpful :)
     
    Last edited: Nov 28, 2015
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    yeah.. exactly.. been reporting this.. but very slow support here..
     
  5. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I've spent hours trying to reproduce these errors. The only way I could reproduce the ArugmentOutOfRangeException was to disable a GameObject with a Doorway component on it. I can't imagine why anyone would be disabling a doorway's GameObject so I'm not sure it's going to fix your problem but it's the only thing I could change to get that error message. The new build uses Doorways regardless of whether they're active or not.

    I've been trying to reproduce the other exception but no luck so far. I've tried every combination of duplicating Dungeon Flows and upgrading/downgrading DunGen and I just can't get it to break with any of the versions of Unity I have (4.3.3, 4.6.9f1, 5.0 and 5.2.1f1). I can't think of a reason this kind of error would be happening.

    As of 2.7.0, door prefabs are parented to the dungeon root object and are destroyed in the Dungeon class Clear() function so you shouldn't be seeing them hanging around.

    Archetypes probably should combine the weights from all TileSets instead of the current behaviour - I'll see if I can get this changed for 2.8


    Version 2.7.1 (Beta)
    - Download

    - Change There's now an experimental option to not pre-load all tiles before generating a dungeon layout
    - Bugfix DunGen will no longer throw an ArgumentOutOfRangeException if a GameObject containing a Doorway component is disabled
     
    hopeful likes this.
  6. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi

    I just wondered whether there are any plans to automatically do a mesh combine upon generating the dungeons, as I'm thinking this may provide a performance improvement?

    cheers

    Nalin
     
  7. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    If you add SECTR VIS, it makes all the doors portals and does a great job of culling and there isn't any need to do a mesh combine.

    Here is an example. I don't have anything that outputs stats in the player but when I run this in the editor the draw calls are around 4-25 and the number of polys is in the hundreds. It's much higher without SECTR VIS.

    https://dl.dropboxusercontent.com/u/496463/SPY/index.html
     
    hopeful likes this.
  8. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Aegon, When do you think we can expect the chances of tile in tiles are considered across all the tiles in the archetype etc..

    Having different tile set if great because we can organize things and be clever with them, but it is of no good if a tile set is randomly chosen first and then the tile within the that chosen tile set is randomly chosen based on their weight.

    The all tiles in all tile sets must be considered as if they are from one pool to be useful. Otherwise I will have to put everything in one tileset and can't really have different tileset and mix them together to create something interesting.

    This needs to be addressed really soon. Please.!
     
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    And that includes, Tile sets in the Archetype and the Branch Cap tile sets as well.

    The normal tilesets for the archetype can be considered on their own together and then the branch cap tile sets needs to be considered together. (Because end cap sets can't be in the middle of the main path)
     
  10. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    @kenlem thanks for this

    Unfortunately I don't have SECTR VIS so I just wondered whether a mesh combine would work / be possible
     
  11. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I strongly doubt such a thing would be provided as part of this kit, though if you need it you could apply your own.

    So far as I can tell, using VIS or IOC for dynamic occlusion is going to be a better solution, unless you've got a situation where most or all of the dungeon layout will be visible at a glance. In that case, running a mesh combiner at runtime is one way to go, and maybe you could use a plugin like Mesh Baker. Another way to create efficiency might be to design larger, more complicated rooms, so that each complex room mesh is like a pre-combination of several smaller room meshes.
     
  12. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    Weird I just came here to post about SECTR. I have everything working pretty nicely, the SECTR works pretty great. however I have issues with the lights and such. an example light is structured like this:

    GameObject
    ParticleSystem
    PointLight
    Model


    Now I put a SECTR_Member on the GameObject and it is supposed to deal with everything no? What happens is you do not see the object at all. Its the same with local props. I have like broken walls etc when I put a SECTR_Member on them they are invisible.

    Do I have to define a sector on the prefab tiles then assign props etc to it? Other than that it works great.
     
  13. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    I get an Error when I go to build a player from SECTR-VIS. its in the class SECTRPortalCullingAdapter, the OnInspectorGUI method. I have to comment out every line. the error is:
    Code (CSharp):
    1. Assets/DunGen/Integration/SECTR_VIS/SECTRPortalCullingAdapter.cs(77,60): error CS0103: The name `UnityEditor' does not exist in the current context
    I get an error for each line of the method.
     
  14. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    @bigdaddio - If you resolve any of these problems with SECTR, please let us know how to do it. I'm not currently using SECTR and DunGen together, but I plan to.
     
    BackwoodsGaming likes this.
  15. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,229
    Ditto... That is my plan as well.. Once I get to the point of producing my dungeons, sewers, crypts, and caves/caverns. Still working on individual above ground stuff at the moment and haven't reintegrated sectr into my project yet.
     
  16. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    Hey, whats the best lightning setup to work with dungen?

    only realtime lights? mixed? only baked?

    if heard/read of so many problems considering unitys baking system
    i am not sure which to use with procedural dungeons

    any tips?

    my plan would be to only use realtime GI
    and no baked lightning
     
  17. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    Yea you cannot bake, not using Unity baking. However I have run experiments with 8+ lights per room and it will still run on Intel 4000. I am not so much targeting that as minimum, but I have one here to try and it was interesting. I think the only place where RT lighting may be an issue is mobile. There is not much info on SECTR either from Make Code Now or Aegon. The Dungen docs say just works... in SECTR docs nothing. I can get it to go south pretty easily. Especially since I also use UFPS controller.

    I want to know what things like Cull Each Child do other than really screw it up.
     
  18. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    thx that I cannot bake was also my impression BUT
    if you look here
    http://forum.unity3d.com/threads/problems-with-instantiating-baked-prefabs.324514/

    in #6 one unity guy posts a script to store lightmaps in prefabs
    (I dont fully understand the whole thread but it should work for DunGen)
     
  19. AlexSledge

    AlexSledge

    Joined:
    Nov 13, 2013
    Posts:
    17
    With all the talk of SECTR VIS I took this opportunity to see what could be done with the Keep Demo and the latest beta & SECTR bits.

    Using Unity 5.3.0f4 I imported the current 2.7.1 DunGen beta, the SECTR VIS integration sub package from the DunGen beta, the SECTR VIS component from SECTR Complete, the current Village Interiors Kit, and finally the Keep Demo which Aegon provided earlier.

    In the hierarchy view I selected the Player Camera, added the SECTR Culling Camera component and checked Simple Culling in the inspector. I then selected the Generator, and in the inspector selected SECTR VIS as the portal culling method, and checked that it was enabled.

    Gave it a go and everything seems to work fine.

    However, on one of the first runs I did hit this code in DunGen.Adapters.SECTRPortalCullingAdapter line 25 Aegon:

    Debug.LogError("[DunGen] No SECTR_Portal component is assigned to this doorway (" + door.gameObject.name + "). This shouldn't happen.");

    I didn't think much of it as I was just starting testing, and it hasn't happened again yet. However, as it should "never" happen, I thought you'd might want to know to investigate.
     
    hopeful, Arganth and BackwoodsGaming like this.
  20. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    Wow that is interesting I will have to try it. One of the issues is that the tile rortates, I would think if you bake in outside lighting you would have to stop rotating.
     
  21. AlexSledge

    AlexSledge

    Joined:
    Nov 13, 2013
    Posts:
    17
    Not the best solution, but you could just provide your own four compass rotated versions of the room pre-baked, and don't have DunGen rotate them. Larger content footprint is the downside, though outside of mobile you can still be a bit space sloppy.
     
  22. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    It is space sloppy as you put it, the lightmaps use about 20% if that of the map that you need to include. After about an hour of playing with it I quit. If you really NEED lightmapped stuff I guess its something to look at. With SECTR I never get more than a few dozen or so lights anyway and even Intel 4000 graphics can handle it.
     
    hopeful likes this.
  23. sk1zZ

    sk1zZ

    Joined:
    Mar 30, 2015
    Posts:
    9
    How to solve problem with rotation 2D tile?
    I have added a component Tile to Prefab and set Allow Rotation = false. Also makes in Gloval Overrides. Nothing helped.
    SOLVED.
    It's all about in rotation of door. Because of 2D mode is not visible how they fit together.
     
    Last edited: Dec 27, 2015
  24. TheOz

    TheOz

    Joined:
    May 21, 2011
    Posts:
    34
    Hi, I have a question for the group.

    I am using DunGen for level generation in our game SpaceJoe. The challenge I have is that when the player moves from room to room I only wish to show the room he is in on the screen. so the rooms are attached via the doors but I don't wish to have the rooms married up against each other. The doors on each room will act like a teleport to to the next room on the level as defined by DunGens dungeon generator. The camera will face the current room on a side that has been cut away. Here is an example of a room with the camera angle.

    SpaceJoe in New World.gif

    Anyone have a working way to do this using DunGen?


    Garry@crazybeardentertainment.com
     
  25. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Time for a new beta build. Version 2.7.1 is now 2.8.0 due to some underlying changes to the weighting system.


    Version 2.8.0 (Beta)
    - Download

    - Bugfix DunGen will no longer throw an ArgumentOutOfRangeException if a GameObject containing a Doorway component is disabled

    * New *
    - Change Tiles will now maintain their proper weights across multiple TileSets. The old behavior can be reactivated using the "Use Legacy Weighting" option in the dungeon generator settings
    - Bugfix Fixed an error when trying to build a project with SECTR integration
    - Bugfix Fixed a stack overflow exception that occurred when no Tile matched the requirements for the next room in the layout
    - Bugfix The scale of Tile prefabs will no longer be reset before being placed by the generator


    Here's a visual example of how the weighting system differs from before, using a layout with one Archetype which contains two TileSets:
    WeightingExample.png



    I didn't think I'd miss so many messages over the holidays. Anyway, I'll try to answer everything here - if I miss anything, please let me know.


    I've tampered with automatic mesh combining for DunGen a little in the past but I wasn't able to get any good results. I don't think it's something that'll make it in as an out-of-the-box solution, sorry. In terms of performance gains for large dungeon layouts, portal culling can't be beat if you're working on an interior environment. hopeful's suggestion for using larger, multi-room chunks that have been combined in-editor is a pretty good alternative for reducing draw calls though.


    The new beta build should do exactly what you're wanting. I haven't done extensive testing, but it should be working in any instance in which DunGen needs to pick a Tile from multiple TileSets.


    That's strange. I copied your structure but didn't run into any issues. Without the SECTR_Member, the light is culled as normal (when you can't see into the room that contains it); with the SECTR_Member, it becomes visible even when not looking through the portal to it's room as long as your view-frustum intersects the object's boundaries.


    Thanks, I'll have to look into that at some point. I've never run into that error myself but as stated, it should never happen.


    You could hide all of the rooms at the start and then when your player interacts with a door to move on to another room, teleport them and toggle the visibility.

    You'll need a DungenCharacter script attached to your player for information about which Tile you're in. You'll also want a script to hide all rooms when the generation is complete; something like this:

    Code (CSharp):
    1. public class HideRoomsOnStart : MonoBehaviour
    2. {
    3.     private void Awake()
    4.     {
    5.         // Listen for generation status events so we're notified when the dungeon is complete
    6.         var dungeonGenerator = FindObjectOfType<RuntimeDungeon>().Generator;
    7.         dungeonGenerator.OnGenerationStatusChanged += OnDungeonGenerationStatusChanged;
    8.     }
    9.  
    10.     private void OnDungeonGenerationStatusChanged(DungeonGenerator generator, GenerationStatus status)
    11.     {
    12.         // When the dungeon generation is finished, hide all Tiles
    13.         if (status == GenerationStatus.Complete)
    14.         {
    15.             foreach (var tile in generator.CurrentDungeon.AllTiles)
    16.                 tile.Hide();
    17.  
    18.             generator.CurrentDungeon.MainPathTiles[0].Show();
    19.         }
    20.     }
    21. }
    And finally, you'll want a door prefab (assigned through the Doorway component) with the script to take you to the next room. This script does so when the player walks into a trigger that's attached to the door:

    Code (CSharp):
    1. public class TransitionDoor : MonoBehaviour
    2. {
    3.     private void OnTriggerEnter(Collider other)
    4.     {
    5.         // Get some references to the colliding player and the door we just hit
    6.         var playerCharacter = other.transform.GetComponent<DungenCharacter>();
    7.         var door = GetComponent<Door>();
    8.  
    9.         if (playerCharacter == null || door == null)
    10.             return;
    11.  
    12.         // Find the doorway which belongs to the adjacent room we want to travel to
    13.         Doorway adjacentDoorway = (door.TileA == playerCharacter.CurrentTile) ? door.DoorwayB : door.DoorwayA;
    14.  
    15.         // Hide our previous room and show the new one
    16.         playerCharacter.CurrentTile.Hide();
    17.         adjacentDoorway.Tile.Show();
    18.  
    19.         // Teleport the player 1 Unity unit infront of the door on the other side
    20.         const float offset = 1;
    21.         playerCharacter.transform.position = adjacentDoorway.transform.position - adjacentDoorway.transform.forward * offset;
    22.         playerCharacter.transform.rotation = adjacentDoorway.transform.rotation;
    23.     }
    24. }
    The Show() and Hide() functions of the Tile class basically just set the visibility of every Renderer component in the room so you might want to use your own logic for setting visibility if that doesn't suit your needs.
     
    Last edited: Jan 8, 2016
    montyfi, BackwoodsGaming and hopeful like this.
  26. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi

    I'm seeing some weird scaling problems on 2.8 beta. If I set the scale of a tile / prefab to 0.1, after instantiation Dungen sets the scale of the prefabs to 1.0 prior to instantiating the dungeon - meaning everything is much bigger than expected.

    Is this correct?

    thanks

    Nalin
     
  27. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    have the same problem the other way around
    ^^ dungen seems to always scale it back to 1
     
  28. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    That's what I meant - it always resets the scale to 1.0
     
  29. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    cant test it right now but what could work
    is if you put the whole "tile" into an another gameobject

    then you should be able to scale the tile without dungen resetting it
     
  30. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Nice one on new weight system!

    Does it also work with the end cap room types? I am talking about the one that I can add for the end of branch "instead of".
     
  31. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    335
    Hello,

    is possible to edit first post about limitations ?

    +++
     
  32. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Thanks, this should be fixed now if you re-download the 2.8 beta.


    It does, yeah.


    I assume you mean the broken link? It's fixed now, thanks.
     
    hopeful likes this.
  33. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi

    I redownloaded the Beta, however now it seems to rescale the blockers to 1,1,1

    cheers

    Nalin
     
  34. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I can't seem to down load beta, when I enter my invoice number it just gives http 500 error
     
  35. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Hmm, I'm not seeing this. You mean you've scaled up/down the blocker GameObjects and DunGen is resetting their scale?


    Sorry about that. It should work now.
     
  36. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    Is there really no (practical) way to use precomputed GI with DunGen or procedural generation in general?

    I am considering this:
    Global Illumination Proxy
    https://www.assetstore.unity3d.com/en/#!/content/21197

    to have better lighting with procedural levels

    any alternatives?
     
  37. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    I finally got around to giving ProBuilder a look and have found the issue which was causing prefabs made with it to not work properly with DunGen. ProBuilder objects don't have a mesh until they're instantiated in the scene which meant that the proxy objects generated by DunGen didn't have a valid bounding box and resulted in intersecting tiles.

    I'm manually calculating bounding boxes from pb_Object vertices using reflection to detect whether there are any ProBuilder objects in the tile; so tiles built with ProBuilder should now just work. I haven't testing this extensively, nor have I testing it in Unity 4 yet but I don't see why it wouldn't work.


    Version 2.8.0 (Beta)
    - Download

    - Bugfix DunGen will no longer throw an ArgumentOutOfRangeException if a GameObject containing a Doorway component is disabled
    - Change Tiles will now maintain their proper weights across multiple TileSets. The old behavior can be reactivated using the "Use Legacy Weighting" option in the dungeon generator settings
    - Bugfix Fixed an error when trying to build a project with SECTR integration
    - Bugfix Fixed a stack overflow exception that occurred when no Tile matched the requirements for the next room in the layout
    - Bugfix The scale of Tile prefabs will no longer be reset before being placed by the generator

    * New *
    - Feature DunGen now supports tiles made with ProBuilder





    Not as I understand it. Someone from Unity here has said that in the future it might be possible to bake GI on a per-prefab basis - something like that would be ideal for use with DunGen but I haven't been able to find any news on it since. Fully dynamic GI really is the only way to go for procedural content I think - which is unfortunate since it'll likely result in worse quality and performance than using Enlighten.

    We're working on a procedurally generated game ourselves at the moment and really haven't found that any of the big general-purpose game engines deal with procedural content gracefully, especially where lighting is concerned.
     
    hopeful likes this.
  38. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    there are two ways right now
    the first one is from this thread:
    http://forum.unity3d.com/threads/problems-with-instantiating-baked-prefabs.324514/

    but this only works for non-rotating tiles and only non-directional light
    and it does also not work in Unity 5.3
    so for low-fi mobile games it might be an option

    the other one is this:
    https://www.assetstore.unity3d.com/en/#!/content/21197

    got this just before, has a ton of (right now undocumented) customisation options
    but creator is working on it
    http://forum.unity3d.com/threads/re...bile-optimized-ibl.261453/page-9#post-2458758



    fps is higher normally (ssrr pro takes sooo much power ^^)

    its not perfect but its not like we have much choice right now ^^
     
  39. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    So ... I saw in the notes that the latest version of ProBuilder (released today) no longer requires special treatment when meshes are instantiated.

    Anyone using ProBuilder with DunGen able to verify that it works without tweaks now?
     
  40. Mithion

    Mithion

    Joined:
    Dec 12, 2013
    Posts:
    14
    I've just started using DunGen and so far I'm extremely impressed - I just had a couple of questions.

    First, is it possible to generate a dungeon asynchronously? If so, where in the documentation can I find it? My initial impression is that the answer is no, due to the fact that Unity API methods are not thread-safe, and I believe this system uses them. However, if anyone knows otherwise, I would love to hear about it.

    Second, is there a function that will give me the total bounds of the generated dungeon? I can't for the life of me find it right now. If I have to write my own that's fine, but I'd rather not reinvent the wheel if I don't have to.
     
  41. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    Hi!
    I just have one question that seems simple, but what do I know?
    Is there a way that I can have a set of tiles that always generate but just in a different layout?
    For example, I have 7 tiles. They consist of a starting room and some rooms. I want to generate all these 7 tiles once and that's it. This would then result in the layout being different every time but the same rooms would still exist.
     
  42. AlexSledge

    AlexSledge

    Joined:
    Nov 13, 2013
    Posts:
    17
    @Mithion There was some discussion earlier in this thread I believe where there was talk about getting the overall bounds of the generated dungen dungeon - if you can't find it I'll see if I can track it down.

    @RealMTG It's not really designed for that, and I believe you'll need to tweak some code - I'd imagine considering the 7 tiles "unique" and only allowing them to be used once the way start/end rooms are might get you there, but I don't think the weighting system in place now (at least what I see in the doc) will get you what you are looking for.

    @Aegon The readme on the AegonGames site is still for the older 2.5.3 (or marked that) from what I see.

    @hopeful/Aegon With 2.8.0 beta making changes for Pro Builder to "work right", I'm assuming that with the newer ProBuilder finally fixing things their side, that now Aegon needs to undo the special treatment of Pro Builder bits by DunGen for them both to play nice.
     
  43. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I doubt any changes made by Aegon would adversely affect things, but it would be good to know for sure.

    The timing on this was odd - the two updates happening at about the same time - so I didn't know what exactly changed.

    Did ProBuilder purposefully make the change to enable their meshes to be used in DunGen? And that's why they should work now?

    Or did Aegon make a change in DunGen to accept ProBuilder meshes that are still in a ProBuilder state? That would be fine too, although a bit funny that this long-ago asked for feature should appear at the exact moment it is no longer needed. ;)

    And then the most important question: does this mean it is working for people now, with either form of ProBuilder meshes?

    I'm not actively building dungeons at the moment, but I may get into that in a few weeks, and it would be good to have a confirmation, if possible.

    BTW, it occurs to me to mention that if Aegon did add code to help DunGen accept ProBuilder objects, and if it is working fine without impinging upon anything else, I'd leave that in. It will probably provide extra flexibility for developing assets, in that you can build rooms in ProBuilder, test them in DunGen, and make changes as needed very easily.
     
  44. Mithion

    Mithion

    Joined:
    Dec 12, 2013
    Posts:
    14
    Yep, you're absolutely right - I found it. Apologies for that, guess I didn't look hard enough the first time around.
    Thanks for the assist!
     
  45. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    If it is difficult to find ... maybe post a note about how to do it? Shouldn't hurt to have it shown twice in this thread. :)
     
  46. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Unity provides the functionality here, you can aggregate the bounds by looping through all the room mesh renderers and using bounds.Encapsulate iirc
     
  47. Mithion

    Mithion

    Joined:
    Dec 12, 2013
    Posts:
    14
    @hopeful good point, I'll do that here.

    All you do is call:
    Code (CSharp):
    1. UnityUtil.CalculateObjectBounds(dungeon.Root, false, true);
    Where the first parameter is a DungeonGenerator object, the second is whether or not to include inactive tiles, and the third is whether or not to include sprite renderers.

    It returns a Bounds struct. Nice and easy :)
     
    hopeful likes this.
  48. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    Yeah, looks like the changes I made in 2.8.0 aren't needed any more; literally days after I pushed it to the Asset Store :p


    Asynchronous generation isn't possible just yet. I might be able to do something with co-routines and not have to worry about threading, but it'll probably require some pretty serious changes to the generation process. Definitely something I want to do though.

    As you've already figured out, the helper function UnityUtil.CalculateObjectBounds() will calculate the overall bounding box around an object - that function might be a little slow though as it loops through all renderers and colliders in the object's hierarchy. I've been meaning to save the dungeon bounds to a variable somewhere for a while now but keep forgetting - I'll do it now so it's ready for the next release.


    Sorry, that's not something DunGen can do. I tried seeing if I could hack in that kind of behaviour using the injected tile functionality and a dungeon length of zero (I was basically trying to override the whole generation process) but it really didn't work.


    Thanks, I've updated the documentation version on the website.

    From what testing I've done, the ProBuilder changes don't cause any conflicts with DunGen 2.8.0, I'm just doing some now-redundant bounds calculation before instantiating ProBuilder prefabs.


    When I finally got around to testing ProBuilder, it looked like instantiation worked fine already without any special functions, but ProBuilder objects didn't create the mesh until after it was placed in the scene - meaning that room bounds were incorrect when I make the proxy objects for quick collision testing. Basically, in 2.8 I manually calculated the bounds of a ProBuilder object (detected by class name through reflection o_O) in the pre-processing stage so there were no intersecting rooms caused by a lack of collider/renderer. It looks like even this step isn't necessary any more so I'm just doing some unnecessary calculations for each ProBuilder object that's used.
     
    hopeful likes this.
  49. FacepunchAd

    FacepunchAd

    Joined:
    Aug 13, 2015
    Posts:
    3
    Hi!

    When setting up doors, is it possible to use groups somehow? Say I have three doors in a room, A,B,C. I always want door A to be used and then either B or C.

    Thanks
    Adam
     
  50. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    622
    There's no built-in way of doing that, but if you're up for modifying the source code you could give the Doorway class a new variable and prioritize picking doorways based on this variable by modifying the PickRandomDoorwayIndex() function in TilePlacementData.cs