I have objects of type “Creep” that are colliding into a trigger to be destroyed. At first, I assigned them a tag and used this conditional (which does work):
void OnTriggerEnter(Collider other) {
if (other.gameObject.tag == "Creep")
But I’ve decided I’d rather check for the type of the object colliding so I don’t have to tag all future objects. I’ve been searching around and tried all of the following methods, none of which have worked:
if (other.GetType().ToString() == "Creep")
if (other.GetType() == Creep)
if (other is Creep)
if (other.GetType() == typeof(Creep))
Is there another way to do this that I’m not aware of? Or should one of these work and perhaps something else is causing the trouble?