Is there a way to count objects that has a certain tag then put the number on a GUI? for example if there was 5 enemies all with an enemy tag, is there a way to publish that on a GUI text and if one enemy dies the number on the GUI go’s to 4 as well??
var enemies : GameObject;
enemies = GameObject.FindGameObjectsWithTag(“Enemy”);
var count = enemies.length;
BUT!!! That would mean you are constantly throwing all this and Find function are expensive since they need to go through all the object of the game.
Instead keep a static counter that is incresed when instantiating and decreased when destroying.