title: NavMeshNavigation - Load Failed: Object reference not set to an instance of an object
body: <p>EDIT: This is different from other questions because the code is much more specific to NavMesh code. I haven't found any questions specific to my code. (also other question seems to involve null?)</p>
  
  <p>I'm trying to learn NavMeshAgent for use in point and click movement for a game using RTS style movement. I keep getting errors. The first issue is "Load Failed: Object reference not set to an instance of an object" - my code is below.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class PlayerNavigation : MonoBehaviour {
  
      public Camera cam;
      public NavMeshAgent navMeshAgent;
  
      void Start () { 
          cam = Camera.main;
          navMeshAgent = GetComponent&lt;NavMeshAgent&gt;();
      }
  
      void Update () {
          if(Input.GetKeyDown  (KeyCode.Mouse0)){
              Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
              RaycastHit hit;
  
              if(Physics.Raycast( ray, out hit)){
                  navMeshAgent.SetDestination ( hit.point );
          }
      }
   }
  }
  </code></pre>
  
  <p>My next issue, seems to be compiling error. I'm hoping fixing the above code will fix it. When I press play, it says "All compiler errors have to be fixed before you can enter playmode"</p>
  
  <p>Any help would be greatly appreciated.</p>