mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-22 07:08:51 -05:00
31 lines
791 B
C#
31 lines
791 B
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|