title: Why am I getting a NullReferenceException in this specific case?
body: <p>This is what I see when I start up the game: <a href="http://i.imgur.com/lwfkWlw.png" rel="nofollow">http://i.imgur.com/lwfkWlw.png</a> The last error happens when I press "space".</p>
  
  <p>Ok, so I even put the "ResourcesScript" onto the "Cube" manually from the editor and it still can't find it with "GetComponenet  ();" :S The Actor class was initially used to create the component (and ITS reference to it exists and is not a null):</p>
  
  <pre><code>void Awake () {
      resource = gameObject.AddComponent &lt;ResourcesScript&gt; ();
  }
  </code></pre>
  
  <p>This is the entire ResourcesScript:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  
  public class ResourcesScript : MonoBehaviour {
      public GameObject attatchedGameObject;
      public Rigidbody attatchedRigidbody;
  
      public BehaviourStateResource behaviourResource;
      public BehaviourStateManager behaviourManager;
  
      public MovementStats moveStats;
      public MovementStatsManager moveManager;
      public State currentMovementState;
  
      public HealthStats healthStats;
      public HealthStats armorStats;
      public HealthStats shieldStats;
      //public HealthManager healthManager;
  
      void Start () {
          attatchedGameObject = gameObject;
          attatchedRigidbody = gameObject.GetComponent &lt;Rigidbody&gt; ();
  
          behaviourResource = new BehaviourStateResource ();
          behaviourManager = gameObject.AddComponent &lt;BehaviourStateManager&gt; ();
  
          moveStats = new MovementStats (new Stat (10.0f), new Stat (10.0f), 10.0f, new Stat (10.0f), new Stat (10.0f), 10.0f);
          moveManager = new MovementStatsManager (this);
          currentMovementState = gameObject.AddComponent &lt;DefaultState&gt; ();
  
          healthStats = new HealthStats (new Stat (10.0f), new Stat (10.0f), new Stat (10.0f));
          armorStats = new HealthStats (new Stat (10.0f), new Stat (10.0f), new Stat (10.0f));
          shieldStats = new HealthStats (new Stat (10.0f), new Stat (10.0f), new Stat (10.0f));
          //healthManager = gameObject.AddComponent &lt;HealthManager&gt; ();
      }
  }
  </code></pre>
  
  <p>And finally, this is an example of a class that uses the GetComponent to get the object... but fails to find one:</p>
  
  <pre><code>public class BehaviourStateManager : MonoBehaviour {
      public ResourcesScript resource;
  
      void Start () {
          resource = gameObject.GetComponent &lt;ResourcesScript&gt; ();
          Utilities.Validate &lt;ResourcesScript&gt; (resource, this);
      }
  }
  </code></pre>
  
  <p>I've been at this for a long time and I can't seem to find the problem. </p>