title: Unity: NullReferenceException: Object reference not set to an instance of an object
body: <p>I am following an Unity tutorial. I face a problem when trying to detect collision in the game. This is the error: </p>
  
  <p>NullReferenceException: Object reference not set to an instance of an object</p>
  
  <p>This is the script:</p>
  
  <pre class="lang-c# prettyprint-override"><code>using UnityEngine;
  
  public class Collide : MonoBehaviour
  {
      public Movement movement;     // A reference to our PlayerMovement script
  
      // This function runs when we hit another object.
      // We get information about the collision and call it "collisionInfo".
      void OnCollisionEnter(Collision collisionInfo)
      {
          // We check if the object we collided with has a tag called "Obstacle".
          if (collisionInfo.collider.tag == "Obstacle")
          {
              movement.enabled = false;   // Disable the players movement.
              Debug.Log("Coollision occured");
          }
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oPjKj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oPjKj.png" alt=""></a></p>
  
  <p><a href="https://i.stack.imgur.com/Ytb47.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ytb47.jpg" alt=""></a></p>