Add most of research

This commit is contained in:
Bram verhulst
2025-05-31 15:54:23 +02:00
commit 70f128f092
270 changed files with 80847 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using System;
using UnityEngine;
public class Spawner : MonoBehaviour
{
[SerializeField] private GameObject _spawnTemplate = null;
[SerializeField] private int _spawnCount = 1;
[SerializeField] private float _spawnInterval = 1.0f;
private float _nextSpawnTime = 0.0f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
_nextSpawnTime = Time.time + _spawnInterval;
}
private void Update()
{
if (Time.time >= _nextSpawnTime)
{
for (int i = 0; i < _spawnCount; i++)
{
Spawn();
}
_nextSpawnTime = Time.time + _spawnInterval;
}
}
public GameObject Spawn()
{
if (_spawnTemplate == null)
{
Debug.LogError("Spawn template is not assigned in the Spawner component.");
return null;
}
GameObject spawnedObject = Instantiate(_spawnTemplate, transform.position, transform.rotation);
spawnedObject.transform.SetParent(transform); // Optional: Set parent to keep hierarchy organized
return spawnedObject;
}
}