C# Unity - Roguelike room generation HELP

Hello :slight_smile:
I am fiddling arround in Unity in my freetime. I am learning by creating a roguelike.
I am pretty new to the Unity Engine. Heres my problem I dont really understand: I instnatiate prefabs and it works well. But the position of each is a bit โ€œoffโ€. Looks like a grid and not like a continous room.


Heres my code I use to create this:

void Start () {

        int roomWidth = rnd.Next(7, 14);
        int roomHeight = rnd.Next(10, 16);

        lastRoomHeight = roomHeight;
        lastRoomWidth = roomWidth;


        for(int y = 0; y < roomHeight; y ++)
        {
            for(int x = 0; x < roomWidth; x++)
            {
                GameObject newWall = null;
                if (x == 0 || x == roomWidth - 1 || y == 0 || y == roomHeight - 1)
                {
                    if(x == 0 && y == 0 || x == roomWidth-1 && y == 0 || x == 0 && y == roomHeight-1 || x == roomWidth-1 && y == roomHeight-1)
                    {
                        newWall = Instantiate(floorTile, new Vector3(x, 1, y), Quaternion.identity);
                    }
                    else
                    {
                        newWall = Instantiate(wallTile, new Vector3(x, 1, y), Quaternion.identity);
                        newWall.transform.parent = this.transform;

                        if (y == roomHeight - 1)
                            newWall.transform.Rotate(new Vector3(0, 180, 0));
                        if (x == 0)
                            newWall.transform.Rotate(new Vector3(0, -270, 0));
                        if (x == roomWidth - 1)
                            newWall.transform.Rotate(new Vector3(0, 270, 0));
                    }
                    
                }
                GameObject newTile =  Instantiate(floorTile, new Vector3(x, 0, y), Quaternion.identity);
                newTile.transform.parent = this.transform;
            }
        }

Maybe someone can see what I am doing wrong.
I appreciate any help I can get :slight_smile:

The only logical explanation I find is that your prefabs are smaller than 1x1. Have you checked the dimensions?
Maybe the parent object is scaled and this is affecting down the children?
Regards