title: Unity3D: NullReferenceException: Object reference not set to an instance of an object
body: <p>I want to access Hero.class variable "aspect" from laserController.class, but I receive an error message : <code>NullReferenceException: Object reference not set to an instance of an object</code>.</p>
  
  <p>Hero.class</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Hero : MonoBehaviour {
  
  public float aspect = 0.1f;
  void Update () {
  
      }
  }
  </code></pre>
  
  <p>laserController.class</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class laserController : MonoBehaviour {
  
  public float health = 0f;
  //public float aspect = 0.1f;
  
  void OnCollisionEnter(Collision collision) {
      if(collision.gameObject.tag == "enemy"){
          Destroy(gameObject);
          Destroy(collision.gameObject);
      }
   }      
  
  void Update () {
  
      Hero direction = gameObject.GetComponent&lt;Hero&gt;();
  
      //LaserHealth
      health += Time.deltaTime;
  
      if(health &gt; 7f){
          Destroy(gameObject);
      } 
      //problem in here
      transform.Translate(Vector3.up * -direction.aspect);
  
      }
  }
  </code></pre>