Hello. i'm trying to find it in searches but fail.
FindWithTag returns a null which in if() clause interpreted as false. what i can use so to check if there any instances of the same prefab left in the scene.
i just used this line
if(!(!GameObject.FindWithTag("Target"))){}
works fine but maybe there is a better way
You can use
if (GameObject.FindWithTag("Target") != null) { //objects left }
or, if you intend to use the gameobject
var go = GameObject.FindWithTag("Target"); if (go != null) { //objects left, can do stuff with go }
You can also skip the != null entirely, but that loses some of the description of what it's doing