title: Trying to program a 2D Unity code that shows if my character is grounded or not and it's not working
body: <p>How can I make the ground so that the character recognize that it is ground? I'm trying to do a 2D jump movement. It's either the <code>Collisions2D</code> couldn't find <code>GetComponent</code> or the game works but the character doesn't jump at all.</p>
  <p><strong>Error:</strong></p>
  <blockquote>
  <p>error CS1061: 'Collision2D' does not contain a definition for
  'GetComponent' and no accessible extension method 'GetComponent'
  accepting a first argument of type 'Collision2D' could be found</p>
  </blockquote>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Grounded : MonoBehaviour
  {
      GameObject Player;
  
      void Start()
      {
          Player = GetComponentInParent&lt;GameObject&gt;();
      }
  
      void Update(){
      }
      
      void OnCollisionEnter2D(Collision2D col) {
      
          if (col.GetComponent&lt;Collider2D&gt;().tag == &quot;Ground&quot;) {
          
              Player.GetComponent&lt;Move2D&gt;().isGrounded = true;
              
          }
      }
      
      void OnCollisionExit2D(Collision2D col) {
      
          if (col.GetComponent&lt;Collider2D&gt;().tag == &quot;Ground&quot;) {
          
              Player.GetComponent&lt;Move2D&gt;().isGrounded = false;
              
          }
      }
  }
  </code></pre>