title: Where is the error in my script causing my player to not be able to jump after jumping into a wall?
body: <p>I have been coding a game for about an hour now and I have run into an error with my script that I can't seem to fix. What I mainly seem to be focusing on is the isGrounded update part of my script:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    private void OnCollisionExit2D(Collision2D collision)
      {
          isGrounded = false;
  
      }
      private void OnCollisionEnter2D(Collision2D collision2)
      {
          isGrounded = true;
      }
  </code></pre>
  
  <p>But I am concerned it might be a different part of my script because I don't think anything is wrong with this part. Here is the full script:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using UnityEngine;
  using System.Collections;
  
  public class move : MonoBehaviour
  {
  
      public float speed;
      float moveVelocity;
  
      public float jumpPower = 300.0f;
      private bool isGrounded = false;
      private bool facingEast = false;
  
      void Update()
      {
  
          moveVelocity = 0;
  
          //Left Right Movement
          if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
          {
              moveVelocity = -speed;
              facingEast = false;
          }
          if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
          {
              moveVelocity = speed;
              facingEast = true;
          }
  
          GetComponent&lt;Rigidbody2D&gt;().velocity = new Vector2(moveVelocity, GetComponent&lt;Rigidbody2D&gt;().velocity.y);
  
          Rigidbody2D rb = GetComponent&lt;Rigidbody2D&gt;();
          if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Space))
          {
              if (isGrounded == true)
              {
                  rb.AddForce(Vector2.up * jumpPower);
              }
          }
  
      }
      private void OnCollisionExit2D(Collision2D collision)
      {
          isGrounded = false;
  
      }
      private void OnCollisionEnter2D(Collision2D collision2)
      {
          isGrounded = true;
      }
  }
  </code></pre>
  
  <p>Sorry if this is a bad question or if there is an obvious answer and I am just being stupid. I am still fairly new to C#</p>