1
0
mirror of https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git synced 2025-01-22 15:18:25 -05:00
UDRIGEEKCup2024/Assets/Obstacles/ObjectSpawner.cs

31 lines
791 B
C#
Raw Normal View History

2024-04-18 12:52:07 -04:00
using System;
using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
namespace MAVRIC.GEEKCup.Obstacles
{
public class ObjectSpawner : MonoBehaviour
{
public float minTimeToSpawn = 1.0f;
public float maxTimeToSpawn = 5.0f;
public GameObject spawningObject;
private void Start()
{
StartCoroutine(Spawning());
IEnumerator Spawning()
{
while (true)
{
float randTime = Random.Range(minTimeToSpawn, maxTimeToSpawn);
yield return new WaitForSeconds(randTime);
Instantiate(spawningObject, transform.position, Quaternion.identity);
}
}
}
}
}