I have a list that I using to store the current buildings in a units sight for an RTS game. Whenever that building is destroyed it just says missing inside the list where it was inside the list. I’m wondering how to reduce the list so that it doesn’t say missing and the size of the list will go down one when the building is destroyed. Thank you and please let me know if you need more information
There is a method to resize an array in
Resize(ref array, int newSize), but the bad thing is, in your example, if you were to resize the array, HQ would disappear from the array, so you’d have to figure out a way to calculate the number of objects inside of an array, that are not missing, moving them to the start of an array and then resizing to the number of objects that are not missing in the array.
Instead, I would suggest using a list. The way you declare it is:
List<T> yourList = new List<T>(); where
T is the type of the object that you want to use. Then it’s as simple as just calling
Remove() on it, for specific objects.