Increasing Corridor Width - Unity Procedural Generation of a 2D Dungeon Extra P12.5

Поділитися
Вставка
  • Опубліковано 28 вер 2024
  • Learn how to procedurally generate a 2D dungeon in Unity using Random Walk and Binary Space Partitioning algorithms! In this tutorial we will use unity Tilemaps to create single and multi room dungeons connected by corridors using Corridors First and Rooms first approaches.
    Resources
    github.com/Sun...
    Learn more from about Unity Game Dev in my video courses at:
    courses.sunnyv...
    Assets used:
    pixel-poem.itc...
    You can support me through Patreon:
    / sunnyvalleystudio
    Join the discord:
    / discord

КОМЕНТАРІ • 55

  • @marc8150
    @marc8150 4 місяці тому +5

    Hey man, excellent work! Publishing this for free is crazy, really appreciate it.
    You should definitely advertise your courses more! :D If they have the exact same quality like this series I would really consider buying them just to support you.

    • @SunnyValleyStudio
      @SunnyValleyStudio  4 місяці тому

      I really appreciate that! Yes I have a hard time splitting time into making content and making marketing stuff 😐 But I will aim to improve the marketing side 👍 Thank you for the feedback!

  • @SunnyValleyStudio
    @SunnyValleyStudio  Рік тому +9

    Bug fix:
    In the else statement of the IncreaseCorridorSizeByOne method I forgot to put:
    "previousDirection = directionFromCell;" since we never set it hence the "if" part never gets used.
    Sorry about that!

    • @sonicboomerintheair
      @sonicboomerintheair Рік тому +1

      where exactly do we include this line? Tried including it at the start and end of the "else" part but the "if" part is still never used

  • @Hinaru2008
    @Hinaru2008 8 місяців тому +2

    Great I was exactly thinking that I wanted to make the corridors bigger haha, really love this videos thank you! This is exactly what I was looking for

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому +1

      Thanks! I had a lot of feedback about the corridors so I decided to add this part after recording the whole tutorial 🙂

  • @Ryukujin93
    @Ryukujin93 Рік тому +2

    This is so good tutorial. Hope you can expand it a little bit more about placing doors between rooms, generating rooms content, etc.

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Hey! I will tackle it in a new series as adding doors and keys would require us starting from a High level idea for a map which we next convert into a tile map on the screen. It would still be generated by some PCG algorithm but the idea is that it would only focus on gameplay design for our map. Next we would run the algorithms shown in this series to generate the visuals for the dungeon based on our previous established plan.

  • @epicdungeontiles
    @epicdungeontiles 10 місяців тому +1

    I'd love to see the ability to create within a bounding box, I will try it... I am thinking like a check whenever a floorPosition is being added to see if it is greater than x/y or less than x/y - then just adding this range inside a SerializeField so you can keep the random generation with a certain area.

  • @ty-xq7bl
    @ty-xq7bl 8 місяців тому +1

    How would these tiles be optimized in a 3d game since each individual tile will be its own object?

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому +1

      In 3D you can still use the same concepts but the problem begins in generating the 3D mesh. The most optimal way would be to generate a floor mesh in unity for each room and corridor. Unfortunately this limits you to how the floor will look as 3d artist can make a much more detailed floor tiles. I would say that it is much better to optimize the project by adding doors to your 3d dungeon and unloading the invisible meshes or use level of details to optimize your project while having it look as you want to.

    • @ty-xq7bl
      @ty-xq7bl 8 місяців тому

      @@SunnyValleyStudio Thanks! It looks like I will go with another method, one that places premade rooms onto a graph

  • @Ome_cent___
    @Ome_cent___ 6 місяців тому +1

    This was a bit too complex in my opinion, even though you already implemented the solution with the way you calculated the walls a few videos ago... i just took the "create walls" methods (for that i renamed them to "outline") and used them to build the walls as floor around the floor. the output can be put to the 'create walls' method again and again, everytime growing by 2 fields in each direction.

  • @steveradtke1308
    @steveradtke1308 Рік тому +4

    Your channel is severely underrated. I very much enjoy your content. I am pulling for you and hope your channel grows big!

  • @lukemarkbrady
    @lukemarkbrady 5 місяців тому

    Hey thank you for this. Is there any chance you could create tutorials for making a procedual dungeon which instead of creating random shaped rooms, it selects from a random room prefab. So we can hand design each room then the generator randomly creates the layout and joins the rooms.
    tried looking everywhere and can't see any guidance on this

    • @SunnyValleyStudio
      @SunnyValleyStudio  5 місяців тому +1

      Thanks for the suggestion! Yeah I am thinking about a series like that 👍

    • @lukemarkbrady
      @lukemarkbrady 5 місяців тому

      @@SunnyValleyStudio thats great to hear! yes that would be perfect if you could :) keep up the amazing work!

  • @Chillyfeely
    @Chillyfeely Рік тому +1

    What happens if we use roomfirstDungeon generator

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      I don't think it matters as long as you add the initial corridor tiles to some sort of a collection and use our method to extend them.

    • @Chillyfeely
      @Chillyfeely Рік тому

      @@SunnyValleyStudio

    • @robingaborancsin2537
      @robingaborancsin2537 10 місяців тому

      if you did it can you send me how?😅

    • @Chillyfeely
      @Chillyfeely 10 місяців тому +1

      @@robingaborancsin2537 sorry after my university started I couldn't put much time for it

  • @hernan7561
    @hernan7561 Рік тому +1

    Thanks !!

  • @coffinbonq
    @coffinbonq 8 місяців тому +1

    I have an error error after typing line List corridors = CreateCorridors(floorPositions,potentialRoomPositions); CS0029: Cannot implicitly convert type 'void' to 'System.Collections.Generic.List' . Do you know how can I fix this?

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому

      Check the return type of your CreateCorridors(..) method. That is the best I can think of.

  • @phillipwebb1104
    @phillipwebb1104 Рік тому +2

    Awesome videos. For some reason after this extra part I just receive a out of memory error and nothing loads

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Hey!
      This usually means that some loop is infinite. I think I have added the code to github but if not let me know! I didn't see the exception in my code but it might very well be something I wrote.
      Feel free to join my discord (link in the descritpion) if you still can't figure it out. it will be easier to answer your question there 👍

    • @jamez1434
      @jamez1434 Рік тому

      @@SunnyValleyStudio Hi, i love this series, and this is exactly what i needed for this, though, the code from this tutorial, on the extra width is not on github?

  • @zippybagi1105
    @zippybagi1105 Рік тому +1

    This may be a wrong video to post this comment on but I dont know where else so...
    I am trying to implement djikstra's algoritham for rooms so I know in which room to spawn the player and the exit. I know how the algoritham works but I am having a hard time figuring out what are the neigbours of each room(I am using the rooms first genereation). Do you have any idea how to figure this out?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +1

      Hey! You need to save each room as a List/Hashset of tiles in a dictionary and a key as some index (or actually you could just have a List?. This way you can just use List index as a room index. Anyhow whatever you need to do first collect the data that you need and it should become really easy to perform your own logic.
      I hope it helps!

  • @TotallyRoguelike
    @TotallyRoguelike 4 місяці тому +1

    Love this series, it's really helping me out.
    I just did a slight tweak to help changing the corridor size, to just have a field with corridorSize in the 3by3 instead if just 2, to allow me to adjust the size in the editor.

  • @pepdawg18
    @pepdawg18 10 місяців тому +1

    Love this!
    Would love a deep dive on your procedural item and enemy placement series as well.
    Maybe something on leveling up and character ability skill tree, or a character select screen?

    • @SunnyValleyStudio
      @SunnyValleyStudio  10 місяців тому

      Thanks for the feedback! I will think about it 🙂

  • @cutiefloation
    @cutiefloation Рік тому +1

    Incredible tutorial! Always curious, where did u study those fancy and super useful algorithms? Practice? Inspiration?

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      There are plenty of articles on those. You just pick up one and try using it and sometimes you can get it to work 🙂

  • @youtuber_mini
    @youtuber_mini Рік тому +1

    sir can i get coupon for this course "Unity 2020 URP Make a juicy 2d Shooter prototype" ?

  • @harnageaa
    @harnageaa Рік тому +1

    I hope you are happy in life because you deserve it x99999

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Thanks! Like the said in GTA 3 "No Money, Mo' Problems" 😀
      But really thanks to your support and others I can keep on making those tutorials videos and small games so it is all good!

  • @ty-xq7bl
    @ty-xq7bl 8 місяців тому +1

    your guide is amazing but very advanced concepts which im trying to pick up as i go, do you have some kind of course that goes in depth with inheritance and such?

    • @SunnyValleyStudio
      @SunnyValleyStudio  8 місяців тому

      If you mean the Object Oriented Design I have video couse about it at courses.sunnyvalleystudio.com/ (Thanks for considering to support my channel 😍) . If it's about C# and data structures i will be posting more basic videos this year starting with "C# basics for unity devs" so feel free to subscribe 🙂

    • @ty-xq7bl
      @ty-xq7bl 8 місяців тому

      @@SunnyValleyStudio Thanks! I ended up not using the guide but I did learn a few things from it. It is simply too advanced for me to figure out a way to not have the corridors always in the middle of the room as well as some rooms connecting only via a door and no corridor at all.

  • @carstenhau
    @carstenhau Рік тому

    Thank you for your great tutorials!
    One thing: The "Handle corners" part at 5:25 does not work and is not required, since the corridors you create in your random walk are all straight lines. A "corner" in your example is just the intersection of two corridors. The if clause is never true.

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому

      Thanks for the feedback! I remember that it was tricky to figure out especially to remove the corridors that suddenly end with a wall (not a room). Maybe at that point I kind of implemented this unneeded clause just in case not realizing it was unnecessary 🙂

  • @e4gywanking
    @e4gywanking Рік тому

    how would you make a seed tho

    • @SunnyValleyStudio
      @SunnyValleyStudio  Рік тому +2

      You could set the seed manually docs.unity3d.com/530/Documentation/ScriptReference/Random-seed.html but this is a bit more complicated since to have repeated results it is better to calculate random value based on noise like Perlin noise. This would ensure that the result is always repeatable. With Random calls if you add 1 additional call it will modify the next result and it can be difficult to ensure the order of calls to it.

    • @e4gywanking
      @e4gywanking Рік тому

      @@SunnyValleyStudio Interesting, thanks!