(Unity6 BRP)一定間隔でオブジェクトを生成する方法(タイマーの活用)

(サンプルコード)

using UnityEngine;

public class AutoGene2 : MonoBehaviour
{
    public GameObject ballPrefab;
    private float timer = 0;

    void Update()
    {
        timer += Time.deltaTime;

        if(timer >= 1.0f)
        {
            Instantiate(ballPrefab, transform.position, Quaternion.identity);
            timer = 0;
        }
    }
}

(実行結果)