Unity Tutorial: ROGUELIKE Room / Dungeon Generation (Like the Binding of Isaac)

Поділитися
Вставка
  • Опубліковано 30 тра 2024
  • Tutorial on how to make roguelike rooms and doors generation in Unity, like it's done in the binding of isaac.
    Scripts coming soon.
    Join the discord server: / discord
    0:00 Setup Unity Scene
    4:42 Coding "Room" script
    6:14 Coding "RoomManager" script
    20:15 Make rooms spawn randomly
    21:49 Adjacent Rooms logic
    25:00 Open Doors
    35:06 Outro

КОМЕНТАРІ • 45

  • @matthieuboissel3676
    @matthieuboissel3676 3 місяці тому +6

    Hey! Great tutorial!
    Just want to post my solutions for the two problems i can see in your system.
    1) The room overlapping
    Put this check in the TryGenerateRoomFunction :
    if (_roomGrid[x, y] != 0)
    return false;
    2)The error when a room tries to be created outside of the grid
    Put this check also in the TryGenerateRoom function (put it before all the other checks by the way) :
    if (x >= gridSizeX || y >= gridSizeY || x < 0 || y < 0)
    return false;
    Hope this helps anyone!

    • @rootbindev
      @rootbindev  3 місяці тому

      Thank you

    • @ke77i
      @ke77i Місяць тому

      when you fix the overlapping the first room never spawns with any doors

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

    Great tutorial! One of the better, well explained ones I have seen on this topic. Would love to see more on this series for sure!

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

      Thank you very much!

  • @MadChirpy
    @MadChirpy 6 місяців тому

    Great video, please continue!
    Adding a few timestamps/chapters to videos as long as this one could be nice, just a thought. But good job, mate!

  • @littlenugget4711
    @littlenugget4711 2 місяці тому

    Hey, awesome tutorial! I'm currently making a game for my school's game jam, and this helped soooo much. Thank you!

    • @rootbindev
      @rootbindev  2 місяці тому

      Thank you, and Good luck with the game jam!

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

    AHHH Root how did I miss this upload of yours. I have always had notifs on D: Nonetheless, very organized tutorial!!

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

      Thank you Panini! :D

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

    Everything works just fine! Great tutorial!
    I'd like to see you explain how to spawn a boss room, a shop, secret rooms, like in Isaac!

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

      I'm glad you liked it! I might do that in the future!

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

      Oh, by the way, I just did it myself, with help of ChatGPT, now it's perfect: Boss Room is always has a connection to only one room and is always the furthest room from the start, also Treasure room and Shop room generating with only one room adjacent to them. It is still based on your code, just saying, if you are interested to see how AI implemented this - let me know.@@rootbindev

  • @LizzySphinx
    @LizzySphinx 7 місяців тому +5

    LOVE THIS tutorial! Very thorough and to-the-point!

  • @migalesch1839
    @migalesch1839 3 місяці тому +1

    thank you!

  • @MaximumSpice
    @MaximumSpice 3 місяці тому

    I assume you forgot or didn't want to add the scripts in the description :(

  • @ItsReece2
    @ItsReece2 6 місяців тому +2

    This tutorial is great, well done and keep it up!
    I did notice that some of the rooms do overlap on top of each other during runtime. Do you know why?

    • @rootbindev
      @rootbindev  6 місяців тому

      Did you follow the tutorial 100%? In my game, using this code I get no overlaps

    • @ItsReece2
      @ItsReece2 6 місяців тому +2

      Yes, I did follow it but might be possible I missed something in the tutorial. I must say it's very uncommon it happens the overlap; normally overlaps from starting room and occasionally another room from the neighbouring nodes. @@rootbindev

    • @FennrirWolf
      @FennrirWolf 5 місяців тому +3

      I also noticed this same issue. It is pretty far and few between, and also as Reece mentioned it is usually an overlap on top of the starting room. Rarer occasions do include non-starting rooms overlapping too. I'm not sure if this is the most efficient fix, but in our Update when we call the TryGenerateRoom 4 time, I added checks for neighbors prior to actually generating in any direction. I have not seen any overlap since I added these checks.
      if (gridX > 0 && roomGrid[gridX - 1, gridY] == 0)
      {
      //No neighbor to the left
      TryGenerateRoom(new Vector2Int(gridX - 1, gridY));
      }
      if (gridX < gridSizeX - 1 && roomGrid[gridX + 1, gridY] == 0)
      {
      //No neighbor to the right
      TryGenerateRoom(new Vector2Int(gridX + 1, gridY));
      }
      if (gridY > 0 && roomGrid[gridX, gridY - 1] == 0)
      {
      //No neighbor below
      TryGenerateRoom(new Vector2Int(gridX, gridY - 1));
      }
      if (gridY < gridSizeY - 1 && roomGrid[gridX, gridY + 1] == 0)
      {
      //No neighbor above
      TryGenerateRoom(new Vector2Int(gridX, gridY + 1));
      }
      @@rootbindev

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

      @@rootbindev I have the same problem, and you can see the problem in your video too (eg, 20:07). You can see 17 room created, but only "12" visible

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

      Try adding the checks that @FennrirWolf posted above@@bsdrago

  • @RG-vv4wcRG
    @RG-vv4wcRG 5 місяців тому +2

    Nice

  • @SurvivalGamingyt
    @SurvivalGamingyt 3 місяці тому

    Would this also work with tilemap based rooms?

    • @AvoDev
      @AvoDev 3 місяці тому

      yeah, I was able to do it with minimal effort, just create a tilemap grid on the room object, and give it some colliders.

  • @migalesch1839
    @migalesch1839 3 місяці тому

    Sometimes rooms are generating inside of existing rooms, any idea how to fix this?

    • @rootbindev
      @rootbindev  3 місяці тому

      I've noticed as some guys told me below, I'm not sure why

  • @codered_dev
    @codered_dev 2 місяці тому

    ummm some dungeon patterns are repeating like

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

    where are the scripts

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

      I can send them at discord

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

    Does this work with tiles?

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

      I haven't tried it but it should work

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

      @@rootbindevalso how can you edit the room like as content, if there’s only one prefab how can you make different type of rooms

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

      Make another room prefab that suits your needs, and before instantiating the room you decide which prefab to Instantiate :) @@Arcann_bhp

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

      @@rootbindev so I can just make a list of room and then randomize with the length of the rooms?

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

      Exactly! Atleast that's how I would do @@Arcann_bhp

  • @LogicStudios_1
    @LogicStudios_1 2 місяці тому +2

    Great tutorial, how would I go about instantiating something at the last room generated...
    Edit: Figured it out.
    Add this code where you set generationComplete = true.
    GameObject lastRoom = roomObjects.Last();
    Instantiate(boss, lastRoom.transform.position, Quaternion.identity);
    Make sure your script is using System.Linq;

    • @rootbindev
      @rootbindev  2 місяці тому

      Thank you for sharing!