0
我手動(從編輯器)用框創建空對象。它圍繞中心旋轉。 但如果我創建與腳本盒相同的對象。它圍繞着未知點旋轉。 我找到了原因。它發生的原因是盒子具有比例(0.1,0.2,0.1)。如果我設置(1,1,1) - 它工作。 如何解決它?我想要小盒子。圍繞中心旋轉空對象
var wall = new GameObject();
//wall.transform.parent = room.transform;
wall.transform.name = "Wall";
wall.transform.position = new Vector3(0,0,0);
for (int x = -3; x < width-3; x++)
{
for (int y = -3; y < height-3; y++)
{
var plate = Instantiate(SimplePlate);
var pos = plate.transform.position;
float posZ = pos.z - (x * plate.transform.lossyScale.z);
float posY = pos.y + (y * plate.transform.lossyScale.y);
var newPos = new Vector3(0, posY, posZ);
plate.transform.position = newPos;
plate.transform.parent = wall.transform;
plate.name = "Plate " + x;
}
}
是的,(1,1,1)。如果我旋轉包含框(1,1,1)的空GameObject,它工作正常。如果我旋轉包含盒(0.1,0.1,0.1)空遊戲對象 - 遊戲物體圍繞旋轉樞軸就像從箱(1,1,1)包含的內容。 – Vostrugin
也許我會嘗試:http://answers.unity3d.com/questions/12453/how-do-i-offset-the-scaling-center-for-a-cube.html – rmTheZ