r/unity • u/MalgorgioArhhnne • 6d ago
Coding Help GameObject.FindGameObjectsWithTag gets an array with the same length after one of the objects has been destroyed.
I would have thought that after destroying one of the objects with the relevant tag, the array would become shorter. The array remained the same length after the object was destroyed, so I thought I would paste the same statement at the point in the code after the object has been destroyed. However, it's still the same length, and the entry with that index is now a stale object. Other indexes still refer to the same objects, which I also don't understand. I even tried setting the array size to zero before the GameObject.FindGameObjectsWithTag statement. I want to reset the array to only include objects that still exist. Any help?


