1
我在每隔1秒間隔後實例化一個特定的預製。this.transform.position + new Vector3(0,y,0)更改遊戲對象的z軸
float y = Random.Range(-0.5f, 1f);
GameObject newObject = Instantiate (this.prefabToSpawn, this.transform.position + new Vector3(0,y,0),Quaternion.identity);
每次我實例,我只是想改變沿y遊戲對象的位置 - 軸,但是如果我添加上面的代碼中,新的遊戲目標更進了後面沿z - 軸(甚至在y軸上也有一個隨機變化,雖然它似乎工作正常,但它只需要保留它的z位置),因此不會再出現在場景中。我哪裏錯了?