Y
Y
yraiv2022-03-22 20:07:30
Unity
yraiv, 2022-03-22 20:07:30

How to check for the presence of an object in the scene with a specific tag?

I'm confused about something. How to do it?

if (GameObject.FindGameObjectsWithTag("Zombie") == null)
        {
            Debug.Log("12");
            _textWave.GetComponent<AnimationText>().SetTextWave();
        }

How to check that there are no objects in the scene? debug is not running

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GFX Data, 2022-03-22
@yraiv

An empty array is returned if there are no such objects.

if (GameObject.FindGameObjectsWithTag("Zombie").Length < 1)

F
Farawa, 2022-03-22
@Farawa

it's better not to search like that, but to create a class that will store them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question