如何在Unity中的代码中从一面墙到另一面创建动态对象(立方体)?这样:
答案 0 :(得分:3)
有趣的是,Unity家伙写了一个看起来与你想要达到的完全相同的例子:)
答案 1 :(得分:0)
您可以使用2实例化预制件。
public GameObject objToCreate;
void Start ()
{
//2 for sentences to create a vidirectional array
for(int i = 0; i<5;i++){ //for move on Y
for(int j = 0; j<5;j++){ //for move on X
Instantiate(objToCreate, transform.position,transform.rotation);
transform.Translate(1f,0,0); //Move on X
}
transform.Translate(0,1f,0); //When fill X translate on Y and start again
transform.Translate(-5f,0,0); //Reset out transform position 5 units as set in the first for sentence
//For mor space between objects just change the values in Translate function
}
}