Trick is now pickup-able and is not scored by baskets

This commit is contained in:
hz
2026-01-31 18:55:26 -06:00
parent c24846d568
commit 7d1b387d19
6 changed files with 86 additions and 6 deletions
+26 -3
View File
@@ -9,9 +9,18 @@ public class Spawner : MonoBehaviour
// Time interval between spawns
public float spawnInterval = 1f;
[SerializeField] private int maxAlive = 0;
[SerializeField] private bool spawnOnStart = true;
private readonly List<GameObject> spawned = new List<GameObject>();
private void OnEnable()
{
if (spawnOnStart)
{
SpawnOnce();
}
}
void Start()
{
// Start the spawning process using a Coroutine
@@ -35,12 +44,26 @@ public class Spawner : MonoBehaviour
continue;
}
// Spawn the object at the spawner's position and rotation
var instance = Instantiate(objectToSpawn, transform.position, Quaternion.identity);
spawned.Add(instance);
SpawnOnce();
}
}
private void SpawnOnce()
{
if (objectToSpawn == null)
{
return;
}
if (maxAlive > 0 && CountAlive() >= maxAlive)
{
return;
}
var instance = Instantiate(objectToSpawn, transform.position, Quaternion.identity);
spawned.Add(instance);
}
private int CountAlive()
{
for (var i = spawned.Count - 1; i >= 0; i--)