Search Unity

Question A* Pathfinding Dungeon Crawler Hallways

Discussion in '2D' started by GhostSystemDE, May 8, 2023.

  1. GhostSystemDE

    GhostSystemDE

    Joined:
    Dec 31, 2021
    Posts:
    2
    Fellow programmers, artists and Unity Users alike

    I am currently working on a 2D Bullet Hell Dungeon Crawler, very similar to games like Enter The Gungeon. I want procedurally generated dungeons, which create rooms and loops and connects them together will hallways.

    You can find an example of a generated Dungeon in the Attached Files :)!

    As you can see, in the Image, the Dungeon is nearly fully generated, but misses one last loop between the start and end rooms (as indicated by the Green Line). This path between the rooms is created with an A* Pathfinding algorithm, that finds the shortest path from A to B. As you can see, this path creates a lot of small Zig-Zags.
    The hallways are 2 Tiles wide and cannot bend in the ways that the Pathfinding Algorithm finds it's route. What I need is a connection between point A and B, with the least amount of bends possible (see Attached Files, Image 2).

    I have experimented around with getting the X and Y Length of the path and figuring out how to bend that way, but I don't seem to get a system that takes the already generated path into account.
    I have no clue how to approach fixing this problem. Does anyone have an idea on how these kinds of Hallways could be achieved?

    Thanks in advance!
     

    Attached Files:

  2. gooby429

    gooby429

    Joined:
    Aug 13, 2019
    Posts:
    136
    i assume youre using aron granberg's project? if so, you can also ask on his forums, he is good about responding to posts. i can speculate, but youre really just better off playing with the value in the inspector or adding custom grid rules, adding custom grid modifying objects to the scene, etc. til you get what you want
     
  3. GhostSystemDE

    GhostSystemDE

    Joined:
    Dec 31, 2021
    Posts:
    2
    Yup, am working with aron granberg's project. Will definitely ask the same question in his forum!
    I have already played with the grid rules quite a bit, mainly to already achieve movement in only X and Y direction, and to keep enough distance from other rooms so hallways would fit, It's just about getting that path built!
    Thank you for your answer!