Object spawner for tricks and treats

This commit is contained in:
DesignJiggles
2026-01-31 15:04:21 -06:00
parent 26262b19ec
commit 2a9006b10c
7 changed files with 432 additions and 13 deletions
+28
View File
@@ -0,0 +1,28 @@
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);
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 14b0bf07aa1abc44a8ebd00cecacd6f4