Search Unity

DunGen - Procedural Dungeon Generation

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

  1. Creiz

    Creiz

    Joined:
    Jun 6, 2017
    Posts:
    80
    I'm having a bit of a stiffy with this. Nothing too bad, I hope.

    I'm trying to make a 3 way tile, for corridors. I need Dungen to make a bunch of rooms, (like 5~10 of them), separated fairly far, then connect these with corridors. And this where I'm stuck.

    So I have my corridor I and L which works correctly. However, I need some corridors to branch out. So I made a T tile with 3 doorways but sometimes it doesn't use 1 or 2 of those doorways. How can I force it to use all of them?

    Also, I need the corridors to lead to a room. Sometimes it doesn't a just cuts short. Can I also force it?
     
  2. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    Sorry for the late reply, I've been out of commission since Wednesday.

    Unfortunately, it's not possible to guarantee all of the doorways of any given tile will be used.

    For branches ending in a corridor, the 2.15 beta has a new option in the dungeon flow asset settings that will delete the last tile in each branch if it doesn't meet the requirements you specify (it does this recursively so it will prune the branch until there's a valid cap tile).

    This can be used to make sure there are no corridors on the end of a branch. Here's how you'd do it:

    1. Create a tag called 'Corridor' (Window > DunGen > Tags)
    2. For each of your corridor tile prefabs, if it doesn't have a Tile component, add one. In the tile component, add your new 'Corridor' tag to the list of tags at the bottom of the inspector.
    3. In your dungeon flow settings, set the 'Branch Prune Mode' to 'Any Tags Present', and add your corridor tag to the list below.
     
  3. katasteel

    katasteel

    Joined:
    Nov 21, 2014
    Posts:
    278
    Question regarding nodes in the dungeon flow.
    I have a dungeon flow with two different tile sets.
    A main dungeon tile set and a sewer tile set.
    I have my flow(picture attached) starting with the main dungeon TS segment, then I have a node to transition to the sewer TS segment.
    Then towards the end i have another node to transition back to the original main dungeon TS segment.
    The problem is when I run it I only get 3 sewer tiles. How do I make DunGen produce more tiles for that segment?
    upload_2021-10-19_13-33-48.png
    upload_2021-10-19_14-8-33.png
    upload_2021-10-19_14-7-52.png
     
  4. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    The number of rooms generated for a line segment is based on the relative length of the line and the dungeon flow's 'Length' property. For example, if you have a dungeon flow with a length of 15 rooms, and it has 3 line segments of equal length, each segment would produce 5 tiles.

    So there are two ways to increase the number of tiles in a segment:
    1. Make the line segment longer relative to the other line segments in the flow graph.
    2. Increase the number of rooms in the dungeon as a whole by increasing the 'Length' property in the dungeon flow.
     
  5. vaki26

    vaki26

    Joined:
    Jan 23, 2015
    Posts:
    20
    How can I reposition your NavMesh it is offset to the tiles ? The NavMesh is perfect it is just below the tiles.
    How is the NavMesh location in relation to the tiles decided ?
    Can I alter the code somewhre to set the starting position ?
    Thanks !
     
    Last edited: Oct 25, 2021
  6. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    Are you using the Unity navmesh adapter? If so, Unity handles generating the navmesh and as far as I know there's no way for us to give it a height offset. If the navmesh is only below the floor by a small amount it might not be a problem at all - you should just be able to decrease the 'Base Offset' in the NavMeshAgent component.
     
  7. vaki26

    vaki26

    Joined:
    Jan 23, 2015
    Posts:
    20
    I am using your NavMesh adapter. The NavMesh is offset to far, I have to locate the tiles in different locations because of the way the Multiple scenes are located and the is also a MMORPG networked game so the dungen can be placed in multiple locations. Its seems to be offset by the distance the spawntile is set from 0,0,0
     
  8. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    There are three navmesh adapters in DunGen: One for Unity's own navmesh using their navmesh components package, and another two for the 3rd party assets A* Pathfinding Project Pro and RAIN (asset now deprecated). I assume you're using the one for Unity's own navmesh system.

    The only scenario I can think of that would cause the navmesh to be offset from the dungeon is if the dungeon was moved after it finished generating, and your navmesh adapter uses 'Full Dungeon Bake' as the bake mode with 'Auto-Generate Surfaces' turned off. In that situation, your dungeon could be separate from the NavMeshSurface component and you'd need to be sure to move them both the same amount.
     
  9. vaki26

    vaki26

    Joined:
    Jan 23, 2015
    Posts:
    20
    Awesome thanks for the help ! I will check that out. You were right thanks !!
     
    Last edited: Oct 28, 2021
  10. vaki26

    vaki26

    Joined:
    Jan 23, 2015
    Posts:
    20
    What layers does the NavMesh adapter ignore or where can I change it ? Layer "Ignore Raycast" also gets NavMesh. It looks like you have addressed this in DungeonCrawlerNavMeshAdapter. I just added a layermask to the script works great.
     
    Last edited: Oct 30, 2021
  11. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    26
    Setting a Lock for Injected Tile is nice.
    However, is it possible to select the position of the lock?
    I used it for blocking the main path, but the lock did not necessarily spawn on the main path.

    I want to use a room with 3 or more doors and set a lock gate only on the door that goes through the main path.
     
  12. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    26
    Sorry to bother you again.
    I'm using GlobalCountMode, and I was wondering why branches were prioritizing the second half of the dungeon to be generated.

    The problem seems to be that the random number used in line 84 of BranchCountModes.cs is Integer. randomStream.NextDouble() seems to have improved the situation.
     
  13. vaki26

    vaki26

    Joined:
    Jan 23, 2015
    Posts:
    20
    When using the UnityAdapter for creating NavMesh it is making gaps where the tiles connect. Is there a way to correct this ?
    I tried using the DungeonCrawlerAdapter which fixed that issue but picks up all objects everywhere not just under the root folder.
    Any advise would be great, thanks.
     
  14. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    I've just pushed a new bugfix version (2.15.1) to the asset store, it should be available immediately.

    the new asset store version (2.15.1) allows you to choose which layers to include whenever DunGen has to make a new NavMeshSurface. Any existing NavMeshSurface component will use their own layer mask still.


    Locks on injected tiles were always supposed to appear on the entrance to the tile, but there was a bug that sometimes allowed it to be placed elsewhere. I've just fixed this issue in the new asset store version (2.15.1). I'd like to re-work the way locks are places so users have more control over where they are allowed to go, but that's going to have to come in a future version.

    Thanks for letting me know about the global count mode issue, I've fixed that in the new asset store version too.

    The DungeonCrawlerNavMeshAdapter shouldn't include objects outside the dungeon root, so I'm not sure why that's happening, I wasn't able to reproduce the issue. About the gaps between tiles, there are two things I can think of that might cause it:
    1. There's actually a small gap between your tiles, but it's big enough that the navmesh thinks they're not connected
    2. If you tiles are connected by doorways, your agent radius might be too big to fit through the doorway. Open the Navigation window (Window > AI > Navigation), select your agent(s) from the list and try lowing the 'Radius' property.
     
  15. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    26
    Sorry for repeating myself.
    In some cases, branchesRemaining in ComputeBranchCountsGlobal() is a negative value, in which case the number of branches seems to be higher than expected.
     
  16. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    You're right, looks like I wasn't clamping that properly - thanks for letting me know. I just pushed an update to the asset store. It's the same version number (2.15.1) but you should still be able to update the package.
     
  17. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    151
    I know it says Unity 2019, but any chance you have 2017.4.37f1 Build, if so, I will buy it
     
  18. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    The current asset store version works for Unity 2017. Up until a few versions ago I was actually publishing from 2017.1, so I haven't been using any features that depend on newer versions. The dungeon crawler sample project does require Unity 2019+ though.

    I can't guarantee that future versions of the asset will continue to work in older Unity versions, but I'll try to avoid braking compatibility if I don't have to.
     
  19. UnityRocksAlt

    UnityRocksAlt

    Joined:
    Dec 28, 2015
    Posts:
    151
    I bought it, I will let you know when I use it. It will be soon .
     
    Last edited: Nov 18, 2021
  20. ZaharAlone

    ZaharAlone

    Joined:
    Mar 14, 2018
    Posts:
    2
    Hi!

    Faced such a problem that in my dungeon, the room is generated above the room. Yes, I have a vertical drop. But I need to avoid generating a room above the room, can I somehow do this using standard means DunGen?
    изображение_2021-11-16_224936.png изображение_2021-11-16_224944.png
     
  21. JamesKalin

    JamesKalin

    Joined:
    Aug 27, 2014
    Posts:
    2
    Hi there. Just bought DunGen. I understand DunGen can be used to procedurally generate towns. Can anyone point me at any doc or examples of DunGen being used to do this? I'm excited to dive into the product.
    Jim
     
  22. adamz

    adamz

    Joined:
    Jul 18, 2007
    Posts:
    1,106
    Does anyone know how the lightning deal works? Does the percentage off reduce as more people buy an asset? I ask because DunGen said it was -90% before the time was up, but now it's -70%. So I'm confused as to how it works.
     
  23. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    You should be able to avoid that by checking the 'Disallow Overhangs' box in the inspector of the Runtime Dungeon component.


    I've never used DunGen to generate a town before, but the way I'd going about doing this would be to make my tiles as square chunks containing some roads and buildings. I'd place doorways on each edge of the tile where I want them to connect. Something like this image (top-down view):

    DunGenTownChunkTile.png

    Red Border = The tile boundaries
    Blue Lines = Doorways
    Grey = Roads
    Brown = Buildings

    You'd probably need to make use of 'Connectors' and 'Blockers' on the doorway components (objects that are added/removed based on whether a doorway is used or not) to block-off areas outside the level bounds. I did something similar for the graveyard tiles in the included dungeon crawler sample.


    Yeah, it's strange that Unity doesn't seem to explain this anywhere. Here's how it works:

    Lightning deal assets have a limited number of licenses available at each price point. The asset starts with 20 licenses at 90% discount. Once those are all bought, there are 50 licenses at 80% discount, and finally 400 licenses at 70% discount. Once all licenses are purchased, the asset falls back to the standard 50% discount for the remainder of the sale.

    If you go to bottom of the list on the lightning deal page, you'll see some assets that haven't started yet and they'll have a countdown for when they'll be on sale starting at 90% off.
     
    adamz likes this.
  24. JamesKalin

    JamesKalin

    Joined:
    Aug 27, 2014
    Posts:
    2
    Your description of how to use DunGen to makes towns looks straightforward to try out. I can imagine various ways I might implement this solution.
    Much thanks, Aegon-Games person.
     
  25. JohnGrizzly

    JohnGrizzly

    Joined:
    Oct 27, 2021
    Posts:
    2
    Hello,

    I'm considering buying the DunGen but first I wanted to know if it's possible to make a fully linear structure with different sized rooms. The goal would be to have a kind of train shape but with different sized rooms procedurally placed inside.
    Just need to know if it's possible then I'll figure it out^^
     
  26. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    Yes, that's possible. DunGen just uses whatever room prefabs you give it, the only restriction is that doors need to be on the boundaries of the room and need to be axis-aligned. If you only put doorways on the two opposite ends of a room, you'll always get a straight line layout as a result.
     
  27. JohnGrizzly

    JohnGrizzly

    Joined:
    Oct 27, 2021
    Posts:
    2
    Perfect, thank you so much !
     
  28. ramtamir

    ramtamir

    Joined:
    Feb 23, 2019
    Posts:
    16
    Trying to get navmesh working. I'm getting a bunch of errors all regarding navmeshsurface not existing. How do I solve this?
     
  29. Aegon-Games

    Aegon-Games

    Joined:
    Mar 7, 2014
    Posts:
    552
    NavMeshSurface is part of Unity's newer navigation package which still has to be downloaded separately for some reason. You can find it on the github page (scroll down to the 'How To Get Started' section for instructions on how to add it to your project).
     
unityunity