【ゲームエンジン】Unity初心者質問スレBuild3at GAMEDEV
【ゲームエンジン】Unity初心者質問スレBuild3 - 暇つぶし2ch777:名前は開発中のものです。
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)]);
}
}
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch