1
不一致浮子我有我使用隨機生成一個「房間」幾個預製件,但相同的代碼導致不一致的寬度:使用Unity
頂部(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);
}
我會瘋了嗎?它剛剛晚了,我錯過了什麼?
謝謝。
你有什麼設置北牆和南牆在檢查員? – Lefty
我剛剛將一個Wall預製件拖放到它們中的每一個上。 Wall是一個帶有箱式對撞機的四輪車。 – stefannew
那麼檢查員內部的規格是什麼? –