「部屋」をランダムに生成するために使用しているプレハブがいくつかありますが、同じコードを使用すると幅が一貫しなくなります。
上部 (northWall) は下部 (southWall) と同じ幅である必要がありますが、明らかに 3 倍のサイズです。
これは、他の「壁」プレハブをインスタンス化する「部屋」プレハブです (この時点では基本的にすべてクワッドです)。
public float length;
public float width;
public float wallDepth;
public Transform northWall;
public Transform southWall;
void Start () {
length = Random.Range (5.0f, 25.0f);
width = Random.Range (5.0f, 25.0f);
wallDepth = 2.0f;
transform.localScale = new Vector3 (width, length, 0.0f);
Instantiate (northWall, new Vector3(transform.localPosition.x, transform.localPosition.y + (transform.localScale.y / 2) + (wallDepth / 2), 10.0f), Quaternion.identity);
northWall.transform.localScale = new Vector3 (width, wallDepth, 10.0f);
Instantiate (southWall, new Vector3(transform.localPosition.x, transform.localPosition.y - (transform.localScale.y / 2) - (wallDepth / 2), 10.0f), Quaternion.identity);
southWall.transform.localScale = new Vector3 (width, wallDepth, 10.0f);
}
私は夢中になっていますか?遅れただけで、何か足りないのですか?
ありがとう。