Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pathfinding using room "Difficulty"?

Discussion in 'Scripting' started by CaptainKiyaku, May 24, 2013.

  1. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    324
    Hi guys,

    i am trying to work on a random dungeon generator.
    The idea is to have a grid, place a start and exit point, fill the grid with randomly sized rectangles (which represent other rooms) and assign a difficulty level to each room (depending on some factors like size).

    The result is something like this:
    $dungeon_progress_07.png

    Now i need to find a way from Start To End, but i want to consider the room difficulty (green = easy, red = difficult).
    Once i get the path, i would use every room that the path touched and remove all the other rooms, to get my dungeon.

    The question i have though is, how do i generate a path that goes from A to B but avoids anything difficult if it can, and only walk through rooms that are harder if it can't find a different way?

    Would i be able to use A* for this and "somehow" weight each tile on the grid depending on what the room difficulty is? Or are there any "easier/simpler" solutions to this?

    Thanks!
     
  2. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    324
    Alright i figured it out, and all i really needed was an A* Pathfinding system and add the difficulty for each room to the cost of each node.

    The result looks like this :D