20/03/08 17:40:35.63 +9Yp1l0D.net
>>776
いろいろ試してはいるのですがなんかエラー出ますm(__)m
そもそも生成自体ちゃんとできてないみたいです
どのように記述すればいいのでしょうか・・・?
public class sousa : MonoBehaviour
{
public GameObject obj; // インスペクターでプレハブ接続済み
public GameObject [] go=new GameObject[5];
// Start is called before the first frame update
void Start()
{
for (int i = 0; i <= 5; i++) // オブジェクト複数生成
{
go[i] = Instantiate(obj);
go[i].transform.position = new Vector3(i, 0, 0);
}
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0)) //マウスクリックでランダム選択
{
Destroy(go[Random.Range(0,5)]);
}
}
}