Which is more expensive? other.name vs other.tag

Hi guys

As the subject asks. Is using other.name efficient? Should compareTag be used instead?

   void OnTriggerStay(Collider other)
    {
        if (other.name == "hero")
        {
         }
     }

Thanks

Not quite the question you asked but i think this is probably relevant. Of course, best to profile if you really want to know as performance can vary quite a bit between unity versions and i think the linked thread is quite old:

1 Like