Search Unity

PGC Dungeon Help (WebPlayerBuild inside)

Discussion in 'Scripting' started by Pysassin, Nov 10, 2014.

  1. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    Hey all, I am currently making a dungeon crawler and thought I'd try out using PGC (procedurally generated content) dungeon and I am having a bit of an issue on some logic. The system I plan on using revolves around rooms,junctions,and connections(halls). The objects are classified as below:

    Rooms(up to 4 connections): Connects to a connection(hall)
    Connections(halls)(2 total connections): Connects to a junction or room
    Junction(upto 4 connections): Connects to connections(hall)

    My current issue is I am not sure how to approach the logic to stop connections from running over each other. I thought about checking the space the new tile is going to be place in but I found several times that you could tell 2-3 placements prior the collision is going to happen. How to get my code to see this is my current obstacle.

    Could anyone offer up some advice?

    Here is a webplayer link to the current project (has since been updated to reflect changes to code): https://dl.dropboxusercontent.com/u/142894708/Gen/Gen.html
     
    Last edited: Nov 11, 2014
  2. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    I managed to get my junctions/connections to stop overlapping, and although I'm not entirely sure why some of my dungeon is allowed to create itself. I have solved the issue of overlap. To do so I check (using rigidbody.sweeptest) if I can place the desired object in the space allotted, if I can place it, if not find a different part. When placing junctions I also check to make sure something can be placed at the end of each junction, if it can't pick a different junction, if it still can't find a valid junction turn it into a dead end (connection with no exit connector).

    I have updated the webplayer link in case anyone would like to test this out and offer up and advice.
     
  3. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    Link is updated again to show progress made. For at least a simple single level dungeon gen I think its passable, but always nice to hear suggestions from others.