0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at
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++;
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?