#Broken random dungeon generation

1 messages · Page 1 of 1 (latest)

lean rain
#

I've been trying to fix this for 8 hours now and I have no clue what the problem is ```cs
void Spawn()
{

 if (spawned == false)
 {
     if (templates.totalRooms < templates.maxRooms)
     {
         if (openingDirection == 0)
         {
             spawned = true;
         }
         if (openingDirection == 1)
         {
             rand = Random.Range(0, templates.bottomRooms.Length);
             Instantiate(templates.bottomRooms[rand], transform.position, templates.bottomRooms[rand].transform.rotation);
         }
         else if (openingDirection == 2)
         {
             rand = Random.Range(0, templates.topRooms.Length);
             Instantiate(templates.topRooms[rand], transform.position, templates.topRooms[rand].transform.rotation);
         }
         else if (openingDirection == 3)
         {
             rand = Random.Range(0, templates.leftRooms.Length);
             Instantiate(templates.leftRooms[rand], transform.position, templates.leftRooms[rand].transform.rotation);
             //Need Left door
         }
         else if (openingDirection == 4)
#
            {
                rand = Random.Range(0, templates.rightRooms.Length);
                Instantiate(templates.rightRooms[rand], transform.position, templates.rightRooms[rand].transform.rotation);
                //Need Right door
            }
            templates.totalRooms++;
        }
        else 
        {
            if (openingDirection == 1)
            {
                Instantiate(templates.EndBottom, transform.position, Quaternion.identity);
            }
            else if (openingDirection == 2)
            {
                Instantiate(templates.EndTop, transform.position, Quaternion.identity);
            }
            else if (openingDirection == 3)
            {
                Instantiate(templates.EndLeft, transform.position, Quaternion.identity);
            }
            else if (openingDirection == 4)
            {
                Instantiate(templates.EndRight, transform.position, Quaternion.identity);
            }
        }
        
        spawned = true;

    }
}```