title: MissingComponentException there is no rigidbody2D attached to gameObject but a script is trying to access it
body: <p>Im getting this error. I have no idea why.</p>
  
  <p>Heres a screen shot:</p>
  
  <p><a href="http://www.siz.co.il/my.php?i=gmfmczmo3gzl.png" rel="nofollow">http://www.siz.co.il/my.php?i=gmfmczmo3gzl.png</a></p>
  
  <p>And my script code:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class PlayerMovementV2 : MonoBehaviour
  {
  public KeyCode moveUp;
  public KeyCode moveDown;
  public KeyCode moveRight;
  public KeyCode moveLeft;
  
  public float playerVelocity = 1;
  
  public Rigidbody2D rigid2D;
  public Vector2 vector2;
  
  // Use this for initialization
  void Start()
  {
      rigid2D = GetComponent&lt;Rigidbody2D&gt;();
      vector2 = new Vector2(rigid2D.velocity.x, playerVelocity);
  }
  
  
  // Update is called once per frame
  void Update()
  {
      if (Input.GetKey(moveUp))
      {
          rigid2D.velocity = vector2;
      }
      else
          if (Input.GetKey(moveDown))
          {
              rigid2D.velocity = new Vector2(rigid2D.velocity.x,playerVelocity);
          }
  }
  }
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>As far as i seen from the picture there is a script attached to the gmae object so what does Unity3D wants from me?</p>
  
  <p>PS:
  Its the latest Unity3D version. Downloaded it yesterday.</p>