Files
ggj2026/Assets/Scripts/Spawner.cs
T
Walter 77d2abd60c Merging all the things
Adding in the spawning and treat picking up.
2026-01-31 15:34:32 -06:00

29 lines
793 B
C#

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);
}
}
}