using UnityEngine;

public class Test : MonoBehaviour
{
public Transform hero;
public GameObject treePrefab;
public int width;
public int height;
// Start is called before the first frame update
void Start()
{
GenerateWall();
}
void GenerateWall()
{
var wallParent = new GameObject("Walls").transform;
wallParent.transform.position = hero.position;

float evenOffset = (width % 2 == 0) ? 0.5f : 0; //์ง์ˆ˜์ผ๋•Œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ1

for (int i = 0; i < width; i++)
{
Instantiate(treePrefab, new Vector3(i - width / 2 + evenOffset, (float)height /2) + hero.position, Quaternion.identity, wallParent);
Instantiate(treePrefab, new Vector3(i - width / 2 + evenOffset, -(float)height /2) + hero.position, Quaternion.identity, wallParent);
}

evenOffset = (height % 2 == 0) ? 0.5f : 0; //์ง์ˆ˜์ผ๋•Œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ2

for (int i = 0; i < height; i++)
{
Instantiate(treePrefab, new Vector3((float)width / 2 ,i - height / 2 + evenOffset) + hero.position, Quaternion.identity, wallParent);
Instantiate(treePrefab, new Vector3(-(float)width /2, i - height / 2 + evenOffset) + hero.position, Quaternion.identity, wallParent);
}


}
}



2cb3c331e0c076b660b8f68b12d21a1de306dbbcafb1




78bb8173b0846ba03bbad0ed10857664119579a59d760800344542e672f157c8a116d9


ํ›„์šฐ.. ํ•‘ํ”„๊ธ€์—ย ๊ฐ€๊นŒ์šด ์ฝ”๋“œ์งˆ๋ฌธ ์ž˜ ๋‹ต๋ณ€ ์•ˆํ•˜๋Š”๋ฐ ์ด๋ฒˆ๋งŒ์ž…๋‹ˆ๋‹ค.


์ง„์งœ ๋Œ€์ถฉ์งฌ