设置GameObject位置会使崩溃Unity

时间:2019-05-07 02:34:32

标签: c# unity3d

在脚本中,我实例化了一个GameObject。

float x = Random.Range(-cameraWidth / 2, cameraWidth / 2);
float y = Random.Range(-cameraHeight / 2, cameraHeight / 2);

Vector3 position = new Vector3(x, y, 0);

GameObject newCar= Instantiate(car, position, Quaternion.identity);

问题在于此代码使我的引擎崩溃。

当我尝试在另一点实例化它时,我发现问题出在我的载体上

GameObject newCar = Instantiate(car, new Vector3(0,0,0), Quaternion.identity);

我还尝试将实例化的对象位置设置为向量 position

newCar.transform.position = position;

但是它也崩溃了。

此向量有什么问题?我调试了它,值是正确的。

0 个答案:

没有答案
相关问题