ランダムな場所にクローン生成※編集中

Clone.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Clone : MonoBehaviour
{
    [SerializeField]
    GameObject prefab;
    int count = 0;
    int max = 50;   

    void Start()
    {
        InvokeRepeating("Generate", 1, 1);

    }
    void Generate()
    {
        if (count == max) return;
        float x = Random.Range(0f, 500f);
        float y = 0;
        float z = Random.Range(0f, 500f);
        Vector3 position = new Vector3(x, y, z);
        Instantiate(prefab, new Vector3(x, y, z), Quaternion.identity);
        count++;
    }
}
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.