我在自学unity3d,遇到个问题,请教各位大神。
我用预制体cube方块生成的前面,会散掉,不知道怎么回事?
cube物体有刚体组件,大小都是1,1,1的正方体;
这个是源代码:
public class RayDemo : MonoBehaviour
{
private int x = 10;//宽度
private int y = 5;//高度
public GameObject prefabBrick;
// Start is called before the first frame update
void Start()
{
for (int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
GameObject.Instantiate(prefabBrick, new Vector3(i-5, j, 0), Quaternion.identity);
}
}
}
执行之后是这样

,想要的是这样,并且有刚体组件
b
我用预制体cube方块生成的前面,会散掉,不知道怎么回事?
cube物体有刚体组件,大小都是1,1,1的正方体;
这个是源代码:
public class RayDemo : MonoBehaviour
{
private int x = 10;//宽度
private int y = 5;//高度
public GameObject prefabBrick;
// Start is called before the first frame update
void Start()
{
for (int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
GameObject.Instantiate(prefabBrick, new Vector3(i-5, j, 0), Quaternion.identity);
}
}
}
执行之后是这样

,想要的是这样,并且有刚体组件
b
