Hello, I’ve been using some code (which I take no credit for using) which spawns enemies at set spawn points, at set intervals.
I have now included “blockages” to parts of the map. Meaning the player must remove them if they want to advance to a new part of the map.
Now I was hoping to make Spawn Points become “active” or “enabled” as the player removes these blockages. Pretty much like Call Of Duty: Zombies.
A huge thanks in advance if you can help me.
P.S: This is the spawning code that I have currently.
using UnityEngine;
using System.Collections;
public class SpawnWaveGenerator : MonoBehaviour
{
[System.Serializable]
public class enemy
{
public string name;
public GameObject prefab;
public float chance;
public float delayTime;
}
public Transform[] points;
public enemy[] enemies;
public int SpawnTimer;
enemy chosenEnemy;
float random;
float cumulative;
void Start()
{
SpawnTimer = 0;
}
void Update()
{
SpawnTimer = SpawnTimer + 1;
if (SpawnTimer >= 100)
{
SpawnRandom();
SpawnTimer = 0;
}
}
void SpawnRandom()
{
random = Random.value;
cumulative = 0f;
for (int i = 0; i < enemies.Length; i++)
{
cumulative += enemies*.chance;*
if (random < cumulative && Time.time >= enemies*.delayTime)*
{
chosenEnemy = enemies*;*
break;
}
}
Instantiate(chosenEnemy.prefab, points[Random.Range(0, points.Length)].position, points[Random.Range(0, points.Length)].rotation);
}
}