Hello,
So I have a simple list where I store a set of enemy spawn points. Every so often, the spawn points change. So whenever I create new spawn points I clear the list using List.Clear() and destroy the old spawn points, create new spawn points and add them to the list. Easy, right?
Well the problem is when I clear the list using List.Clear() (or setting it equal to a new List) it leaves behind missing elements. What it looks like:
This is my code:
ClearSpawnPoints function:
void ClearSpawnPoints()
{
Debug.Log("Clearing Points");
enemySpawnPoints.Clear();
Debug.Log("Cleared Points! Count is: " + enemySpawnPoints.Count );
}
Update Function:
if (enemySpawnPoints.Count > 0)
{
Debug.Log("Current Count: " + enemySpawnPoints.Count);
//Do Stuff
}
If it helps at all, when I clear the list, it is saying that the count is equal to 0. In the update function however it is saying that the list is equal to the previous list amount + the current List amount:
The red line is the point that I clear the list and create new ones. I only create 11 new points. I have no idea why this is occurring. If anyone has seen anything similar to this and why it might be doing this, please let me know.
Thank You in advance.