Search Unity

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

Discussion in 'Physics' started by KarlKarl2000, Jan 22, 2020.

  1. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi guys

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

    Code (CSharp):
    1.    void OnTriggerStay(Collider other)
    2.     {
    3.         if (other.name == "hero")
    4.         {
    5.          }
    6.      }
    Thanks
     
  2. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    400
    KarlKarl2000 likes this.