public GameObject enemy;
public int amountToPool;
public List poolObjects;
EnemyHealthBar health;
public Text text;
Transform spawnPoint;
Enemy respawnNew;
// Use this for initialization
void Start()
{
health = FindObjectOfType<EnemyHealthBar>();
poolObjects = new List<GameObject>();
for(int i = 0; i < amountToPool; i++)
{
GameObject obj = (GameObject)Instantiate(enemy);
poolObjects.Add(obj);
text.text = "Enemies " + poolObjects.Count;
}
}
private void Update()
{
RemoveInactive
}
public void RemoveInactive()
{
for (int i = 0; i < poolObjects.Count; i++)
{
if (!poolObjects*.activeInHierarchy)*
{
poolObjects.Remove(poolObjects*);*
text.text = "Enemies " + poolObjects.Count;
GameObject obj = Instantiate(enemy);
poolObjects.Add(obj);
//enemy.SetActive(true);
}
else
{
return;
}
}
Cant Remove from list everytime the object is inactive or destroyed don’t know what do… It makes as much sense too me but the code never does it >:O