Here is the code .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PipeSpawnScript : MonoBehaviour
{
public GameObject pipe;
public float spawnRate = 2;
private float timer = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (timer < spawnRate)
{
timer = timer + Time.deltaTime;
}
else
{
Instantiate(pipe, transform.position, transform.rotation);
timer = 0;
}
}
}
I want my object to come over and over again after certain intervals
New contributor
Vishal Dalal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.