title: Any difference between Component.CompareTag() and GameObject.CompreTag()?
body: <p>I'd like to know if there's any under-the-hood difference in the execution of these two CompareTag() calls:</p>
  <pre><code>private void OnTriggerEnter(Collider otherCollider)
  {
      if (otherCollider.CompareTag(&quot;TestTag&quot;))
      {
          Debug.Log(&quot;The other Collider is tagged: TestTag&quot;);
      }
  
      if (otherCollider.gameObject.CompareTag(&quot;TestTag&quot;))
      {
          Debug.Log(&quot;The other GameObject is tagged: TestTag&quot;);
      }
  }
  </code></pre>
  <p>I suspect they should be identical – a Component is always attached to one and only one GameObject, so it
  shouldn't be necessary to access the Component's &quot;.gameObject&quot; reference first.  Both calls behave identically as far as I can tell.</p>
  <p>I wonder because:</p>
  <ol>
  <li>Calling otherCollider.gameObject.CompareTag() doesn't result in a “name can be simplified” warning.  This could be because those classes and methods are in the UnityEngine namespace, and thus not covered by VisualStudio's warnings?</li>
  <li>The example in the Unity documentation for Component.CompareTag() explicitly uses the longer form of the call: other.gameObject.CompareTag(&quot;Player&quot;).  This could just be the result of a sloppy copy-paste from the GameObject.CompareTag() method's documentation, which provides an identical example?
  <a href="https://docs.unity3d.com/ScriptReference/Component.CompareTag.html" rel="nofollow noreferrer">https://docs.unity3d.com/ScriptReference/Component.CompareTag.html</a></li>
  </ol>