Search Unity

[RELEASED] Dungeon Architect

Discussion in 'Works In Progress' started by AliAkbar, Aug 9, 2015.

  1. CliffCawley

    CliffCawley

    Joined:
    Mar 30, 2009
    Posts:
    16
    Additionally, in the Grid builder, how do you cope with specifying the size of the stairs? For example my stair mesh is quite large and requires some padding around it because otherwise the generator can create small rooms where the stairs either butt up against a wall or overhang.

    I.e: Bug.PNG

    Here for example the stair case highlighted in red overhangs the wall and the blue line/arrows show the flow I assume it was trying to generate.
     
  2. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    I forget what it's called but there's a feature where you can say only generate this tile in a place with these tiles around it.
     
  3. CliffCawley

    CliffCawley

    Joined:
    Mar 30, 2009
    Posts:
    16
    Yeah, although that's for sub markers. This is a base marker emitted by the dungeon generator
     
  4. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    well perhaps in an update it should be made for all markers.
    in the mean time you can just manually paint some floor in front of problematic stairs.
     
  5. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    oh also, do all tiles have to be square or could I use the snap builder to make rare 45 degree corner tiles?
     
  6. TheLoveableDonut

    TheLoveableDonut

    Joined:
    Apr 26, 2017
    Posts:
    1
  7. AliAkbar

    AliAkbar

    Joined:
    Jun 30, 2014
    Posts:
    595
  8. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    ok to there isn't support yet for non-square tiles and off-grid angles. Well maybe in a distant update one day.
     
  9. Kiracam1

    Kiracam1

    Joined:
    Sep 20, 2015
    Posts:
    2
    Thanks for the info! I actually got working on my side. Turns out the pivot points for my art assets were in a weird spot and thus causing equally weird results. :D
     
  10. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @AliAkbar,

    For DungeonSnap and the Dungeon Flow Editor. They are Awesome!

    I was getting module (room) collisions when building a dungeon. I had to instantiate the prefab modules in order to get correct bounds. The renderer bound extents were coming out as zero.

    SnapBuilder.cs:

    Code (CSharp):
    1.         static Bounds GetBounds(GameObject target)
    2.         {
    3.             var bounds = new Bounds();
    4.             if (target == null)
    5.             {
    6.                 return bounds;
    7.             }
    8.  
    9.             /*
    10.             var renderers = target.GetComponentsInChildren<Renderer>();
    11.             foreach (var renderer in renderers)
    12.             {
    13.                 bounds.Encapsulate(renderer.bounds);
    14.             }
    15.             */
    16.             bounds = DungeonGame.DungeonHelper.GetBounds(target);
    17.  
    18.             return bounds;
    19.         }
    Code (CSharp):
    1. namespace DungeonGame
    2. {
    3.     public static class DungeonHelper
    4.     {
    5.         public static Bounds GetBounds(GameObject gameObject)
    6.         {
    7.             GameObject instance = Object.Instantiate(gameObject, Vector3.zero, Quaternion.identity) as GameObject;
    8.             Bounds bounds = new Bounds(Vector3.zero, Vector3.zero);
    9.  
    10.             var renderers = instance.GetComponentsInChildren<Renderer>();
    11.             foreach (var renderer in renderers)
    12.             {
    13.                 bounds.Encapsulate(renderer.bounds);
    14.             }
    15.  
    16.             Object.DestroyImmediate(instance);
    17.  
    18.             return bounds;
    19.         }
    20.     }
    21. }
    Now it works great. If the issue was mine, I appologize.

    I recreated your ue4 multi-level dungeon example from watching your youtube videos the other day (it looked cool). It helped me understand the process better. Thanks!

    Snap1.png
     
    Last edited: Apr 7, 2019
    AliAkbar, Sehee26 and hopeful like this.
  11. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    296
    @AliAkbar is there a way to exclude an object from the meshmerger? I have some events that dynamically change the object and I need it to not be merged with other objects.
     
  12. KungFuBrad

    KungFuBrad

    Joined:
    Apr 12, 2018
    Posts:
    9
  13. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @AliAkbar,

    For DungeonGrid and ClusterTheming:

    For my own knowledge and to better understand the Grid Dungeon code, I translated your ue4 ClusterTheming cpp code to c# and got it working for Unity3d (have both ue4 and unity3d Dungeon Architect). It's a cool feature. It can make complex looking dungeons.

    Cheers!

    FYI:
    In the images, the "Cluster Themes" array is in the inspector at the top right in the Dungeon script. The "Enable Cluster Theming" and "Cluster with Height Variation" checkboxes are at the bottom right in the GridDungeonConfig script.

    1: Cluster Theming On, Cluster with Height Variation On
    2: Cluster Theming On, Cluster with Height Variation Off

    ClusterTheming2.png ClusterTheming3.png
     
    Last edited: Apr 12, 2019
    AliAkbar likes this.
  14. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @dlevel,

    I looked at the MeshMerger code and it looks like it will ignore/exclude non-static game objects. I'm not sure about excluding static objects.
     
  15. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @TheLoveableDonut,

    I'm not too familiar with the JackRabbit 2D demo, but I noticed that your GameController is missing the Waypoint Generator Script. I looked at the GameControllerJackRabbit code, and it looks like you might get NullPointer exceptions without it.

    FYI: I'm using DungeonArchitect version 1.9.0.

    GameControllerJackRabbit.cs:
    Code (CSharp):
    1.         void NotifyBuild()
    2.         {
    3.             waypointGenerator.BuildWaypoints(dungeon.ActiveModel, dungeon.Markers);
    4.             specialRoomFinder.FindSpecialRooms(dungeon.ActiveModel);
    5.         }
    6.  
    7.         void NotifyDestroyed() {
    8.             waypointGenerator.OnDungeonDestroyed(dungeon);
    9.             specialRoomFinder.OnDungeonDestroyed(dungeon);
    10.         }
     
  16. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @CliffCawley,

    I apologize in advance if you already know this. If you are asking about creating stair footprints much larger than the X,Z cell size, I'm not sure how it would work without potential structure overlap/obstruction (even with Spacial Constraints).


    But just in case, here is how I understand it.

    In the GridDungeonConfig, you can set the expected stair height in "Grid Cell Size". The "Y" value corresponds with the stair height (change in dungeon height from area to area). So for X=4, Y=2, Z=4; your expected stair height would be 2. For a larger height stair prefab, you can set the Y to something larger (4, 6, 8, ...).

    You would want to match your stair prefab height with the "Grid Cell Size" Y height. So for a stair prefab of height 4, you would set the "Grid Cell Size" Y height to 4 also.

    You can also specify if you want the GridDungeonConfig to vary the stair height using the "Max Allowed Stair Height". For example, setting it to 2 could potentially generate a dungeon where "some" of the stairs are twice as high. This can bring a variety of stair heights to your dungeon. You would use the "Stair2X" marker in the theme file for this larger stair and assign it to a stair prefab that was twice as tall.

    Hope this helps.

    GridDungeonConfig:
     

    Attached Files:

    Last edited: Apr 12, 2019
  17. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    296
    Thank you!
     
  18. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @Nevercallmebyname,

    You can create a triangle ground mesh and use spacial constraints (using DungeonGrid). You can set the spacial constraint rules so that the corner is only used where fences/walls exist on two sides.

    Dungeon Architect has a better example where it places curved corner floors and railing at all corners. It even places 2x larger curved corners where extra ground space is available.

    DA Curved Corner Example:
    DungeonArchitect_Samples\Demo_SpatialConstraints\11_SCExample_RemovalRules_Corner_Scene
     

    Attached Files:

    AliAkbar likes this.
  19. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    ok lovely a multi floor dungeon with per floor layouts. I do not need the floors to be random for this project so this works well enough and I assume I use stairs instead of elevators because the elevators do not fit the fantasy genre build I have in mind. Would still like to add some non 90 degree corners to get the game off grid but a lot of boxes are ticked so I wont gripe.
     
  20. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Yes. The dungeon flow editor is pretty useful. After designing the basic dungeon flow branches (ex: mini-boss to key, mini-boss to treasure, locked door to boss to next level stairs), you can generate as many dungeons as you want until you get one that you like (if you want a pre-generated dungeon).
     
  21. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    did i reply the wrong post? I did... that's an embarrass
     
  22. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    Anyway, I'm realizing that the terrain features for this are probably not compatible with Map Magic. That is a shame because I had intended to use the two together.
     
  23. kernelkode

    kernelkode

    Joined:
    Jan 27, 2014
    Posts:
    8
    Hi Ali,

    Bought DA a couple years ago and just got around to using it. I am playing with DungeonMaze for a mini-game, but Spatial Constraints don't seem to work with it for me. Is there an example you can point me to?

    Thanks,
     
  24. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @kernelkode,

    I looked at the code and it doesn't look like there is a Spatial Constraints processor that will work with DungeonMaze. There are:

    SpatialConstraintProcessorGrid3D.cs
    SpatialConstraintProcessorGrid2D.cs
    SpatialConstraintProcessorSimpleCity3D.cs

    Each one will expect a unique config class. You could write your own, however, and add it to your DungeonMaze game object. It seems to work when I added small blue blocks in the maze corners (in the theme file). You may have to play around with it to see how well it works.

    Code (CSharp):
    1. using UnityEngine;
    2. using DungeonArchitect.SpatialConstraints;
    3. using DungeonArchitect.Graphs.SpatialConstraints;
    4.  
    5. namespace DungeonArchitect.Builders.Maze
    6. {
    7.     public class SpatialConstraintProcessorMaze2D : SpatialConstraintProcessor
    8.     {
    9.         public override SpatialConstraintRuleDomain GetDomain(SpatialConstraintProcessorContext context)
    10.         {
    11.             var mazeConfig = context.config as MazeDungeonConfig;
    12.  
    13.             var domain = base.GetDomain(context);
    14.             domain.gridSize = new Vector3 (mazeConfig.gridSize.x, 0f, mazeConfig.gridSize.y);
    15.             return domain;
    16.         }
    17.     }
    18. }
     

    Attached Files:

    AliAkbar and hopeful like this.
  25. kernelkode

    kernelkode

    Joined:
    Jan 27, 2014
    Posts:
    8

    Thank you @HayLo02, that's what I was looking for! Thanks for taking the time. Wish I had started playing with this sooner, it's pretty fun.
     
  26. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    No problem. It was fun discovering that it could be done for dungeon maze.
     
  27. nrvllrgrs

    nrvllrgrs

    Joined:
    Jan 12, 2010
    Posts:
    12
    Has anybody successfully used Dungeon Architect with 2019.1? I am getting associated script cannot be loaded warnings when selecting my theme asset.
     
  28. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    50

    Thanks @HayLo02 this was exactly what I was looking for as well. I'd made my own builder but didn't know how to get spatial constraints working with it as they are not really documented well. You saved me a lot of time!
     
  29. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @Darren-R,

    Thanks! I'm glad you like it.
     
  30. kernelkode

    kernelkode

    Joined:
    Jan 27, 2014
    Posts:
    8
    @HayLo02
    I have an issue with the maze builder. Maybe it has to do with changing the start point from:
    var startPoint = new IntVector2(0, 2 + random.Next() % (MazeConfig.mazeHeight - 4));
    to:
    var startPoint = new IntVector2(2, 2);

    99% of the time I get a good maze where I can get to every point on the map, but 1% of the time I get a stranded corner part like this:



    Any ideas how I can prevent this?

    Here is a demo: https://kernelk.itch.io/mazecrawler
     
    Last edited: Apr 26, 2019
    AliAkbar likes this.
  31. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @kernelkode,

    I'm not too familiar with the MazeDungeonBuilder code, but it looks like the start position is not being marked as visited. This can sometimes result in the start position being marked as a block instead of an empty space (see Maze1.png - startPosition = 2,2). Setting the start position as visited seems to fix the problem (see Maze2.png - startPosition = 2,2).

    By the way, your maze demo is cool!

    MazeDungeonBuilder.cs:

    Code (CSharp):
    1.             var stack = new Stack<IntVector2>();
    2.             {
    3.                 //var startPoint = new IntVector2(0, 2 + random.Next() % (MazeConfig.mazeHeight - 4));
    4.                 var startPoint = new IntVector2 (2, 2);
    5.                 stack.Push(startPoint);
    6.                 visited[startPoint.x, startPoint.y] = true; // <<< ADD THIS LINE
    7.                 //Debug.Log("Start Point: x = " + startPoint.x + ", y = " + startPoint.y);
    8.             }
    9.  
     

    Attached Files:

    Last edited: Apr 27, 2019
    AliAkbar likes this.
  32. kernelkode

    kernelkode

    Joined:
    Jan 27, 2014
    Posts:
    8
    @HayLo02 Thanks again! I am trying this out now.
     
  33. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    So what if there was a specific floor-plan you had in mind but you don't care what is in each individual room?
     
  34. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @Nevercallmebyname,

    For DungeonSnap you would need to populate each room with whatever enemies and props you want in that room. You could create different versions of the room (different enemies and props) and have SnapBuilder randomly choose a room from your module list.

    I don't think DungeonSnap currently populates a room automatically like DungeonGrid - using a theme file (e. g. chairs, rugs, lamps, etc).

    Below I created a SnapBuilder with a simple flow: SpawnRoom > Room > MiniBoss > Exit. Since I created 3 different room modules using the same "Room" module node/category name (see the SnapConfig "Modules" List), SnapBuilder randomly chooses among them for each dungeon seed.

    To make it easier for DungeonSnap to generate a dungeon, I added snap connections centered on every 1x1 wall (12 units - See pic #5 Room2x2).

    1. DungeonFlowEditor
    2. Dungeon #1 (seed 20 - used Room1x1)
    3. Dungeon #2 (seed 10 - used Room2x1)
    4. Dungeon #3 (seed 30 - used Room2x2)
    5. Example of Room2x2 Snap Connections
     

    Attached Files:

    Last edited: Apr 29, 2019
    AliAkbar likes this.
  35. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    I actually was thinking of DungeonGrid. DungeonSnap just doesn't suit my needs at all. Unless DungeonSnap is the only way to implement multi level dungeons.
     
  36. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    I suppose for DungeonGrid you could prebuild your dungeons and save each one to a scene. You could then load each scene as your player progresses through the dungeon. You could also use Platform Volumes, Theme Volumes, Negation Volumes, and Paint Mode to alter the layout of your dungeon.
     
    Last edited: Apr 29, 2019
  37. luizrd

    luizrd

    Joined:
    Mar 4, 2017
    Posts:
    5
    Hallo,

    Can I do a dungeon without corridors? in case I want to do a 2D platform game, and i´ll create all the rooms, and the dungeon master should create the dungeon randomly. rooms can not be rotated. it is possible?
     
  38. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @luizrd,

    Dungeon Architect has a dungeon builder that can create Mario style 2.5D platform levels. You just need to supply the prefabs (walls, ground, etc - dungeon theme file) and set the dungeon length, height, etc. This does leave room/area creation to the builder. (see image 1 below).

    If you want to use your own rooms/areas, you could use the DungeonSnap builder to create a random 2D style level (with dungeon seed number). Make sure to uncheck the "Rotate Module to Fit" checkbox in the DungeonSnap GameObject. Each area/room prefab (excluding the first area/room prefab) should have a DungeonSnap Connection on each end with no doors/walls assigned. The first area/room should only have a connection on the right side. Below (see images 2-4 below) is a simple DungeonSnap example I created.

    DA Mario Example Location:
    DungeonArchitect_Samples/DemoBuilder_Mario

    Images:
    1. DemoBuilder_Mario Example
    2. DungeonSnap Example
    3. DungeonSnap Area/Room Prefab
    4. DungeonSnap DungeonFlow
     

    Attached Files:

    Last edited: May 2, 2019
  39. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    94
    Hmm what about if I made a room for DungeonSnap that was just the outer edges of tiles and set the other rooms to generate inside that area of for DungeonTile made the outside edge as a single tile and configured it to fill with tiles. I want this first area of my game to be eight pointed star shaped and I'm just trying to come up with the best way to configure that.

    Oh also, I'm going to tie the props that generate to some values that will change through gameplay but Ideally I'd want the props to change and the dungeon layout to be the same each time the area loads. Like a dynamic hub level.
     
  40. Weblox

    Weblox

    Joined:
    Apr 11, 2016
    Posts:
    256
    Hi @everyone! So with the new Components and updates, are the Video Tutorials still a good place to start ?

     
    Last edited: May 3, 2019
  41. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    That’s a tricky one. I’m not sure how compatible DungeonSnap and DungeonGrid are currently. You might be able to Paint a general (although blocky) star shape with DungeonGrid, but that isn’t the same as defining a border shape and having DungeonGrid fill it with rooms, corridors, and props.

    You could investigate if DungeonGrid volumes are useful.
     
    Last edited: May 3, 2019
    AliAkbar likes this.
  42. HayLo02

    HayLo02

    Joined:
    Sep 11, 2017
    Posts:
    16
    Hi @Weblox,

    Yes. The video tutorials give you a good handle on how to use one of Dungeon Architect’s most useful builders: the Grid Dungeon Builder.

    @AliAkbar is also making improvements to the Snap Builder with the Dungeon Flow editor. You can look at his YouTube videos and the below document link on how to use it.

    https://coderespawn.github.io/dungeon-architect-snap-map-user-guide-unity/
     
    Last edited: May 4, 2019
    AliAkbar and Weblox like this.
  43. wigglypuffs

    wigglypuffs

    Joined:
    Aug 10, 2015
    Posts:
    63
    Not sure if anyone else has solved this problem yet. But I'll post my solution here. On Unity 2018 and newer the game objects being added to the scene are prefabs. Unity throws an error during creation due to set parent and also during destruction which prevents the destroy from being completed. I modified the editor dungeon scene object instantiator to unpack the prefabs as they are added to the scene.

    Assets\DungeonArchitect\Editor\Dungeon\EditorDungeonSceneObjectInstantiator.cs

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. namespace DungeonArchitect.Editors
    5. {
    6.     public class EditorDungeonSceneObjectInstantiator : IDungeonSceneObjectInstantiator
    7.     {
    8.         public GameObject Instantiate(GameObject template, Vector3 position, Quaternion rotation, Vector3 scale, Transform parent)
    9.         {
    10.             var gameObj = PrefabUtility.InstantiatePrefab(template) as GameObject;
    11.  
    12.             if (PrefabUtility.IsPartOfPrefabInstance(gameObj.transform))
    13.                 PrefabUtility.UnpackPrefabInstance(gameObj, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
    14.  
    15.             gameObj.transform.SetParent(parent);
    16.             gameObj.transform.position = position;
    17.             gameObj.transform.rotation = rotation;
    18.             gameObj.transform.localScale = scale;
    19.             return gameObj;
    20.         }
    21.     }
    22. }
    Hope this helps anyone else encountering this issue.
     
    Weblox and hopeful like this.
  44. unity_Lb2lDqR5J9MXZw

    unity_Lb2lDqR5J9MXZw

    Joined:
    Dec 5, 2017
    Posts:
    1
    Hi, very new to DA, just trying to make a simple dungeon with Unity cube shape prefabs. For my stairs I have simple created a cube and rotated and scale it to create a slope.
    I have Enable Runtime Navigation elected in the Dungeon Runtime Navigation script, bu tthe navmesh that is built is really bad, some of the slopes/stairs are fine, but many are not and make the dungeon impassable?
    Any ideas what's going on and how to fix this?
    My project will be using random dungeons generated at runtime, but if there's a small chance that nav mehses can break for players like this then I'm in trouble. I'm going to assume for now that I've done something wrong, help appreciated.

    Below, the grey slopes most NavMesh is broken, one or two of them are successful, but it's not to do with facing or rotation either as some are borken that have the same orientation as good ones
    upload_2019-5-11_10-1-15.png
     
  45. bradbecker

    bradbecker

    Joined:
    Dec 26, 2014
    Posts:
    96
    I'm playing around with MultiStory Dungeons (the Linear PC version) and downloaded the relevant theme from DA but all the meshes are blank. Is the DA theme's prefabs out of date or was it expecting a different version of MultiStory Dungeons?
     
  46. bradbecker

    bradbecker

    Joined:
    Dec 26, 2014
    Posts:
    96
    I also noticed that the Theme has a bunch of nodes that point to nothing:
    upload_2019-5-17_13-34-13.png
     
  47. bradbecker

    bradbecker

    Joined:
    Dec 26, 2014
    Posts:
    96
    I'm guessing the latter issue is by design but the fact that all the meshes are missing on the MultiStory Dungeons prefabs in the DA theme is an issue with it expecting an older version of the meshes or an older version of probuilder or ... ?

    Anyone else seeing this?
     
  48. Arcan-Studios

    Arcan-Studios

    Joined:
    Mar 12, 2015
    Posts:
    49
    hi i need help with the new snap system, i read the overview and look the example but have problem with corridor, i can put room, but when i try to put corridor, the dungeon dont build without any error
     

    Attached Files:

  49. bradbecker

    bradbecker

    Joined:
    Dec 26, 2014
    Posts:
    96
    Is there a Discord channel or active forum for DA?
     
  50. Sajid_farooq

    Sajid_farooq

    Joined:
    May 23, 2012
    Posts:
    237