Hello. How can I count the number of objects with a certain tag that are in a scene at the current time(I eventually want to set up something like "if there are > 20 objects with the tag "Enemy" do...")?Thanks
Hi!
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("Enemy");
if(gos.length > 20)
{
// Do Something
}
Hope it helps!
1 Like
Or if you want to do this in just one line:
if(GameObject.FindGameObjectsWithTag("Enemy").Length > 20) {
// Do something
}