I essentially have a “Madness” button that i press which spawns a ton of enemies for me to kill (for testing). I notice that a bunch of them (as individual gameobjects) just vanish into thin air while the zombies are coming towards me. I can see the gameboject list shrinking a bit shortly after pressing my madness button.
So if my madness button spawns 100, approx only 50 actually survive.
Is this a garbage collector working? Am i hitting some kind of limit i don’t know about? All my zombies have animations, hitboxes, and rigibody2ds. The only thing that can kill my zombies are colliders tagged with “Projectile”. I’m not shooting my gun, so i know they aren’t dying due to my code.
The garbage collector picks up C# objects that are not referenced anywhere anymore. This does not include game objects.
I can see two possibilities:
- you’ve got some script destroying them
- some kind of physics makes them fall through the world/be launched into space
Does the zombies actually dissapear? As in, are they still in the hireachy panel? If they are, check where they went, otherwise check what scripts you have in the scene when the zombies are spawned.
Tip: if you have a script that’s named for example “KillField” that you think is causing this, but you don’t know what object the script is on, you can write “t:KillField” in the search bar of your hireachy, and you’ll get a list of all the objects with that script on it.