using System.Collections; using UnityEngine; public class Spawner : MonoBehaviour { // Reference to the Prefab to Spawn [SerializeField] private GameObject objectToSpawn; // Time interval between spawns public float spawnInterval = 1f; void Start() { // Start the spawning process using a Coroutine StartCoroutine(SpawnRoutine()); } private IEnumerator SpawnRoutine() { // Infinite loop to keep spawning (can be modified) while (true) { // Wait for the specified interval yield return new WaitForSeconds(spawnInterval); // Spawn the object at the spawner's position and rotation Instantiate(objectToSpawn, transform.position, Quaternion.identity); } } }