代码控制用Cube创建一堵墙,如何避免运行的时候自动撞散?

PoorMonk丶 PoorMonk丶 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

public int width = 6;
public int height = 4;
public int zPos = 3;
private void CreateWall()
{
for (int x = -width / 2; x < width / 2; ++x)
{
for (int y = 0; y < height; ++y)
{
GameObject go = Instantiate(block, new Vector3(x, y, zPos), Quaternion.identity);
go.transform.SetParent(Wall);
}
}
}

block是一个Cube预制体,Transform.Position(0, 0.5, 0),添加了Rigidbody。

为什么手动把Block拖到Scene中不会有问题,用代码生成的墙就自动撞散了?
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
PoorMonk丶
Unity3D 2,590 成员 2,147 内容