Unity:シーンにランダムにプレハブを出現させる

Unity

ParticleController

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleController : MonoBehaviour
{
    public GameObject effect;

    // Update is called once per frame
    void Update()
    {
        if(Time.frameCount % 60 == 0)
		{
            // プレハブ発生
            Instantiate(effect, new Vector3(Random.Range(-4.7f, 4.7f), Random.Range(-4.7f, 4.7f), Random.Range(-4.7f, 4.7f)), Quaternion.identity);
		}
    }
}

コメント