Merging all the things
Adding in the spawning and treat picking up.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user