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