using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectPool : MonoBehaviour
{
[SerializeField] float waitTimer = 2f;
[SerializeField] float spawnTimer = 0f;
[SerializeField] GameObject enemy;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
spawnTimer += Time.deltaTime;
if (waitTimer < spawnTimer)
{
SpawnEnemy();
spawnTimer = spawnTimer - waitTimer;
}
}
void SpawnEnemy()
{
Instantiate<GameObject>(enemy, transform.position, Quaternion.identity);
}
}