When 0 elements with a tag, get a value of 13
I'm trying to count out the number of enemies in a scene by using tags, but I keep getting the value 13 when there are no enemies.
I put the check in the Start() function, and I'm still getting 13 there!
When I look through the elements in my scene, none of them are tagged "Enemy".
Here's the code:
void Start()
{
Debug.Log(GameObject.FindGameObjectsWithTag("Enemy").Length);
}
If any enemies appear on-screen, the value goes up with 13 being the base (1 enemy means 14, 2 enemies means 15, etc).
I'm still new in Unity. What am I doing wrong?
Edit: just tested, it doesn't matter which object I do this check in.
Answer by MI_Buddy · Oct 10, 2017 at 05:37 PM
Restarted Unity, I'd removed an element prefab and it looks like Unity glitched out. When I re-opened the prefab was gone from the list. Things are working as expected now!
Your answer
Follow this Question
Related Questions
Get Childrens to new array from perents array. 1 Answer
GameObject[] doesn't have a definition for transform/name/etc... 1 Answer
Why can't I find a GameObject with FindGameObjectsWithTag 2 Answers
Change max range attribute? 0 Answers
How to find all GameObjects with different tags excluding some tags. 0 Answers